[cfe-commits] [libcxx] r111389 - in /libcxx/trunk: include/type_traits test/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp www/libcxx_by_chapter.pdf
Howard Hinnant
hhinnant at apple.com
Wed Aug 18 11:52:04 PDT 2010
Author: hhinnant
Date: Wed Aug 18 13:52:04 2010
New Revision: 111389
URL: http://llvm.org/viewvc/llvm-project?rev=111389&view=rev
Log:
Updated by-chapter chart with weekly test results. Also did some prototyping on result_of, but if-def'd out the prototyped part (which the LWG may or may not accept)
Modified:
libcxx/trunk/include/type_traits
libcxx/trunk/test/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp
libcxx/trunk/www/libcxx_by_chapter.pdf
Modified: libcxx/trunk/include/type_traits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=111389&r1=111388&r2=111389&view=diff
==============================================================================
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Wed Aug 18 13:52:04 2010
@@ -1321,6 +1321,71 @@
typedef decltype(declval<_Fn>()(declval<_ArgTypes>()...)) type;
};
+#if 0
+
+template <class _MP, class _Tp, class ..._Args>
+struct __result_of_mp;
+
+// member function pointer
+
+template <class _R, class _Class, class _Tp, class ..._Params, class ..._Args>
+struct __result_of_mp<_R (_Class::*)(_Params...), _Tp, _Args...>
+{
+ typedef _R type;
+};
+
+template <class _R, class _Class, class _Tp, class ..._Params, class ..._Args>
+struct __result_of_mp<_R (_Class::*)(_Params...) const, _Tp, _Args...>
+{
+ typedef _R type;
+};
+
+template <class _R, class _Class, class _Tp, class ..._Params, class ..._Args>
+struct __result_of_mp<_R (_Class::*)(_Params...) volatile, _Tp, _Args...>
+{
+ typedef _R type;
+};
+
+template <class _R, class _Class, class _Tp, class ..._Params, class ..._Args>
+struct __result_of_mp<_R (_Class::*)(_Params...) const volatile, _Tp, _Args...>
+{
+ typedef _R type;
+};
+
+// member data pointer
+
+template <class _MP, class _Tp, bool>
+struct __result_of_mdp;
+
+template <class _R, class _Class, class _Tp>
+struct __result_of_mdp<_R _Class::*, _Tp, false>
+{
+ typedef typename __apply_cv<decltype(*_STD::declval<_Tp>()), _R>::type type;
+};
+
+template <class _R, class _Class, class _Tp>
+struct __result_of_mdp<_R _Class::*, _Tp, true>
+{
+ typedef typename __apply_cv<_Tp, _R>::type&& type;
+};
+
+template <class _R, class _Class, class _Tp>
+struct __result_of_mp<_R _Class::*, _Tp>
+ : public __result_of_mdp<_R _Class::*, _Tp,
+ is_base_of<_Class, typename remove_reference<_Tp>::type>::value>
+{
+};
+
+template <class _Fn, class _Tp, class ..._ArgTypes>
+class __result_of<_Fn(_Tp, _ArgTypes...), false> // _Fn must be member pointer
+ : public __result_of_mp<_Fn, _Tp, _ArgTypes...>
+{
+};
+
+#endif
+
+// result_of
+
template <class _Fn, class ..._ArgTypes>
class result_of<_Fn(_ArgTypes...)>
: public __result_of<_Fn(_ArgTypes...),
Modified: libcxx/trunk/test/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp?rev=111389&r1=111388&r2=111389&view=diff
==============================================================================
--- libcxx/trunk/test/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp (original)
+++ libcxx/trunk/test/utilities/meta/meta.trans/meta.trans.other/result_of.pass.cpp Wed Aug 18 13:52:04 2010
@@ -1 +1 @@
-//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// result_of<Fn(ArgTypes...)>
#include <type_traits>
typedef bool (&PF1)();
typedef short (*PF2)(long);
struct S
{
operator PF2() const;
double operator()(char, int&);
};
int main()
{
static_assert((std::is_same<std::result_of<S(int)>::type, short>::value), "Error!");
static_assert((std::is_same<std::result_of<S&(unsigned char, int&)>::type, double>::value), "Error!");
static_assert((std::is_same<std::result_of<PF1()>::type, bool>::value), "Error!");
}
\ No newline at end of file
+//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// <functional>
// result_of<Fn(ArgTypes...)>
#include <type_traits>
#include <memory>
typedef bool (&PF1)();
typedef short (*PF2)(long);
struct S
{
operator PF2() const;
double operator()(char, int&);
void calc(long) const;
char data_;
};
typedef void (S::*PMS)(long) const;
typedef char S::*PMD;
int main()
{
static_assert((std::is_same<std::result_of<S(int)>::type, short>::value), "Error!");
static_assert((std::is_same<std::result_of<S&(unsigned char, int&)>::type, double>::value), "Error!");
static_assert((std::is_same<std::result_of<PF1()>::type, bool>::value), "Error!");
// static_assert(std::is_sa
me<std::result_of<PMS(std::unique_ptr<S>, int)>::type, void>::value, "Error!");
// static_assert(std::is_same<std::result_of<PMD(S)>::type, char&&>::value, "Error!");
// static_assert(std::is_same<std::result_of<PMD(const S*)>::type, const char&>::value, "Error!");
}
\ No newline at end of file
Modified: libcxx/trunk/www/libcxx_by_chapter.pdf
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/libcxx_by_chapter.pdf?rev=111389&r1=111388&r2=111389&view=diff
==============================================================================
Binary files - no diff available.
More information about the cfe-commits
mailing list