Index: libcxx/trunk/test/std/input.output/filesystems/fs.enum/check_bitmask_types.h =================================================================== --- libcxx/trunk/test/std/input.output/filesystems/fs.enum/check_bitmask_types.h +++ libcxx/trunk/test/std/input.output/filesystems/fs.enum/check_bitmask_types.h @@ -0,0 +1,75 @@ +#ifndef TEST_BITMASK_TYPE_H +#define TEST_BITMASK_TYPE_H + +#include +#include + +#include "test_macros.h" + + +template ::type, + UT UVal1 = static_cast(Val1), + UT UVal2 = static_cast(Val2), + UT UZero = static_cast(0), + EnumType Zero = static_cast(0) + > +struct check_bitmask_type { + + static constexpr UT dcast(EnumType e) { return static_cast(e); } + static constexpr UT unpromote(decltype((~UZero)) promoted) { return static_cast(promoted); } + // We need two values that are non-zero and share at least one bit. + static_assert(Val1 != Zero && Val2 != Zero, ""); + static_assert(Val1 != Val2, ""); + static_assert((UVal1 & UVal2) == 0, ""); + + + static bool check() + { + { + EnumType ValRef = Val1; + ASSERT_SAME_TYPE(EnumType, decltype(Val1 & Val2)); + ASSERT_SAME_TYPE(EnumType, decltype(Val1 | Val2)); + ASSERT_SAME_TYPE(EnumType, decltype(Val1 ^ Val2)); + ASSERT_SAME_TYPE(EnumType, decltype((~Val1))); + ASSERT_SAME_TYPE(EnumType&, decltype(ValRef &= Val2)); + ASSERT_SAME_TYPE(EnumType&, decltype(ValRef |= Val2)); + ASSERT_SAME_TYPE(EnumType&, decltype(ValRef ^= Val2)); + } + + static_assert((Val1 & Zero) == Zero, ""); + static_assert((Val1 & Val1) == Val1, ""); + static_assert(dcast(Val1 & Val2) == (UVal1 & UVal2), ""); + + static_assert((Val1 | Zero) == Val1, ""); + static_assert(dcast(Val1 | Val2) == (UVal1 | UVal2), ""); + + static_assert((Val1 ^ Zero) == Val1, ""); + static_assert(dcast(Val1 ^ Val2) == (UVal1 ^ UVal2), ""); + + static_assert(dcast(~Zero) == unpromote(~UZero), ""); + static_assert(dcast(~Val1) == unpromote(~UVal1), ""); + + { + EnumType e = Val1; + EnumType& eref = (e &= Val2); + assert(&eref == &e); + assert(dcast(eref) == (UVal1 & UVal2)); + } + { + EnumType e = Val1; + EnumType& eref = (e |= Val2); + assert(&eref == &e); + assert(dcast(eref) == (UVal1 | UVal2)); + } + { + EnumType e = Val1; + EnumType& eref = (e ^= Val2); + assert(&eref == &e); + assert(dcast(eref) == (UVal1 ^ UVal2)); + } + return true; + } +}; + +#endif // TEST_BITMASK_TYPE Index: libcxx/trunk/test/std/input.output/filesystems/fs.enum/check_bitmask_types.hpp =================================================================== --- libcxx/trunk/test/std/input.output/filesystems/fs.enum/check_bitmask_types.hpp +++ libcxx/trunk/test/std/input.output/filesystems/fs.enum/check_bitmask_types.hpp @@ -1,75 +0,0 @@ -#ifndef TEST_BITMASK_TYPE_HPP -#define TEST_BITMASK_TYPE_HPP - -#include -#include - -#include "test_macros.h" - - -template ::type, - UT UVal1 = static_cast(Val1), - UT UVal2 = static_cast(Val2), - UT UZero = static_cast(0), - EnumType Zero = static_cast(0) - > -struct check_bitmask_type { - - static constexpr UT dcast(EnumType e) { return static_cast(e); } - static constexpr UT unpromote(decltype((~UZero)) promoted) { return static_cast(promoted); } - // We need two values that are non-zero and share at least one bit. - static_assert(Val1 != Zero && Val2 != Zero, ""); - static_assert(Val1 != Val2, ""); - static_assert((UVal1 & UVal2) == 0, ""); - - - static bool check() - { - { - EnumType ValRef = Val1; - ASSERT_SAME_TYPE(EnumType, decltype(Val1 & Val2)); - ASSERT_SAME_TYPE(EnumType, decltype(Val1 | Val2)); - ASSERT_SAME_TYPE(EnumType, decltype(Val1 ^ Val2)); - ASSERT_SAME_TYPE(EnumType, decltype((~Val1))); - ASSERT_SAME_TYPE(EnumType&, decltype(ValRef &= Val2)); - ASSERT_SAME_TYPE(EnumType&, decltype(ValRef |= Val2)); - ASSERT_SAME_TYPE(EnumType&, decltype(ValRef ^= Val2)); - } - - static_assert((Val1 & Zero) == Zero, ""); - static_assert((Val1 & Val1) == Val1, ""); - static_assert(dcast(Val1 & Val2) == (UVal1 & UVal2), ""); - - static_assert((Val1 | Zero) == Val1, ""); - static_assert(dcast(Val1 | Val2) == (UVal1 | UVal2), ""); - - static_assert((Val1 ^ Zero) == Val1, ""); - static_assert(dcast(Val1 ^ Val2) == (UVal1 ^ UVal2), ""); - - static_assert(dcast(~Zero) == unpromote(~UZero), ""); - static_assert(dcast(~Val1) == unpromote(~UVal1), ""); - - { - EnumType e = Val1; - EnumType& eref = (e &= Val2); - assert(&eref == &e); - assert(dcast(eref) == (UVal1 & UVal2)); - } - { - EnumType e = Val1; - EnumType& eref = (e |= Val2); - assert(&eref == &e); - assert(dcast(eref) == (UVal1 | UVal2)); - } - { - EnumType e = Val1; - EnumType& eref = (e ^= Val2); - assert(&eref == &e); - assert(dcast(eref) == (UVal1 ^ UVal2)); - } - return true; - } -}; - -#endif // TEST_BITMASK_TYPE Index: libcxx/trunk/test/std/input.output/filesystems/fs.enum/enum.copy_options.pass.cpp =================================================================== --- libcxx/trunk/test/std/input.output/filesystems/fs.enum/enum.copy_options.pass.cpp +++ libcxx/trunk/test/std/input.output/filesystems/fs.enum/enum.copy_options.pass.cpp @@ -16,7 +16,7 @@ #include #include -#include "check_bitmask_types.hpp" +#include "check_bitmask_types.h" #include "test_macros.h" Index: libcxx/trunk/test/std/input.output/filesystems/fs.enum/enum.directory_options.pass.cpp =================================================================== --- libcxx/trunk/test/std/input.output/filesystems/fs.enum/enum.directory_options.pass.cpp +++ libcxx/trunk/test/std/input.output/filesystems/fs.enum/enum.directory_options.pass.cpp @@ -18,7 +18,7 @@ #include #include "test_macros.h" -#include "check_bitmask_types.hpp" +#include "check_bitmask_types.h" constexpr fs::directory_options ME(int val) { return static_cast(val); } Index: libcxx/trunk/test/std/input.output/filesystems/fs.enum/enum.perm_options.pass.cpp =================================================================== --- libcxx/trunk/test/std/input.output/filesystems/fs.enum/enum.perm_options.pass.cpp +++ libcxx/trunk/test/std/input.output/filesystems/fs.enum/enum.perm_options.pass.cpp @@ -18,7 +18,7 @@ #include #include "test_macros.h" -#include "check_bitmask_types.hpp" +#include "check_bitmask_types.h" constexpr fs::perm_options ME(int val) { Index: libcxx/trunk/test/std/input.output/filesystems/fs.enum/enum.perms.pass.cpp =================================================================== --- libcxx/trunk/test/std/input.output/filesystems/fs.enum/enum.perms.pass.cpp +++ libcxx/trunk/test/std/input.output/filesystems/fs.enum/enum.perms.pass.cpp @@ -18,7 +18,7 @@ #include #include "test_macros.h" -#include "check_bitmask_types.hpp" +#include "check_bitmask_types.h" constexpr fs::perms ME(int val) { return static_cast(val); } Index: libcxx/trunk/test/std/utilities/function.objects/comparisons/greater.pass.cpp =================================================================== --- libcxx/trunk/test/std/utilities/function.objects/comparisons/greater.pass.cpp +++ libcxx/trunk/test/std/utilities/function.objects/comparisons/greater.pass.cpp @@ -15,7 +15,7 @@ #include #include "test_macros.h" -#include "pointer_comparison_test_helper.hpp" +#include "pointer_comparison_test_helper.h" int main(int, char**) { Index: libcxx/trunk/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp =================================================================== --- libcxx/trunk/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp +++ libcxx/trunk/test/std/utilities/function.objects/comparisons/greater_equal.pass.cpp @@ -15,7 +15,7 @@ #include #include "test_macros.h" -#include "pointer_comparison_test_helper.hpp" +#include "pointer_comparison_test_helper.h" int main(int, char**) { Index: libcxx/trunk/test/std/utilities/function.objects/comparisons/less.pass.cpp =================================================================== --- libcxx/trunk/test/std/utilities/function.objects/comparisons/less.pass.cpp +++ libcxx/trunk/test/std/utilities/function.objects/comparisons/less.pass.cpp @@ -15,7 +15,7 @@ #include #include "test_macros.h" -#include "pointer_comparison_test_helper.hpp" +#include "pointer_comparison_test_helper.h" int main(int, char**) { Index: libcxx/trunk/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp =================================================================== --- libcxx/trunk/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp +++ libcxx/trunk/test/std/utilities/function.objects/comparisons/less_equal.pass.cpp @@ -15,7 +15,7 @@ #include #include "test_macros.h" -#include "pointer_comparison_test_helper.hpp" +#include "pointer_comparison_test_helper.h" int main(int, char**) { Index: libcxx/trunk/test/std/utilities/function.objects/comparisons/pointer_comparison_test_helper.h =================================================================== --- libcxx/trunk/test/std/utilities/function.objects/comparisons/pointer_comparison_test_helper.h +++ libcxx/trunk/test/std/utilities/function.objects/comparisons/pointer_comparison_test_helper.h @@ -0,0 +1,39 @@ +#ifndef POINTER_COMPARISON_TEST_HELPER_H +#define POINTER_COMPARISON_TEST_HELPER_H + +#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 (size_t i=0; i < test_size; ++i) + pointers.push_back(std::shared_ptr(new T())); + Compare comp; + UIntCompare ucomp; + VoidCompare vcomp; + for (size_t i=0; i < test_size; ++i) { + for (size_t 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_H Index: libcxx/trunk/test/std/utilities/function.objects/comparisons/pointer_comparison_test_helper.hpp =================================================================== --- libcxx/trunk/test/std/utilities/function.objects/comparisons/pointer_comparison_test_helper.hpp +++ libcxx/trunk/test/std/utilities/function.objects/comparisons/pointer_comparison_test_helper.hpp @@ -1,39 +0,0 @@ -#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 (size_t i=0; i < test_size; ++i) - pointers.push_back(std::shared_ptr(new T())); - Compare comp; - UIntCompare ucomp; - VoidCompare vcomp; - for (size_t i=0; i < test_size; ++i) { - for (size_t 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