[libcxx-commits] [libcxx] [libc++][NFC] Avoid opening namespace std in the tests (PR #94160)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Aug 1 01:17:45 PDT 2024
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/94160
>From 8dd7ee65965a754327556f619cd0c4c2f38ab18d Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Sun, 2 Jun 2024 15:36:09 +0200
Subject: [PATCH] [libc++][NFC] Avoid opening namespace std in the tests
---
.../libcxx/utilities/any/allocator.pass.cpp | 101 ++---
.../format/enable_insertable.compile.pass.cpp | 24 +-
.../common_with.compile.pass.cpp | 409 ++++++++----------
.../common_reference.compile.pass.cpp | 30 +-
libcxx/test/std/containers/Emplaceable.h | 13 +-
libcxx/test/std/containers/NotConstructible.h | 14 +-
.../container.node/node_handle.pass.cpp | 15 +-
.../unord/unord.map/compare.pass.cpp | 12 +-
.../insert_or_assign.pass.cpp | 9 +-
.../unord.map.modifiers/try.emplace.pass.cpp | 9 +-
.../syserr/is_error_code_enum.pass.cpp | 8 +-
.../syserr/is_error_condition_enum.pass.cpp | 8 +-
.../ErrorCodeEnum.pass.cpp | 8 +-
.../lwg3629.pass.cpp | 6 +-
.../ErrorCodeEnum.pass.cpp | 8 +-
.../syserr.errcode.modifiers/lwg3629.pass.cpp | 6 +-
.../lwg3629.pass.cpp | 6 +-
.../lwg3629.pass.cpp | 6 +-
.../propagate_const.nonmembers/hash.pass.cpp | 7 +-
.../indirectly_readable.compile.pass.cpp | 28 +-
.../user_defined_char_type.pass.cpp | 13 +-
.../range.subrange/ctor.range_size.pass.cpp | 6 +-
.../string_append/push_back.pass.cpp | 4 +-
libcxx/test/std/time/rep.h | 8 +-
.../difference_type.pass.cpp | 14 +-
.../allocator.traits.types/size_type.pass.cpp | 10 +-
.../common_reference.compile.pass.cpp | 10 +-
.../meta.trans.other/common_type.pass.cpp | 39 +-
.../optional/optional.hash/hash.pass.cpp | 6 +-
.../tuple_size_incomplete.pass.cpp | 5 +-
.../pairs/pairs.pair/ctor.pair_like.pass.cpp | 8 +-
.../variant/variant.hash/hash.pass.cpp | 11 +-
.../variant.visit.member/visit.pass.cpp | 1 +
.../variant/variant.visit/visit.pass.cpp | 1 +
libcxx/test/support/Counter.h | 12 +-
35 files changed, 364 insertions(+), 511 deletions(-)
diff --git a/libcxx/test/libcxx/utilities/any/allocator.pass.cpp b/libcxx/test/libcxx/utilities/any/allocator.pass.cpp
index daaf74a2783fd..ab0d52aea9149 100644
--- a/libcxx/test/libcxx/utilities/any/allocator.pass.cpp
+++ b/libcxx/test/libcxx/utilities/any/allocator.pass.cpp
@@ -39,61 +39,62 @@ bool Large_was_deallocated = false;
bool Small_was_constructed = false;
bool Small_was_destroyed = false;
-namespace std {
- template <>
- struct allocator<Large> {
- using value_type = Large;
- using size_type = std::size_t;
- using difference_type = std::ptrdiff_t;
- using propagate_on_container_move_assignment = std::true_type;
- using is_always_equal = std::true_type;
-
- Large* allocate(std::size_t n) {
- Large_was_allocated = true;
- return static_cast<Large*>(::operator new(n * sizeof(Large)));
- }
+template <>
+struct std::allocator<Large> {
+ using value_type = Large;
+ using size_type = std::size_t;
+ using difference_type = std::ptrdiff_t;
+ using propagate_on_container_move_assignment = std::true_type;
+ using is_always_equal = std::true_type;
+
+ Large* allocate(std::size_t n) {
+ Large_was_allocated = true;
+ return static_cast<Large*>(::operator new(n * sizeof(Large)));
+ }
- template <typename ...Args>
- void construct(Large* p, Args&& ...args) {
- new (p) Large(std::forward<Args>(args)...);
- Large_was_constructed = true;
- }
+ template <typename... Args>
+ void construct(Large* p, Args&&... args) {
+ new (p) Large(std::forward<Args>(args)...);
+ Large_was_constructed = true;
+ }
- void destroy(Large* p) {
- p->~Large();
- Large_was_destroyed = true;
- }
+ void destroy(Large* p) {
+ p->~Large();
+ Large_was_destroyed = true;
+ }
- void deallocate(Large* p, std::size_t) {
- Large_was_deallocated = true;
- return ::operator delete(p);
- }
- };
-
- template <>
- struct allocator<Small> {
- using value_type = Small;
- using size_type = std::size_t;
- using difference_type = std::ptrdiff_t;
- using propagate_on_container_move_assignment = std::true_type;
- using is_always_equal = std::true_type;
-
- Small* allocate(std::size_t) { assert(false); return nullptr; }
-
- template <typename ...Args>
- void construct(Small* p, Args&& ...args) {
- new (p) Small(std::forward<Args>(args)...);
- Small_was_constructed = true;
- }
+ void deallocate(Large* p, std::size_t) {
+ Large_was_deallocated = true;
+ return ::operator delete(p);
+ }
+};
+
+template <>
+struct std::allocator<Small> {
+ using value_type = Small;
+ using size_type = std::size_t;
+ using difference_type = std::ptrdiff_t;
+ using propagate_on_container_move_assignment = std::true_type;
+ using is_always_equal = std::true_type;
+
+ Small* allocate(std::size_t) {
+ assert(false);
+ return nullptr;
+ }
- void destroy(Small* p) {
- p->~Small();
- Small_was_destroyed = true;
- }
+ template <typename... Args>
+ void construct(Small* p, Args&&... args) {
+ new (p) Small(std::forward<Args>(args)...);
+ Small_was_constructed = true;
+ }
+
+ void destroy(Small* p) {
+ p->~Small();
+ Small_was_destroyed = true;
+ }
- void deallocate(Small*, std::size_t) { assert(false); }
- };
-} // end namespace std
+ void deallocate(Small*, std::size_t) { assert(false); }
+};
int main(int, char**) {
diff --git a/libcxx/test/libcxx/utilities/format/enable_insertable.compile.pass.cpp b/libcxx/test/libcxx/utilities/format/enable_insertable.compile.pass.cpp
index 5c100322fbcf3..9790aeff189e7 100644
--- a/libcxx/test/libcxx/utilities/format/enable_insertable.compile.pass.cpp
+++ b/libcxx/test/libcxx/utilities/format/enable_insertable.compile.pass.cpp
@@ -61,26 +61,24 @@ struct valid {
void insert(iterator, CharT*, CharT*);
};
-namespace std::__format {
template <>
-inline constexpr bool __enable_insertable<no_value_type<char>> = true;
+inline constexpr bool std::__format::__enable_insertable<no_value_type<char>> = true;
template <>
-inline constexpr bool __enable_insertable<no_end<char>> = true;
+inline constexpr bool std::__format::__enable_insertable<no_end<char>> = true;
template <>
-inline constexpr bool __enable_insertable<no_insert<char>> = true;
+inline constexpr bool std::__format::__enable_insertable<no_insert<char>> = true;
template <>
-inline constexpr bool __enable_insertable<valid<char>> = true;
+inline constexpr bool std::__format::__enable_insertable<valid<char>> = true;
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
template <>
-inline constexpr bool __enable_insertable<no_value_type<wchar_t>> = true;
+inline constexpr bool std::__format::__enable_insertable<no_value_type<wchar_t>> = true;
template <>
-inline constexpr bool __enable_insertable<no_end<wchar_t>> = true;
+inline constexpr bool std::__format::__enable_insertable<no_end<wchar_t>> = true;
template <>
-inline constexpr bool __enable_insertable<no_insert<wchar_t>> = true;
+inline constexpr bool std::__format::__enable_insertable<no_insert<wchar_t>> = true;
template <>
-inline constexpr bool __enable_insertable<valid<wchar_t>> = true;
+inline constexpr bool std::__format::__enable_insertable<valid<wchar_t>> = true;
#endif
-} // namespace std::__format
static_assert(!std::__format::__insertable<no_value_type<char>>);
static_assert(!std::__format::__insertable<no_end<char>>);
@@ -95,12 +93,10 @@ static_assert(!std::__format::__insertable<no_specialization<wchar_t>>);
static_assert(std::__format::__insertable<valid<wchar_t>>);
#endif
-namespace std::__format {
template <>
-inline constexpr bool __enable_insertable<valid<signed char>> = true;
+inline constexpr bool std::__format::__enable_insertable<valid<signed char>> = true;
template <>
-inline constexpr bool __enable_insertable<valid<unsigned char>> = true;
-} // namespace std::__format
+inline constexpr bool std::__format::__enable_insertable<valid<unsigned char>> = true;
static_assert(!std::__format::__insertable<valid<signed char>>);
static_assert(!std::__format::__insertable<valid<unsigned char>>);
diff --git a/libcxx/test/std/concepts/concepts.lang/concept.common/common_with.compile.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concept.common/common_with.compile.pass.cpp
index 5d80c1cba2655..d72df6dbb3ca9 100644
--- a/libcxx/test/std/concepts/concepts.lang/concept.common/common_with.compile.pass.cpp
+++ b/libcxx/test/std/concepts/concepts.lang/concept.common/common_with.compile.pass.cpp
@@ -262,17 +262,16 @@ struct BadBasicCommonType {
// should be placed so the test doesn't get deleted.
};
-namespace std {
template <>
-struct common_type<BadBasicCommonType, int> {
+struct std::common_type<BadBasicCommonType, int> {
using type = BadBasicCommonType;
};
template <>
-struct common_type<int, BadBasicCommonType> {
+struct std::common_type<int, BadBasicCommonType> {
using type = int;
};
-} // namespace std
+
static_assert(requires {
typename std::common_type_t<BadBasicCommonType, int>;
});
@@ -289,17 +288,16 @@ static_assert(!std::convertible_to<DullCommonType, int>);
struct T1 {};
static_assert(!std::convertible_to<DullCommonType, T1>);
-namespace std {
template <>
-struct common_type<T1, int> {
+struct std::common_type<T1, int> {
using type = DullCommonType;
};
template <>
-struct common_type<int, T1> {
+struct std::common_type<int, T1> {
using type = DullCommonType;
};
-} // namespace std
+
static_assert(HasValidCommonType<T1, int>());
static_assert(!CheckCommonWith<T1, int>());
@@ -314,17 +312,16 @@ struct T2 {};
static_assert(
!std::convertible_to<CommonTypeImplicitlyConstructibleFromInt, T2>);
-namespace std {
template <>
-struct common_type<T2, int> {
+struct std::common_type<T2, int> {
using type = CommonTypeImplicitlyConstructibleFromInt;
};
template <>
-struct common_type<int, T2> {
+struct std::common_type<int, T2> {
using type = CommonTypeImplicitlyConstructibleFromInt;
};
-} // namespace std
+
static_assert(HasValidCommonType<T2, int>());
static_assert(!CheckCommonWith<T2, int>());
@@ -339,17 +336,16 @@ struct T3 {};
static_assert(
!std::convertible_to<CommonTypeExplicitlyConstructibleFromInt, T2>);
-namespace std {
template <>
-struct common_type<T3, int> {
+struct std::common_type<T3, int> {
using type = CommonTypeExplicitlyConstructibleFromInt;
};
template <>
-struct common_type<int, T3> {
+struct std::common_type<int, T3> {
using type = CommonTypeExplicitlyConstructibleFromInt;
};
-} // namespace std
+
static_assert(HasValidCommonType<T3, int>());
static_assert(!CheckCommonWith<T3, int>());
@@ -361,17 +357,16 @@ static_assert(requires(T4 t4) {
static_cast<CommonTypeImplicitlyConstructibleFromT4>(t4);
});
-namespace std {
template <>
-struct common_type<T4, int> {
+struct std::common_type<T4, int> {
using type = CommonTypeImplicitlyConstructibleFromT4;
};
template <>
-struct common_type<int, T4> {
+struct std::common_type<int, T4> {
using type = CommonTypeImplicitlyConstructibleFromT4;
};
-} // namespace std
+
static_assert(HasValidCommonType<T4, int>());
static_assert(!CheckCommonWith<T4, int>());
@@ -383,17 +378,16 @@ static_assert(requires(T5 t5) {
static_cast<CommonTypeExplicitlyConstructibleFromT5>(t5);
});
-namespace std {
template <>
-struct common_type<T5, int> {
+struct std::common_type<T5, int> {
using type = CommonTypeExplicitlyConstructibleFromT5;
};
template <>
-struct common_type<int, T5> {
+struct std::common_type<int, T5> {
using type = CommonTypeExplicitlyConstructibleFromT5;
};
-} // namespace std
+
static_assert(HasValidCommonType<T5, int>());
static_assert(!CheckCommonWith<T5, int>());
@@ -403,113 +397,111 @@ struct CommonTypeNoCommonReference {
CommonTypeNoCommonReference(int);
};
-namespace std {
template <>
-struct common_type<T6, int> {
+struct std::common_type<T6, int> {
using type = CommonTypeNoCommonReference;
};
template <>
-struct common_type<int, T6> {
+struct std::common_type<int, T6> {
using type = CommonTypeNoCommonReference;
};
template <>
-struct common_type<T6&, int&> {};
+struct std::common_type<T6&, int&> {};
template <>
-struct common_type<int&, T6&> {};
+struct std::common_type<int&, T6&> {};
template <>
-struct common_type<T6&, const int&> {};
+struct std::common_type<T6&, const int&> {};
template <>
-struct common_type<int&, const T6&> {};
+struct std::common_type<int&, const T6&> {};
template <>
-struct common_type<T6&, volatile int&> {};
+struct std::common_type<T6&, volatile int&> {};
template <>
-struct common_type<int&, volatile T6&> {};
+struct std::common_type<int&, volatile T6&> {};
template <>
-struct common_type<T6&, const volatile int&> {};
+struct std::common_type<T6&, const volatile int&> {};
template <>
-struct common_type<int&, const volatile T6&> {};
+struct std::common_type<int&, const volatile T6&> {};
template <>
-struct common_type<const T6&, int&> {};
+struct std::common_type<const T6&, int&> {};
template <>
-struct common_type<const int&, T6&> {};
+struct std::common_type<const int&, T6&> {};
template <>
-struct common_type<const T6&, const int&> {};
+struct std::common_type<const T6&, const int&> {};
template <>
-struct common_type<const int&, const T6&> {};
+struct std::common_type<const int&, const T6&> {};
template <>
-struct common_type<const T6&, volatile int&> {};
+struct std::common_type<const T6&, volatile int&> {};
template <>
-struct common_type<const int&, volatile T6&> {};
+struct std::common_type<const int&, volatile T6&> {};
template <>
-struct common_type<const T6&, const volatile int&> {};
+struct std::common_type<const T6&, const volatile int&> {};
template <>
-struct common_type<const int&, const volatile T6&> {};
+struct std::common_type<const int&, const volatile T6&> {};
template <>
-struct common_type<volatile T6&, int&> {};
+struct std::common_type<volatile T6&, int&> {};
template <>
-struct common_type<volatile int&, T6&> {};
+struct std::common_type<volatile int&, T6&> {};
template <>
-struct common_type<volatile T6&, const int&> {};
+struct std::common_type<volatile T6&, const int&> {};
template <>
-struct common_type<volatile int&, const T6&> {};
+struct std::common_type<volatile int&, const T6&> {};
template <>
-struct common_type<volatile T6&, volatile int&> {};
+struct std::common_type<volatile T6&, volatile int&> {};
template <>
-struct common_type<volatile int&, volatile T6&> {};
+struct std::common_type<volatile int&, volatile T6&> {};
template <>
-struct common_type<volatile T6&, const volatile int&> {};
+struct std::common_type<volatile T6&, const volatile int&> {};
template <>
-struct common_type<volatile int&, const volatile T6&> {};
+struct std::common_type<volatile int&, const volatile T6&> {};
template <>
-struct common_type<const volatile T6&, int&> {};
+struct std::common_type<const volatile T6&, int&> {};
template <>
-struct common_type<const volatile int&, T6&> {};
+struct std::common_type<const volatile int&, T6&> {};
template <>
-struct common_type<const volatile T6&, const int&> {};
+struct std::common_type<const volatile T6&, const int&> {};
template <>
-struct common_type<const volatile int&, const T6&> {};
+struct std::common_type<const volatile int&, const T6&> {};
template <>
-struct common_type<const volatile T6&, volatile int&> {};
+struct std::common_type<const volatile T6&, volatile int&> {};
template <>
-struct common_type<const volatile int&, volatile T6&> {};
+struct std::common_type<const volatile int&, volatile T6&> {};
template <>
-struct common_type<const volatile T6&, const volatile int&> {};
+struct std::common_type<const volatile T6&, const volatile int&> {};
template <>
-struct common_type<const volatile int&, const volatile T6&> {};
-} // namespace std
+struct std::common_type<const volatile int&, const volatile T6&> {};
template <typename T, typename U>
constexpr bool HasCommonReference() noexcept {
@@ -526,177 +518,176 @@ struct CommonTypeNoMetaCommonReference {
CommonTypeNoMetaCommonReference(int);
};
-namespace std {
template <>
-struct common_type<T7, int> {
+struct std::common_type<T7, int> {
using type = CommonTypeNoMetaCommonReference;
};
template <>
-struct common_type<int, T7> {
+struct std::common_type<int, T7> {
using type = CommonTypeNoMetaCommonReference;
};
template <>
-struct common_type<T7&, int&> {
+struct std::common_type<T7&, int&> {
using type = void;
};
template <>
-struct common_type<int&, T7&> {
+struct std::common_type<int&, T7&> {
using type = void;
};
template <>
-struct common_type<T7&, const int&> {
+struct std::common_type<T7&, const int&> {
using type = void;
};
template <>
-struct common_type<int&, const T7&> {
+struct std::common_type<int&, const T7&> {
using type = void;
};
template <>
-struct common_type<T7&, volatile int&> {
+struct std::common_type<T7&, volatile int&> {
using type = void;
};
template <>
-struct common_type<int&, volatile T7&> {
+struct std::common_type<int&, volatile T7&> {
using type = void;
};
template <>
-struct common_type<T7&, const volatile int&> {
+struct std::common_type<T7&, const volatile int&> {
using type = void;
};
template <>
-struct common_type<int&, const volatile T7&> {
+struct std::common_type<int&, const volatile T7&> {
using type = void;
};
template <>
-struct common_type<const T7&, int&> {
+struct std::common_type<const T7&, int&> {
using type = void;
};
template <>
-struct common_type<const int&, T7&> {
+struct std::common_type<const int&, T7&> {
using type = void;
};
template <>
-struct common_type<const T7&, const int&> {
+struct std::common_type<const T7&, const int&> {
using type = void;
};
template <>
-struct common_type<const int&, const T7&> {
+struct std::common_type<const int&, const T7&> {
using type = void;
};
template <>
-struct common_type<const T7&, volatile int&> {
+struct std::common_type<const T7&, volatile int&> {
using type = void;
};
template <>
-struct common_type<const int&, volatile T7&> {
+struct std::common_type<const int&, volatile T7&> {
using type = void;
};
template <>
-struct common_type<const T7&, const volatile int&> {
+struct std::common_type<const T7&, const volatile int&> {
using type = void;
};
template <>
-struct common_type<const int&, const volatile T7&> {
+struct std::common_type<const int&, const volatile T7&> {
using type = void;
};
template <>
-struct common_type<volatile T7&, int&> {
+struct std::common_type<volatile T7&, int&> {
using type = void;
};
template <>
-struct common_type<volatile int&, T7&> {
+struct std::common_type<volatile int&, T7&> {
using type = void;
};
template <>
-struct common_type<volatile T7&, const int&> {
+struct std::common_type<volatile T7&, const int&> {
using type = void;
};
template <>
-struct common_type<volatile int&, const T7&> {
+struct std::common_type<volatile int&, const T7&> {
using type = void;
};
template <>
-struct common_type<volatile T7&, volatile int&> {
+struct std::common_type<volatile T7&, volatile int&> {
using type = void;
};
template <>
-struct common_type<volatile int&, volatile T7&> {
+struct std::common_type<volatile int&, volatile T7&> {
using type = void;
};
template <>
-struct common_type<volatile T7&, const volatile int&> {
+struct std::common_type<volatile T7&, const volatile int&> {
using type = void;
};
template <>
-struct common_type<volatile int&, const volatile T7&> {
+struct std::common_type<volatile int&, const volatile T7&> {
using type = void;
};
template <>
-struct common_type<const volatile T7&, int&> {
+struct std::common_type<const volatile T7&, int&> {
using type = void;
};
template <>
-struct common_type<const volatile int&, T7&> {
+struct std::common_type<const volatile int&, T7&> {
using type = void;
};
template <>
-struct common_type<const volatile T7&, const int&> {
+struct std::common_type<const volatile T7&, const int&> {
using type = void;
};
template <>
-struct common_type<const volatile int&, const T7&> {
+struct std::common_type<const volatile int&, const T7&> {
using type = void;
};
template <>
-struct common_type<const volatile T7&, volatile int&> {
+struct std::common_type<const volatile T7&, volatile int&> {
using type = void;
};
template <>
-struct common_type<const volatile int&, volatile T7&> {
+struct std::common_type<const volatile int&, volatile T7&> {
using type = void;
};
template <>
-struct common_type<const volatile T7&, const volatile int&> {
+struct std::common_type<const volatile T7&, const volatile int&> {
using type = void;
};
template <>
-struct common_type<const volatile int&, const volatile T7&> {
+struct std::common_type<const volatile int&, const volatile T7&> {
using type = void;
};
-} // namespace std
+
static_assert(HasValidCommonType<T7, int>());
static_assert(HasValidCommonType<const T7&, const int&>());
static_assert(HasCommonReference<const T7&, const int&>());
@@ -709,284 +700,242 @@ struct CommonWithInt {
operator int() const volatile;
};
-namespace std {
template <>
-struct common_type<CommonWithInt, int> {
+struct std::common_type<CommonWithInt, int> {
using type = int;
};
template <>
-struct common_type<int, CommonWithInt> : common_type<CommonWithInt, int> {};
+struct std::common_type<int, CommonWithInt> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<CommonWithInt&, int&> : common_type<CommonWithInt, int> {};
+struct std::common_type<CommonWithInt&, int&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<int&, CommonWithInt&> : common_type<CommonWithInt, int> {};
+struct std::common_type<int&, CommonWithInt&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<CommonWithInt&, const int&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<CommonWithInt&, const int&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<int&, const CommonWithInt&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<int&, const CommonWithInt&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<CommonWithInt&, volatile int&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<CommonWithInt&, volatile int&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<int&, volatile CommonWithInt&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<int&, volatile CommonWithInt&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<CommonWithInt&, const volatile int&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<CommonWithInt&, const volatile int&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<int&, const volatile CommonWithInt&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<int&, const volatile CommonWithInt&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<const CommonWithInt&, int&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<const CommonWithInt&, int&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<const int&, CommonWithInt&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<const int&, CommonWithInt&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<const CommonWithInt&, const int&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<const CommonWithInt&, const int&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<const int&, const CommonWithInt&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<const int&, const CommonWithInt&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<const CommonWithInt&, volatile int&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<const CommonWithInt&, volatile int&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<const int&, volatile CommonWithInt&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<const int&, volatile CommonWithInt&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<const CommonWithInt&, const volatile int&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<const CommonWithInt&, const volatile int&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<const int&, const volatile CommonWithInt&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<const int&, const volatile CommonWithInt&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<volatile CommonWithInt&, int&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<volatile CommonWithInt&, int&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<volatile int&, CommonWithInt&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<volatile int&, CommonWithInt&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<volatile CommonWithInt&, const int&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<volatile CommonWithInt&, const int&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<volatile int&, const CommonWithInt&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<volatile int&, const CommonWithInt&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<volatile CommonWithInt&, volatile int&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<volatile CommonWithInt&, volatile int&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<volatile int&, volatile CommonWithInt&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<volatile int&, volatile CommonWithInt&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<volatile CommonWithInt&, const volatile int&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<volatile CommonWithInt&, const volatile int&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<volatile int&, const volatile CommonWithInt&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<volatile int&, const volatile CommonWithInt&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<const volatile CommonWithInt&, int&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<const volatile CommonWithInt&, int&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<const volatile int&, CommonWithInt&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<const volatile int&, CommonWithInt&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<const volatile CommonWithInt&, const int&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<const volatile CommonWithInt&, const int&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<const volatile int&, const CommonWithInt&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<const volatile int&, const CommonWithInt&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<const volatile CommonWithInt&, volatile int&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<const volatile CommonWithInt&, volatile int&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<const volatile int&, volatile CommonWithInt&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<const volatile int&, volatile CommonWithInt&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<const volatile CommonWithInt&, const volatile int&>
- : common_type<CommonWithInt, int> {};
+struct std::common_type<const volatile CommonWithInt&, const volatile int&> : std::common_type<CommonWithInt, int> {};
template <>
-struct common_type<const volatile int&, const volatile CommonWithInt&>
- : common_type<CommonWithInt, int> {};
-} // namespace std
+struct std::common_type<const volatile int&, const volatile CommonWithInt&> : std::common_type<CommonWithInt, int> {};
+
static_assert(CheckCommonWith<CommonWithInt, int>());
struct CommonWithIntButRefLong {
operator int() const volatile;
};
-namespace std {
template <>
-struct common_type<CommonWithIntButRefLong, int> {
+struct std::common_type<CommonWithIntButRefLong, int> {
using type = int;
};
template <>
-struct common_type<int, CommonWithIntButRefLong>
- : common_type<CommonWithIntButRefLong, int> {};
+struct std::common_type<int, CommonWithIntButRefLong> : std::common_type<CommonWithIntButRefLong, int> {};
template <>
-struct common_type<CommonWithIntButRefLong&, int&> {
+struct std::common_type<CommonWithIntButRefLong&, int&> {
using type = long;
};
template <>
-struct common_type<int&, CommonWithIntButRefLong&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<int&, CommonWithIntButRefLong&> : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<CommonWithIntButRefLong&, const int&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<CommonWithIntButRefLong&, const int&> : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<int&, const CommonWithIntButRefLong&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<int&, const CommonWithIntButRefLong&> : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<CommonWithIntButRefLong&, volatile int&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<CommonWithIntButRefLong&, volatile int&> : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<int&, volatile CommonWithIntButRefLong&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<int&, volatile CommonWithIntButRefLong&> : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<CommonWithIntButRefLong&, const volatile int&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<CommonWithIntButRefLong&, const volatile int&>
+ : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<int&, const volatile CommonWithIntButRefLong&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<int&, const volatile CommonWithIntButRefLong&>
+ : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<const CommonWithIntButRefLong&, int&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<const CommonWithIntButRefLong&, int&> : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<const int&, CommonWithIntButRefLong&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<const int&, CommonWithIntButRefLong&> : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<const CommonWithIntButRefLong&, const int&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<const CommonWithIntButRefLong&, const int&> : std::common_type<CommonWithIntButRefLong&, int&> {
+};
template <>
-struct common_type<const int&, const CommonWithIntButRefLong&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<const int&, const CommonWithIntButRefLong&> : std::common_type<CommonWithIntButRefLong&, int&> {
+};
template <>
-struct common_type<const CommonWithIntButRefLong&, volatile int&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<const CommonWithIntButRefLong&, volatile int&>
+ : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<const int&, volatile CommonWithIntButRefLong&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<const int&, volatile CommonWithIntButRefLong&>
+ : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<const CommonWithIntButRefLong&, const volatile int&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<const CommonWithIntButRefLong&, const volatile int&>
+ : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<const int&, const volatile CommonWithIntButRefLong&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<const int&, const volatile CommonWithIntButRefLong&>
+ : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<volatile CommonWithIntButRefLong&, int&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<volatile CommonWithIntButRefLong&, int&> : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<volatile int&, CommonWithIntButRefLong&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<volatile int&, CommonWithIntButRefLong&> : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<volatile CommonWithIntButRefLong&, const int&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<volatile CommonWithIntButRefLong&, const int&>
+ : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<volatile int&, const CommonWithIntButRefLong&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<volatile int&, const CommonWithIntButRefLong&>
+ : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<volatile CommonWithIntButRefLong&, volatile int&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<volatile CommonWithIntButRefLong&, volatile int&>
+ : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<volatile int&, volatile CommonWithIntButRefLong&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<volatile int&, volatile CommonWithIntButRefLong&>
+ : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<volatile CommonWithIntButRefLong&, const volatile int&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<volatile CommonWithIntButRefLong&, const volatile int&>
+ : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<volatile int&, const volatile CommonWithIntButRefLong&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<volatile int&, const volatile CommonWithIntButRefLong&>
+ : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<const volatile CommonWithIntButRefLong&, int&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<const volatile CommonWithIntButRefLong&, int&>
+ : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<const volatile int&, CommonWithIntButRefLong&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<const volatile int&, CommonWithIntButRefLong&>
+ : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<const volatile CommonWithIntButRefLong&, const int&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<const volatile CommonWithIntButRefLong&, const int&>
+ : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<const volatile int&, const CommonWithIntButRefLong&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<const volatile int&, const CommonWithIntButRefLong&>
+ : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<const volatile CommonWithIntButRefLong&, volatile int&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<const volatile CommonWithIntButRefLong&, volatile int&>
+ : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<const volatile int&, volatile CommonWithIntButRefLong&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<const volatile int&, volatile CommonWithIntButRefLong&>
+ : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<const volatile CommonWithIntButRefLong&, const volatile int&>
- : common_type<CommonWithIntButRefLong&, int&> {};
+struct std::common_type<const volatile CommonWithIntButRefLong&, const volatile int&>
+ : std::common_type<CommonWithIntButRefLong&, int&> {};
template <>
-struct common_type<const volatile int&, const volatile CommonWithIntButRefLong&>
- : common_type<CommonWithIntButRefLong&, int&> {};
-} // namespace std
+struct std::common_type<const volatile int&, const volatile CommonWithIntButRefLong&>
+ : std::common_type<CommonWithIntButRefLong&, int&> {};
+
static_assert(CheckCommonWith<CommonWithIntButRefLong, int>());
diff --git a/libcxx/test/std/concepts/concepts.lang/concept.commonref/common_reference.compile.pass.cpp b/libcxx/test/std/concepts/concepts.lang/concept.commonref/common_reference.compile.pass.cpp
index 7c37dafc2d691..ab79130f812f0 100644
--- a/libcxx/test/std/concepts/concepts.lang/concept.commonref/common_reference.compile.pass.cpp
+++ b/libcxx/test/std/concepts/concepts.lang/concept.commonref/common_reference.compile.pass.cpp
@@ -273,17 +273,16 @@ struct BadBasicCommonReference {
static_assert(std::convertible_to<BadBasicCommonReference, int>);
static_assert(std::convertible_to<BadBasicCommonReference, int&>);
-namespace std {
template <template <class> class X, template <class> class Y>
-struct basic_common_reference<BadBasicCommonReference, int, X, Y> {
+struct std::basic_common_reference<BadBasicCommonReference, int, X, Y> {
using type = BadBasicCommonReference&;
};
template <template <class> class X, template <class> class Y>
-struct basic_common_reference<int, BadBasicCommonReference, X, Y> {
+struct std::basic_common_reference<int, BadBasicCommonReference, X, Y> {
using type = int&;
};
-} // namespace std
+
static_assert(!std::common_reference_with<BadBasicCommonReference, int>);
struct StructNotConvertibleToCommonReference {
@@ -291,19 +290,16 @@ struct StructNotConvertibleToCommonReference {
};
static_assert(std::convertible_to<int, StructNotConvertibleToCommonReference>);
-namespace std {
template <template <class> class X, template <class> class Y>
-struct basic_common_reference<StructNotConvertibleToCommonReference, int, X,
- Y> {
+struct std::basic_common_reference<StructNotConvertibleToCommonReference, int, X, Y> {
using type = int&;
};
template <template <class> class X, template <class> class Y>
-struct basic_common_reference<int, StructNotConvertibleToCommonReference, X,
- Y> {
+struct std::basic_common_reference<int, StructNotConvertibleToCommonReference, X, Y> {
using type = int&;
};
-} // namespace std
+
static_assert(
!std::common_reference_with<StructNotConvertibleToCommonReference, int>);
@@ -311,17 +307,16 @@ struct IntNotConvertibleToCommonReference {
operator int&() const;
};
-namespace std {
template <template <class> class X, template <class> class Y>
-struct basic_common_reference<IntNotConvertibleToCommonReference, int, X, Y> {
+struct std::basic_common_reference<IntNotConvertibleToCommonReference, int, X, Y> {
using type = int&;
};
template <template <class> class X, template <class> class Y>
-struct basic_common_reference<int, IntNotConvertibleToCommonReference, X, Y> {
+struct std::basic_common_reference<int, IntNotConvertibleToCommonReference, X, Y> {
using type = int&;
};
-} // namespace std
+
static_assert(
!std::common_reference_with<StructNotConvertibleToCommonReference, int>);
@@ -330,16 +325,15 @@ struct HasCommonReference {
operator int&() const;
};
-namespace std {
template <template <class> class X, template <class> class Y>
-struct basic_common_reference<HasCommonReference, int, X, Y> {
+struct std::basic_common_reference<HasCommonReference, int, X, Y> {
using type = int&;
};
template <template <class> class X, template <class> class Y>
-struct basic_common_reference<int, HasCommonReference, X, Y> {
+struct std::basic_common_reference<int, HasCommonReference, X, Y> {
using type = int&;
};
-} // namespace std
+
static_assert(!std::common_reference_with<HasCommonReference, int>);
static_assert(std::common_reference_with<HasCommonReference, int&>);
diff --git a/libcxx/test/std/containers/Emplaceable.h b/libcxx/test/std/containers/Emplaceable.h
index ca780d0ae1fe2..1a4e14505fb21 100644
--- a/libcxx/test/std/containers/Emplaceable.h
+++ b/libcxx/test/std/containers/Emplaceable.h
@@ -40,18 +40,13 @@ class Emplaceable
int get() const {return int_;}
};
-namespace std {
-
template <>
-struct hash<Emplaceable>
-{
- typedef Emplaceable argument_type;
- typedef std::size_t result_type;
+struct std::hash<Emplaceable> {
+ typedef Emplaceable argument_type;
+ typedef std::size_t result_type;
- std::size_t operator()(const Emplaceable& x) const {return x.get();}
+ std::size_t operator()(const Emplaceable& x) const { return x.get(); }
};
-}
-
#endif // TEST_STD_VER >= 11
#endif // EMPLACEABLE_H
diff --git a/libcxx/test/std/containers/NotConstructible.h b/libcxx/test/std/containers/NotConstructible.h
index f8d0d4d84ae90..213aa1442d5c2 100644
--- a/libcxx/test/std/containers/NotConstructible.h
+++ b/libcxx/test/std/containers/NotConstructible.h
@@ -23,18 +23,12 @@ bool
operator==(const NotConstructible&, const NotConstructible&)
{return true;}
-namespace std
-{
-
template <>
-struct hash<NotConstructible>
-{
- typedef NotConstructible argument_type;
- typedef std::size_t result_type;
+struct std::hash<NotConstructible> {
+ typedef NotConstructible argument_type;
+ typedef std::size_t result_type;
- std::size_t operator()(const NotConstructible&) const {return 0;}
+ std::size_t operator()(const NotConstructible&) const { return 0; }
};
-}
-
#endif // NOTCONSTRUCTIBLE_H
diff --git a/libcxx/test/std/containers/container.node/node_handle.pass.cpp b/libcxx/test/std/containers/container.node/node_handle.pass.cpp
index 1eab9042b9e13..de9564261a04f 100644
--- a/libcxx/test/std/containers/container.node/node_handle.pass.cpp
+++ b/libcxx/test/std/containers/container.node/node_handle.pass.cpp
@@ -59,16 +59,13 @@ struct Static
Static& operator=(Static&&) = delete;
};
-namespace std
-{
-template <> struct hash<Static>
-{
- using argument_type = Static;
- using result_type = std::size_t;
- hash() = default;
- std::size_t operator()(const Static&) const;
+template <>
+struct std::hash<Static> {
+ using argument_type = Static;
+ using result_type = std::size_t;
+ hash() = default;
+ std::size_t operator()(const Static&) const;
};
-}
static_assert(node_compatibility_table<
int, int, std::less<int>, std::less<int>, std::hash<int>,
diff --git a/libcxx/test/std/containers/unord/unord.map/compare.pass.cpp b/libcxx/test/std/containers/unord/unord.map/compare.pass.cpp
index 200107cddf12a..a8474f8f0bdc8 100644
--- a/libcxx/test/std/containers/unord/unord.map/compare.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.map/compare.pass.cpp
@@ -25,14 +25,10 @@ struct Key {
bool operator== (const Key&) const { return true; }
};
-namespace std
-{
- template <>
- struct hash<Key>
- {
- std::size_t operator()(Key const &) const {return 0;}
- };
-}
+template <>
+struct std::hash<Key> {
+ std::size_t operator()(Key const&) const { return 0; }
+};
int main(int, char**)
{
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_or_assign.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_or_assign.pass.cpp
index df2138395adf2..6ba28c00675bc 100644
--- a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_or_assign.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_or_assign.pass.cpp
@@ -58,11 +58,10 @@ class Moveable
bool moved() const {return int_ == -1;}
};
-namespace std {
- template <> struct hash<Moveable> {
- std::size_t operator () (const Moveable &m) const { return m.hash(); }
- };
-}
+template <>
+struct std::hash<Moveable> {
+ std::size_t operator()(const Moveable& m) const { return m.hash(); }
+};
int main(int, char**)
{
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/try.emplace.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/try.emplace.pass.cpp
index b9c82390ab3a5..15cf8bc59eba9 100644
--- a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/try.emplace.pass.cpp
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/try.emplace.pass.cpp
@@ -57,11 +57,10 @@ class Moveable
bool moved() const {return int_ == -1;}
};
-namespace std {
- template <> struct hash<Moveable> {
- std::size_t operator () (const Moveable &m) const { return m.hash(); }
- };
-}
+template <>
+struct std::hash<Moveable> {
+ std::size_t operator()(const Moveable& m) const { return m.hash(); }
+};
int main(int, char**)
{
diff --git a/libcxx/test/std/diagnostics/syserr/is_error_code_enum.pass.cpp b/libcxx/test/std/diagnostics/syserr/is_error_code_enum.pass.cpp
index 80735ba377f4f..3f614efee2036 100644
--- a/libcxx/test/std/diagnostics/syserr/is_error_code_enum.pass.cpp
+++ b/libcxx/test/std/diagnostics/syserr/is_error_code_enum.pass.cpp
@@ -33,12 +33,8 @@ class A {
};
// Specialize the template for my class
-namespace std
-{
- template <>
- struct is_error_code_enum<A> : public std::true_type {};
-}
-
+template <>
+struct std::is_error_code_enum<A> : public std::true_type {};
int main(int, char**)
{
diff --git a/libcxx/test/std/diagnostics/syserr/is_error_condition_enum.pass.cpp b/libcxx/test/std/diagnostics/syserr/is_error_condition_enum.pass.cpp
index b4a6566aaa031..e9916f2427a55 100644
--- a/libcxx/test/std/diagnostics/syserr/is_error_condition_enum.pass.cpp
+++ b/libcxx/test/std/diagnostics/syserr/is_error_condition_enum.pass.cpp
@@ -34,12 +34,8 @@ class A {
};
// Specialize the template for my class
-namespace std
-{
- template <>
- struct is_error_condition_enum<A> : public std::true_type {};
-}
-
+template <>
+struct std::is_error_condition_enum<A> : public std::true_type {};
int main(int, char**)
{
diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp
index 055977895dba7..2667223f5a7a7 100644
--- a/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp
+++ b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/ErrorCodeEnum.pass.cpp
@@ -23,12 +23,8 @@ enum testing
zero, one, two
};
-namespace std
-{
-
-template <> struct is_error_code_enum<testing> : public std::true_type {};
-
-}
+template <>
+struct std::is_error_code_enum<testing> : public std::true_type {};
std::error_code
make_error_code(testing x)
diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/lwg3629.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/lwg3629.pass.cpp
index 9e9e21f9fd9e7..076530b7007a6 100644
--- a/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/lwg3629.pass.cpp
+++ b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.constructors/lwg3629.pass.cpp
@@ -26,10 +26,8 @@ namespace User {
std::error_code make_error_code(Err) { return std::error_code(42, std::generic_category()); }
}
-namespace std {
- template <>
- struct is_error_code_enum<User::Err> : true_type {};
-}
+template <>
+struct std::is_error_code_enum<User::Err> : true_type {};
int main(int, char**) {
std::error_code e((User::Err()));
diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp
index 2c98c89119792..b86f9d21e204c 100644
--- a/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp
+++ b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/ErrorCodeEnum.pass.cpp
@@ -23,12 +23,8 @@ enum testing
zero, one, two
};
-namespace std
-{
-
-template <> struct is_error_code_enum<testing> : public std::true_type {};
-
-}
+template <>
+struct std::is_error_code_enum<testing> : public std::true_type {};
std::error_code
make_error_code(testing x)
diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/lwg3629.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/lwg3629.pass.cpp
index 4e5bcc394607c..4bea503ec0423 100644
--- a/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/lwg3629.pass.cpp
+++ b/libcxx/test/std/diagnostics/syserr/syserr.errcode/syserr.errcode.modifiers/lwg3629.pass.cpp
@@ -26,10 +26,8 @@ namespace User {
std::error_code make_error_code(Err) { return std::error_code(42, std::generic_category()); }
}
-namespace std {
- template <>
- struct is_error_code_enum<User::Err> : true_type {};
-}
+template <>
+struct std::is_error_code_enum<User::Err> : true_type {};
int main(int, char**) {
std::error_code e;
diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/lwg3629.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/lwg3629.pass.cpp
index 2d2d43a129d70..f1e2d9a2ba349 100644
--- a/libcxx/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/lwg3629.pass.cpp
+++ b/libcxx/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.constructors/lwg3629.pass.cpp
@@ -26,10 +26,8 @@ namespace User {
std::error_condition make_error_condition(Err) { return std::error_condition(42, std::generic_category()); }
}
-namespace std {
- template <>
- struct is_error_condition_enum<User::Err> : true_type {};
-}
+template <>
+struct std::is_error_condition_enum<User::Err> : true_type {};
int main(int, char**) {
std::error_condition e((User::Err()));
diff --git a/libcxx/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/lwg3629.pass.cpp b/libcxx/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/lwg3629.pass.cpp
index 72cc77b4949d6..014f14a9fd82a 100644
--- a/libcxx/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/lwg3629.pass.cpp
+++ b/libcxx/test/std/diagnostics/syserr/syserr.errcondition/syserr.errcondition.modifiers/lwg3629.pass.cpp
@@ -28,10 +28,8 @@ namespace User {
std::error_condition make_error_condition(Err) { return std::error_condition(42, std::generic_category()); }
}
-namespace std {
- template <>
- struct is_error_condition_enum<User::Err> : true_type {};
-}
+template <>
+struct std::is_error_condition_enum<User::Err> : true_type {};
int main(int, char**) {
std::error_condition e;
diff --git a/libcxx/test/std/experimental/utilities/propagate_const/propagate_const.nonmembers/hash.pass.cpp b/libcxx/test/std/experimental/utilities/propagate_const/propagate_const.nonmembers/hash.pass.cpp
index 65208ffd8b1fb..1572dd974f7ef 100644
--- a/libcxx/test/std/experimental/utilities/propagate_const/propagate_const.nonmembers/hash.pass.cpp
+++ b/libcxx/test/std/experimental/utilities/propagate_const/propagate_const.nonmembers/hash.pass.cpp
@@ -19,18 +19,15 @@
using std::experimental::propagate_const;
-namespace std {
-template <> struct hash<X>
-{
+template <>
+struct std::hash<X> {
typedef X first_argument_type;
std::size_t operator()(const first_argument_type&) const
{
return 99;
}
-
};
-} // namespace std
int main(int, char**) {
diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.readable/indirectly_readable.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.readable/indirectly_readable.compile.pass.cpp
index e06234477e290..5fc6ffd37caf1 100644
--- a/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.readable/indirectly_readable.compile.pass.cpp
+++ b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.readable/indirectly_readable.compile.pass.cpp
@@ -81,13 +81,12 @@ static_assert(!check_indirectly_readable<missing_iter_value_t>());
struct unrelated_lvalue_ref_and_rvalue_ref {};
struct iter_ref1 {};
-namespace std {
template <>
-struct common_reference<iter_ref1&, iter_ref1&&> {};
+struct std::common_reference<iter_ref1&, iter_ref1&&> {};
template <>
-struct common_reference<iter_ref1&&, iter_ref1&> {};
-} // namespace std
+struct std::common_reference<iter_ref1&&, iter_ref1&> {};
+
static_assert(!std::common_reference_with<iter_ref1&, iter_ref1&&>);
struct bad_iter_reference_t {
@@ -109,16 +108,16 @@ static_assert(!check_indirectly_readable<unrelated_iter_ref_rvalue_and_iter_rval
struct iter_ref3 {
operator iter_rvalue_ref() const;
};
-namespace std {
+
template <template <class> class XQual, template <class> class YQual>
-struct basic_common_reference<iter_ref3, iter_rvalue_ref, XQual, YQual> {
+struct std::basic_common_reference<iter_ref3, iter_rvalue_ref, XQual, YQual> {
using type = iter_rvalue_ref;
};
template <template <class> class XQual, template <class> class YQual>
-struct basic_common_reference<iter_rvalue_ref, iter_ref3, XQual, YQual> {
+struct std::basic_common_reference<iter_rvalue_ref, iter_ref3, XQual, YQual> {
using type = iter_rvalue_ref;
};
-} // namespace std
+
static_assert(std::common_reference_with<iter_ref3&&, iter_rvalue_ref&&>);
struct different_reference_types_with_common_reference {
@@ -131,21 +130,22 @@ static_assert(check_indirectly_readable<different_reference_types_with_common_re
struct iter_ref4 {
operator iter_rvalue_ref() const;
};
-namespace std {
+
template <template <class> class XQual, template <class> class YQual>
-struct basic_common_reference<iter_ref4, iter_rvalue_ref, XQual, YQual> {
+struct std::basic_common_reference<iter_ref4, iter_rvalue_ref, XQual, YQual> {
using type = iter_rvalue_ref;
};
template <template <class> class XQual, template <class> class YQual>
-struct basic_common_reference<iter_rvalue_ref, iter_ref4, XQual, YQual> {
+struct std::basic_common_reference<iter_rvalue_ref, iter_ref4, XQual, YQual> {
using type = iter_rvalue_ref;
};
+// FIXME: This is UB according to [meta.rqmts], and there is no exception for common_reference.
template <>
-struct common_reference<iter_ref4 const&, iter_rvalue_ref&&> {};
+struct std::common_reference<iter_ref4 const&, iter_rvalue_ref&&> {};
template <>
-struct common_reference<iter_rvalue_ref&&, iter_ref4 const&> {};
-} // namespace std
+struct std::common_reference<iter_rvalue_ref&&, iter_ref4 const&> {};
+
static_assert(std::common_reference_with<iter_ref4&&, iter_rvalue_ref&&>);
static_assert(!std::common_reference_with<iter_ref4 const&, iter_rvalue_ref&&>);
diff --git a/libcxx/test/std/localization/locale.categories/category.numeric/locale.num.get/user_defined_char_type.pass.cpp b/libcxx/test/std/localization/locale.categories/category.numeric/locale.num.get/user_defined_char_type.pass.cpp
index 9a4a2f0d5657e..17faf83892a7c 100644
--- a/libcxx/test/std/localization/locale.categories/category.numeric/locale.num.get/user_defined_char_type.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.numeric/locale.num.get/user_defined_char_type.pass.cpp
@@ -26,9 +26,8 @@ struct Char {
char underlying_;
};
-namespace std {
template <>
-struct char_traits<Char> {
+struct std::char_traits<Char> {
using char_type = Char;
using int_type = int;
using off_type = streamoff;
@@ -73,7 +72,7 @@ struct char_traits<Char> {
// This ctype specialization treats all characters as spaces
template <>
-class ctype<Char> : public locale::facet, public ctype_base {
+class std::ctype<Char> : public locale::facet, public ctype_base {
public:
using char_type = Char;
static locale::id id;
@@ -121,10 +120,10 @@ class ctype<Char> : public locale::facet, public ctype_base {
}
};
-locale::id ctype<Char>::id;
+std::locale::id std::ctype<Char>::id;
template <>
-class numpunct<Char> : public locale::facet {
+class std::numpunct<Char> : public locale::facet {
public:
typedef basic_string<Char> string_type;
static locale::id id;
@@ -141,9 +140,7 @@ class numpunct<Char> : public locale::facet {
}
};
-locale::id numpunct<Char>::id;
-
-} // namespace std
+std::locale::id std::numpunct<Char>::id;
int main(int, char**) {
std::locale l(std::locale::classic(), new std::num_get<Char>);
diff --git a/libcxx/test/std/ranges/range.utility/range.subrange/ctor.range_size.pass.cpp b/libcxx/test/std/ranges/range.utility/range.subrange/ctor.range_size.pass.cpp
index 4b29546465e2c..fa2d34db15f23 100644
--- a/libcxx/test/std/ranges/range.utility/range.subrange/ctor.range_size.pass.cpp
+++ b/libcxx/test/std/ranges/range.utility/range.subrange/ctor.range_size.pass.cpp
@@ -27,10 +27,8 @@ struct BorrowedRange {
int* end_;
};
-namespace std::ranges {
- template <>
- inline constexpr bool enable_borrowed_range<::BorrowedRange> = true;
-}
+template <>
+inline constexpr bool std::ranges::enable_borrowed_range<BorrowedRange> = true;
constexpr bool test() {
int buff[] = {1, 2, 3, 4, 5, 6, 7, 8};
diff --git a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
index a352b4cf9b92e..8c2324c9d1759 100644
--- a/libcxx/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
@@ -23,9 +23,8 @@ struct VeryLarge {
char b;
};
-namespace std {
template <>
-struct char_traits<VeryLarge> {
+struct std::char_traits<VeryLarge> {
using char_type = VeryLarge;
using int_type = int;
using off_type = streamoff;
@@ -55,7 +54,6 @@ struct char_traits<VeryLarge> {
static bool eq_int_type(int_type c1, int_type c2);
static int_type eof();
};
-} // end namespace std
template <class S>
TEST_CONSTEXPR_CXX20 void test(S s, typename S::value_type c, S expected) {
diff --git a/libcxx/test/std/time/rep.h b/libcxx/test/std/time/rep.h
index ddb5c0b249317..6df3e7ad27c4d 100644
--- a/libcxx/test/std/time/rep.h
+++ b/libcxx/test/std/time/rep.h
@@ -40,16 +40,16 @@ struct RepConstConvertibleLWG3050 {
operator long() = delete;
operator long() const { return 2; }
};
-namespace std {
+
template <>
-struct common_type<RepConstConvertibleLWG3050, int> {
+struct std::common_type<RepConstConvertibleLWG3050, int> {
using type = long;
};
template <>
-struct common_type<int, RepConstConvertibleLWG3050> {
+struct std::common_type<int, RepConstConvertibleLWG3050> {
using type = long;
};
-} // namespace std
+
#endif // TEST_STD_VER >= 11
// std::chrono:::duration has only '*', '/' and '%' taking a "Rep" parameter
diff --git a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp
index 35721f1cbba9d..2cb2c670441b0 100644
--- a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp
@@ -53,19 +53,13 @@ struct D
typedef void difference_type;
};
-namespace std
-{
-
template <>
-struct pointer_traits<C<char>::pointer>
-{
- typedef C<char>::pointer pointer;
- typedef char element_type;
- typedef signed char difference_type;
+struct std::pointer_traits<C<char>::pointer> {
+ typedef C<char>::pointer pointer;
+ typedef char element_type;
+ typedef signed char difference_type;
};
-}
-
int main(int, char**)
{
static_assert((std::is_same<std::allocator_traits<A<char> >::difference_type, short>::value), "");
diff --git a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp
index cd74671390e7e..d8f15af6acf18 100644
--- a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp
@@ -51,17 +51,11 @@ struct D {
typedef void size_type;
};
-namespace std
-{
-
template <>
-struct pointer_traits<C<char>::pointer>
-{
- typedef signed char difference_type;
+struct std::pointer_traits<C<char>::pointer> {
+ typedef signed char difference_type;
};
-}
-
int main(int, char**)
{
static_assert((std::is_same<std::allocator_traits<A<char> >::size_type, unsigned short>::value), "");
diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/common_reference.compile.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/common_reference.compile.pass.cpp
index 04a1451863c90..e802776f52bfc 100644
--- a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/common_reference.compile.pass.cpp
+++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/common_reference.compile.pass.cpp
@@ -33,26 +33,22 @@ struct Tuple_helper<std::void_t<std::common_reference_t<Ts, Us>...>, UserTuple<T
using type = UserTuple<std::common_reference_t<Ts, Us>...>;
};
-namespace std {
template <class... Ts, class... Us, template <class> class TQual, template <class> class UQual>
-struct basic_common_reference< ::UserTuple<Ts...>, ::UserTuple<Us...>, TQual, UQual>
+struct std::basic_common_reference< ::UserTuple<Ts...>, ::UserTuple<Us...>, TQual, UQual>
: ::Tuple_helper<void, UserTuple<TQual<Ts>...>, UserTuple<UQual<Us>...> > {};
-} // namespace std
struct X2 {};
struct Y2 {};
struct Z2 {};
-namespace std {
template <>
-struct common_type<X2, Y2> {
+struct std::common_type<X2, Y2> {
using type = Z2;
};
template <>
-struct common_type<Y2, X2> {
+struct std::common_type<Y2, X2> {
using type = Z2;
};
-} // namespace std
// (6.1)
// -- If sizeof...(T) is zero, there shall be no member type.
diff --git a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
index 66a29a37a3688..82929a3f3eee3 100644
--- a/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
+++ b/libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp
@@ -33,29 +33,28 @@ struct bad_reference_wrapper {
operator T&() const;
};
-namespace std
-{
- template <typename T>
- struct common_type<T, ::S<T> >
- {
- typedef S<T> type;
- };
+template <typename T>
+struct std::common_type<T, ::S<T> > {
+ typedef S<T> type;
+};
- template <class T>
- struct common_type< ::S<T>, T> {
- typedef S<T> type;
- };
+template <class T>
+struct std::common_type< ::S<T>, T> {
+ typedef S<T> type;
+};
// P0548
- template <class T>
- struct common_type< ::S<T>, ::S<T> > {
- typedef S<T> type;
- };
-
- template <> struct common_type< ::S<long>, long> {};
- template <> struct common_type<long, ::S<long> > {};
- template <> struct common_type< ::X<double>, ::X<double> > {};
-}
+template <class T>
+struct std::common_type< ::S<T>, ::S<T> > {
+ typedef S<T> type;
+};
+
+template <>
+struct std::common_type< ::S<long>, long> {};
+template <>
+struct std::common_type<long, ::S<long> > {};
+template <>
+struct std::common_type< ::X<double>, ::X<double> > {};
template <class> struct VoidT { typedef void type; };
diff --git a/libcxx/test/std/utilities/optional/optional.hash/hash.pass.cpp b/libcxx/test/std/utilities/optional/optional.hash/hash.pass.cpp
index cb23e03e7ca70..ae14b571f7388 100644
--- a/libcxx/test/std/utilities/optional/optional.hash/hash.pass.cpp
+++ b/libcxx/test/std/utilities/optional/optional.hash/hash.pass.cpp
@@ -23,15 +23,11 @@
struct A {};
struct B {};
-namespace std {
-
template <>
-struct hash<B> {
+struct std::hash<B> {
std::size_t operator()(B const&) noexcept(false) { return 0; }
};
-}
-
int main(int, char**)
{
using std::optional;
diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.pass.cpp
index 7585911e2e8d2..a2cb2e989a571 100644
--- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.pass.cpp
+++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_incomplete.pass.cpp
@@ -31,9 +31,8 @@ template <class T> constexpr bool is_complete() { return is_complete<T>(0); }
struct Dummy1 {};
struct Dummy2 {};
-namespace std {
-template <> struct tuple_size<Dummy1> : public integral_constant<std::size_t, 0> {};
-}
+template <>
+struct std::tuple_size<Dummy1> : public integral_constant<std::size_t, 0> {};
template <class T>
void test_complete() {
diff --git a/libcxx/test/std/utilities/utility/pairs/pairs.pair/ctor.pair_like.pass.cpp b/libcxx/test/std/utilities/utility/pairs/pairs.pair/ctor.pair_like.pass.cpp
index 3810c4450e57f..3ff416ed5737e 100644
--- a/libcxx/test/std/utilities/utility/pairs/pairs.pair/ctor.pair_like.pass.cpp
+++ b/libcxx/test/std/utilities/utility/pairs/pairs.pair/ctor.pair_like.pass.cpp
@@ -37,18 +37,14 @@ friend int get(MyPairLike const&)
} // namespace my_ns
-namespace std {
-
template <>
-struct tuple_size<my_ns::MyPairLike> : std::integral_constant<std::size_t, 2> {};
+struct std::tuple_size<my_ns::MyPairLike> : std::integral_constant<std::size_t, 2> {};
template <std::size_t N>
-struct tuple_element<N, my_ns::MyPairLike> {
+struct std::tuple_element<N, my_ns::MyPairLike> {
using type = int;
};
-} // namespace std
-
// https://github.com/llvm/llvm-project/issues/65620
// This used to be a hard error
static_assert(!std::is_constructible_v<std::pair<int,int>, my_ns::MyPairLike const&>);
diff --git a/libcxx/test/std/utilities/variant/variant.hash/hash.pass.cpp b/libcxx/test/std/utilities/variant/variant.hash/hash.pass.cpp
index f472144403d55..ffd5f8266ec2b 100644
--- a/libcxx/test/std/utilities/variant/variant.hash/hash.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.hash/hash.pass.cpp
@@ -22,14 +22,13 @@
#include "poisoned_hash_helper.h"
#ifndef TEST_HAS_NO_EXCEPTIONS
-namespace std {
-template <> struct hash<::MakeEmptyT> {
+template <>
+struct std::hash<::MakeEmptyT> {
std::size_t operator()(const ::MakeEmptyT &) const {
assert(false);
return 0;
}
};
-}
#endif
void test_hash_variant() {
@@ -123,17 +122,13 @@ void test_hash_variant_duplicate_elements() {
struct A {};
struct B {};
-namespace std {
-
template <>
-struct hash<B> {
+struct std::hash<B> {
std::size_t operator()(B const&) const {
return 0;
}
};
-}
-
void test_hash_variant_enabled() {
{
test_hash_enabled_for_type<std::variant<int> >();
diff --git a/libcxx/test/std/utilities/variant/variant.visit.member/visit.pass.cpp b/libcxx/test/std/utilities/variant/variant.visit.member/visit.pass.cpp
index 857e85d00857a..0da23fd58ccaa 100644
--- a/libcxx/test/std/utilities/variant/variant.visit.member/visit.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.visit.member/visit.pass.cpp
@@ -163,6 +163,7 @@ void test_caller_accepts_nonconst() {
struct MyVariant : std::variant<short, long, float> {};
+// FIXME: This is UB according to [namespace.std]
namespace std {
template <std::size_t Index>
void get(const MyVariant&) {
diff --git a/libcxx/test/std/utilities/variant/variant.visit/visit.pass.cpp b/libcxx/test/std/utilities/variant/variant.visit/visit.pass.cpp
index 0caecbe875d55..a72dcf13174c6 100644
--- a/libcxx/test/std/utilities/variant/variant.visit/visit.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.visit/visit.pass.cpp
@@ -314,6 +314,7 @@ void test_caller_accepts_nonconst() {
struct MyVariant : std::variant<short, long, float> {};
+// FIXME: This is UB according to [namespace.std]
namespace std {
template <std::size_t Index>
void get(const MyVariant&) {
diff --git a/libcxx/test/support/Counter.h b/libcxx/test/support/Counter.h
index 6a51cc991eee7..ed03e8a04a069 100644
--- a/libcxx/test/support/Counter.h
+++ b/libcxx/test/support/Counter.h
@@ -40,16 +40,12 @@ class Counter : public Counter_base
int Counter_base::gConstructed = 0;
-namespace std {
-
template <class T>
-struct hash<Counter<T> >
-{
- typedef Counter<T> argument_type;
- typedef std::size_t result_type;
+struct std::hash<Counter<T> > {
+ typedef Counter<T> argument_type;
+ typedef std::size_t result_type;
- std::size_t operator()(const Counter<T>& x) const {return std::hash<T>()(x.get());}
+ std::size_t operator()(const Counter<T>& x) const { return std::hash<T>()(x.get()); }
};
-}
#endif
More information about the libcxx-commits
mailing list