Jelajahi Sumber

In C++03, a bunch of the arithmetic/logical/comparison functors (such as negate/bit_not.pass/logical_not) were defined as deriving from unary_funtion. That restriction was removed in C++11, but the tests still check for this. Change the test to look for the embedded types first_argument/second_argument/result_type. No change to the library, just more standards-compliant tests. Thanks to STL @ Microsoft for the suggestion.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@225402 91177308-0d34-0410-b5e6-96231b3b80d8
Marshall Clow 10 tahun lalu
induk
melakukan
87d03942c4

+ 2 - 1
test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp

@@ -19,7 +19,8 @@ int main()
 {
     typedef std::negate<int> F;
     const F f = F();
-    static_assert((std::is_base_of<std::unary_function<int, int>, F>::value), "");
+    static_assert((std::is_same<F::argument_type, int>::value), "" );
+    static_assert((std::is_same<F::result_type, int>::value), "" );
     assert(f(36) == -36);
 #if _LIBCPP_STD_VER > 11
     typedef std::negate<> F2;

+ 2 - 1
test/std/utilities/function.objects/bitwise.operations/bit_not.pass.cpp

@@ -20,7 +20,8 @@ int main()
 #if _LIBCPP_STD_VER > 11
     typedef std::bit_not<int> F;
     const F f = F();
-    static_assert((std::is_base_of<std::unary_function<int, int>, F>::value), "");
+    static_assert((std::is_same<F::argument_type, int>::value), "" );
+    static_assert((std::is_same<F::result_type, int>::value), "" );
     assert((f(0xEA95) & 0xFFFF ) == 0x156A);
     assert((f(0x58D3) & 0xFFFF ) == 0xA72C);
     assert((f(0)      & 0xFFFF ) == 0xFFFF);

+ 2 - 1
test/std/utilities/function.objects/logical.operations/logical_not.pass.cpp

@@ -19,7 +19,8 @@ int main()
 {
     typedef std::logical_not<int> F;
     const F f = F();
-    static_assert((std::is_base_of<std::unary_function<int, bool>, F>::value), "");
+    static_assert((std::is_same<F::argument_type, int>::value), "" );
+    static_assert((std::is_same<F::result_type, bool>::value), "" );
     assert(!f(36));
     assert(f(0));
 #if _LIBCPP_STD_VER > 11

+ 2 - 1
test/std/utilities/function.objects/negators/unary_negate.pass.cpp

@@ -19,7 +19,8 @@ int main()
 {
     typedef std::unary_negate<std::logical_not<int> > F;
     const F f = F(std::logical_not<int>());
-    static_assert((std::is_base_of<std::unary_function<int, bool>, F>::value), "");
+    static_assert((std::is_same<F::argument_type, int>::value), "" );
+    static_assert((std::is_same<F::result_type, bool>::value), "" );
     assert(f(36));
     assert(!f(0));
 }