summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libcxx/include/type_traits7
-rw-r--r--libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp62
2 files changed, 54 insertions, 15 deletions
diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index c44cae63908..52fb5902485 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -430,9 +430,12 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> :
namespace __libcpp_is_function_imp
{
+struct __dummy_type {};
template <class _Tp> char __test(_Tp*);
+template <class _Tp> char __test(__dummy_type);
template <class _Tp> __two __test(...);
-template <class _Tp> _Tp& __source();
+template <class _Tp> _Tp& __source(int);
+template <class _Tp> __dummy_type __source(...);
}
template <class _Tp, bool = is_class<_Tp>::value ||
@@ -441,7 +444,7 @@ template <class _Tp, bool = is_class<_Tp>::value ||
is_reference<_Tp>::value ||
__is_nullptr_t<_Tp>::value >
struct __libcpp_is_function
- : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>())) == 1>
+ : public integral_constant<bool, sizeof(__libcpp_is_function_imp::__test<_Tp>(__libcpp_is_function_imp::__source<_Tp>(0))) == 1>
{};
template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type {};
diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp
index 82757f5035b..b1df4f2d3f4 100644
--- a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp
+++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.cat/function.pass.cpp
@@ -13,8 +13,19 @@
#include <type_traits>
+using namespace std;
+
+class Class {};
+
+enum Enum1 {};
+#if __cplusplus >= 201103L
+enum class Enum2 : int {};
+#else
+enum Enum2 {};
+#endif
+
template <class T>
-void test_function_imp()
+void test()
{
static_assert(!std::is_void<T>::value, "");
#if _LIBCPP_STD_VER > 11
@@ -34,19 +45,44 @@ void test_function_imp()
static_assert( std::is_function<T>::value, "");
}
-template <class T>
-void test_function()
-{
- test_function_imp<T>();
- test_function_imp<const T>();
- test_function_imp<volatile T>();
- test_function_imp<const volatile T>();
-}
+// Since we can't actually add the const volatile and ref qualifiers once
+// later let's use a macro to do it.
+#define TEST_REGULAR(...) \
+ test<__VA_ARGS__>(); \
+ test<__VA_ARGS__ const>(); \
+ test<__VA_ARGS__ volatile>(); \
+ test<__VA_ARGS__ const volatile>()
+
+
+#define TEST_REF_QUALIFIED(...) \
+ test<__VA_ARGS__ &>(); \
+ test<__VA_ARGS__ const &>(); \
+ test<__VA_ARGS__ volatile &>(); \
+ test<__VA_ARGS__ const volatile &>(); \
+ test<__VA_ARGS__ &&>(); \
+ test<__VA_ARGS__ const &&>(); \
+ test<__VA_ARGS__ volatile &&>(); \
+ test<__VA_ARGS__ const volatile &&>()
+
int main()
{
- test_function<void ()>();
- test_function<void (int)>();
- test_function<int (double)>();
- test_function<int (double, char)>();
+ TEST_REGULAR( void () );
+ TEST_REGULAR( void (int) );
+ TEST_REGULAR( int (double) );
+ TEST_REGULAR( int (double, char) );
+ TEST_REGULAR( void (...) );
+ TEST_REGULAR( void (int, ...) );
+ TEST_REGULAR( int (double, ...) );
+ TEST_REGULAR( int (double, char, ...) );
+#if __cplusplus >= 201103L
+ TEST_REF_QUALIFIED( void () );
+ TEST_REF_QUALIFIED( void (int) );
+ TEST_REF_QUALIFIED( int (double) );
+ TEST_REF_QUALIFIED( int (double, char) );
+ TEST_REF_QUALIFIED( void (...) );
+ TEST_REF_QUALIFIED( void (int, ...) );
+ TEST_REF_QUALIFIED( int (double, ...) );
+ TEST_REF_QUALIFIED( int (double, char, ...) );
+#endif
}
OpenPOWER on IntegriCloud