[libcxx] r225402 - 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.

Marshall Clow mclow.lists at gmail.com
Wed Jan 7 13:51:30 PST 2015


Author: marshall
Date: Wed Jan  7 15:51:30 2015
New Revision: 225402

URL: http://llvm.org/viewvc/llvm-project?rev=225402&view=rev
Log:
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.

Modified:
    libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp
    libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_not.pass.cpp
    libcxx/trunk/test/std/utilities/function.objects/logical.operations/logical_not.pass.cpp
    libcxx/trunk/test/std/utilities/function.objects/negators/unary_negate.pass.cpp

Modified: libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp?rev=225402&r1=225401&r2=225402&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/function.objects/arithmetic.operations/negate.pass.cpp Wed Jan  7 15:51:30 2015
@@ -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;

Modified: libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_not.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_not.pass.cpp?rev=225402&r1=225401&r2=225402&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_not.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/function.objects/bitwise.operations/bit_not.pass.cpp Wed Jan  7 15:51:30 2015
@@ -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);

Modified: libcxx/trunk/test/std/utilities/function.objects/logical.operations/logical_not.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/logical.operations/logical_not.pass.cpp?rev=225402&r1=225401&r2=225402&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/logical.operations/logical_not.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/function.objects/logical.operations/logical_not.pass.cpp Wed Jan  7 15:51:30 2015
@@ -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

Modified: libcxx/trunk/test/std/utilities/function.objects/negators/unary_negate.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/function.objects/negators/unary_negate.pass.cpp?rev=225402&r1=225401&r2=225402&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/function.objects/negators/unary_negate.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/function.objects/negators/unary_negate.pass.cpp Wed Jan  7 15:51:30 2015
@@ -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));
 }





More information about the cfe-commits mailing list