diff --git a/libcxx/test/std/utilities/function.objects/comparisons/equal_to.pass.cpp b/libcxx/test/std/utilities/function.objects/comparisons/equal_to.pass.cpp index 60415ec75d60..d4d99756fecc 100644 --- a/libcxx/test/std/utilities/function.objects/comparisons/equal_to.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/comparisons/equal_to.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "test_macros.h" + int main() { typedef std::equal_to F; @@ -24,7 +26,7 @@ int main() static_assert((std::is_same::value), "" ); assert(f(36, 36)); assert(!f(36, 6)); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 typedef std::equal_to<> F2; const F2 f2 = F2(); assert(f2(36, 36)); diff --git a/libcxx/test/std/utilities/function.objects/comparisons/greater.pass.cpp b/libcxx/test/std/utilities/function.objects/comparisons/greater.pass.cpp index 164f09aa605c..50bdcceee1c9 100644 --- a/libcxx/test/std/utilities/function.objects/comparisons/greater.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/comparisons/greater.pass.cpp @@ -15,6 +15,9 @@ #include #include +#include "test_macros.h" +#include "pointer_comparison_test_helper.hpp" + int main() { typedef std::greater F; @@ -25,7 +28,12 @@ int main() assert(!f(36, 36)); assert(f(36, 6)); assert(!f(6, 36)); -#if _LIBCPP_STD_VER > 11 + { + // test total ordering of int* for greater and + // greater. + do_pointer_comparison_test(); + } +#if TEST_STD_VER > 11 typedef std::greater<> F2; const F2 f2 = F2(); assert(!f2(36, 36)); diff --git a/libcxx/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp b/libcxx/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp index e89c14e24625..0aacb81e9cb4 100644 --- a/libcxx/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp @@ -15,6 +15,9 @@ #include #include +#include "test_macros.h" +#include "pointer_comparison_test_helper.hpp" + int main() { typedef std::greater_equal F; @@ -25,7 +28,12 @@ int main() assert(f(36, 36)); assert(f(36, 6)); assert(!f(6, 36)); -#if _LIBCPP_STD_VER > 11 + { + // test total ordering of int* for greater_equal and + // greater_equal. + do_pointer_comparison_test(); + } +#if TEST_STD_VER > 11 typedef std::greater_equal<> F2; const F2 f2 = F2(); assert(f2(36, 36)); diff --git a/libcxx/test/std/utilities/function.objects/comparisons/less.pass.cpp b/libcxx/test/std/utilities/function.objects/comparisons/less.pass.cpp index 74fe166a0cd9..191d58d6e544 100644 --- a/libcxx/test/std/utilities/function.objects/comparisons/less.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/comparisons/less.pass.cpp @@ -15,6 +15,9 @@ #include #include +#include "test_macros.h" +#include "pointer_comparison_test_helper.hpp" + int main() { typedef std::less F; @@ -25,7 +28,11 @@ int main() assert(!f(36, 36)); assert(!f(36, 6)); assert(f(6, 36)); -#if _LIBCPP_STD_VER > 11 + { + // test total ordering of int* for less and less. + do_pointer_comparison_test(); + } +#if TEST_STD_VER > 11 typedef std::less<> F2; const F2 f2 = F2(); assert(!f2(36, 36)); diff --git a/libcxx/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp b/libcxx/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp index e6ba1f7f8a21..a6aca5d19569 100644 --- a/libcxx/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp @@ -15,6 +15,9 @@ #include #include +#include "test_macros.h" +#include "pointer_comparison_test_helper.hpp" + int main() { typedef std::less_equal F; @@ -25,7 +28,12 @@ int main() assert(f(36, 36)); assert(!f(36, 6)); assert(f(6, 36)); -#if _LIBCPP_STD_VER > 11 + { + // test total ordering of int* for less_equal and + // less_equal. + do_pointer_comparison_test(); + } +#if TEST_STD_VER > 11 typedef std::less_equal<> F2; const F2 f2 = F2(); assert( f2(36, 36)); diff --git a/libcxx/test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp b/libcxx/test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp index 3e710b3e0c70..777c25d520a9 100644 --- a/libcxx/test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp +++ b/libcxx/test/std/utilities/function.objects/comparisons/not_equal_to.pass.cpp @@ -15,6 +15,8 @@ #include #include +#include "test_macros.h" + int main() { typedef std::not_equal_to F; @@ -24,7 +26,7 @@ int main() static_assert((std::is_same::value), "" ); assert(!f(36, 36)); assert(f(36, 6)); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 typedef std::not_equal_to<> F2; const F2 f2 = F2(); assert(!f2(36, 36)); diff --git a/libcxx/test/std/utilities/function.objects/comparisons/pointer_comparison_test_helper.hpp b/libcxx/test/std/utilities/function.objects/comparisons/pointer_comparison_test_helper.hpp new file mode 100644 index 000000000000..66d783a6e357 --- /dev/null +++ b/libcxx/test/std/utilities/function.objects/comparisons/pointer_comparison_test_helper.hpp @@ -0,0 +1,39 @@ +#ifndef POINTER_COMPARISON_TEST_HELPER_HPP +#define POINTER_COMPARISON_TEST_HELPER_HPP + +#include +#include +#include +#include + +#include "test_macros.h" + +template class CompareTemplate> +void do_pointer_comparison_test() { + typedef CompareTemplate Compare; + typedef CompareTemplate UIntCompare; +#if TEST_STD_VER > 11 + typedef CompareTemplate VoidCompare; +#else + typedef Compare VoidCompare; +#endif + std::vector > pointers; + const std::size_t test_size = 100; + for (int i=0; i < test_size; ++i) + pointers.push_back(std::shared_ptr(new T())); + Compare comp; + UIntCompare ucomp; + VoidCompare vcomp; + for (int i=0; i < test_size; ++i) { + for (int j=0; j < test_size; ++j) { + T* lhs = pointers[i].get(); + T* rhs = pointers[j].get(); + std::uintptr_t lhs_uint = reinterpret_cast(lhs); + std::uintptr_t rhs_uint = reinterpret_cast(rhs); + assert(comp(lhs, rhs) == ucomp(lhs_uint, rhs_uint)); + assert(vcomp(lhs, rhs) == ucomp(lhs_uint, rhs_uint)); + } + } +} + +#endif // POINTER_COMPARISON_TEST_HELPER_HPP diff --git a/libcxx/www/cxx1z_status.html b/libcxx/www/cxx1z_status.html index e0150a014f9c..4cf867082cb6 100644 --- a/libcxx/www/cxx1z_status.html +++ b/libcxx/www/cxx1z_status.html @@ -205,7 +205,7 @@ 2192Validity and return type of std::abs(0u) is unclearJacksonville 2276Missing requirement on std::promise::set_exceptionJacksonvilleComplete 2296std::addressof should be constexprJacksonvilleComplete (Clang Only) - 2450(greater|less|greater_equal|less_equal)<void> do not yield a total order for pointersJacksonville + 2450(greater|less|greater_equal|less_equal)<void> do not yield a total order for pointersJacksonvilleComplete 2520N4089 broke initializing unique_ptr<T[]> from a nullptrJacksonvilleComplete 2522[fund.ts.v2] Contradiction in set_default_resource specificationJacksonvilleComplete 2523std::promise synopsis shows two set_value_at_thread_exit()'s for no apparent reasonJacksonvilleComplete