Skip to content

Commit 8b24e40

Browse files
committed
[libc++][NFC] Avoid opening namespace std in the tests
1 parent daaaf4e commit 8b24e40

File tree

35 files changed

+364
-515
lines changed

35 files changed

+364
-515
lines changed

libcxx/test/libcxx/utilities/any/allocator.pass.cpp

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -39,62 +39,62 @@ bool Large_was_deallocated = false;
3939
bool Small_was_constructed = false;
4040
bool Small_was_destroyed = false;
4141

42-
namespace std {
43-
template <>
44-
struct allocator<Large> {
45-
using value_type = Large;
46-
using size_type = std::size_t;
47-
using difference_type = std::ptrdiff_t;
48-
using propagate_on_container_move_assignment = std::true_type;
49-
using is_always_equal = std::true_type;
50-
51-
Large* allocate(std::size_t n) {
52-
Large_was_allocated = true;
53-
return static_cast<Large*>(::operator new(n * sizeof(Large)));
54-
}
42+
template <>
43+
struct std::allocator<Large> {
44+
using value_type = Large;
45+
using size_type = std::size_t;
46+
using difference_type = std::ptrdiff_t;
47+
using propagate_on_container_move_assignment = std::true_type;
48+
using is_always_equal = std::true_type;
49+
50+
Large* allocate(std::size_t n) {
51+
Large_was_allocated = true;
52+
return static_cast<Large*>(::operator new(n * sizeof(Large)));
53+
}
5554

56-
template <typename ...Args>
57-
void construct(Large* p, Args&& ...args) {
58-
new (p) Large(std::forward<Args>(args)...);
59-
Large_was_constructed = true;
60-
}
55+
template <typename... Args>
56+
void construct(Large* p, Args&&... args) {
57+
new (p) Large(std::forward<Args>(args)...);
58+
Large_was_constructed = true;
59+
}
6160

62-
void destroy(Large* p) {
63-
p->~Large();
64-
Large_was_destroyed = true;
65-
}
61+
void destroy(Large* p) {
62+
p->~Large();
63+
Large_was_destroyed = true;
64+
}
6665

67-
void deallocate(Large* p, std::size_t) {
68-
Large_was_deallocated = true;
69-
return ::operator delete(p);
70-
}
71-
};
72-
73-
template <>
74-
struct allocator<Small> {
75-
using value_type = Small;
76-
using size_type = std::size_t;
77-
using difference_type = std::ptrdiff_t;
78-
using propagate_on_container_move_assignment = std::true_type;
79-
using is_always_equal = std::true_type;
80-
81-
Small* allocate(std::size_t) { assert(false); return nullptr; }
82-
83-
template <typename ...Args>
84-
void construct(Small* p, Args&& ...args) {
85-
new (p) Small(std::forward<Args>(args)...);
86-
Small_was_constructed = true;
87-
}
66+
void deallocate(Large* p, std::size_t) {
67+
Large_was_deallocated = true;
68+
return ::operator delete(p);
69+
}
70+
};
71+
72+
template <>
73+
struct std::allocator<Small> {
74+
using value_type = Small;
75+
using size_type = std::size_t;
76+
using difference_type = std::ptrdiff_t;
77+
using propagate_on_container_move_assignment = std::true_type;
78+
using is_always_equal = std::true_type;
79+
80+
Small* allocate(std::size_t) {
81+
assert(false);
82+
return nullptr;
83+
}
8884

89-
void destroy(Small* p) {
90-
p->~Small();
91-
Small_was_destroyed = true;
92-
}
85+
template <typename... Args>
86+
void construct(Small* p, Args&&... args) {
87+
new (p) Small(std::forward<Args>(args)...);
88+
Small_was_constructed = true;
89+
}
9390

94-
void deallocate(Small*, std::size_t) { assert(false); }
95-
};
96-
} // end namespace std
91+
void destroy(Small* p) {
92+
p->~Small();
93+
Small_was_destroyed = true;
94+
}
9795

96+
void deallocate(Small*, std::size_t) { assert(false); }
97+
};
9898

9999
int main(int, char**) {
100100
// Test large types

libcxx/test/libcxx/utilities/format/enable_insertable.compile.pass.cpp

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,26 +61,24 @@ struct valid {
6161
void insert(iterator, CharT*, CharT*);
6262
};
6363

64-
namespace std::__format {
6564
template <>
66-
inline constexpr bool __enable_insertable<no_value_type<char>> = true;
65+
inline constexpr bool std::__format::__enable_insertable<no_value_type<char>> = true;
6766
template <>
68-
inline constexpr bool __enable_insertable<no_end<char>> = true;
67+
inline constexpr bool std::__format::__enable_insertable<no_end<char>> = true;
6968
template <>
70-
inline constexpr bool __enable_insertable<no_insert<char>> = true;
69+
inline constexpr bool std::__format::__enable_insertable<no_insert<char>> = true;
7170
template <>
72-
inline constexpr bool __enable_insertable<valid<char>> = true;
71+
inline constexpr bool std::__format::__enable_insertable<valid<char>> = true;
7372
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
7473
template <>
75-
inline constexpr bool __enable_insertable<no_value_type<wchar_t>> = true;
74+
inline constexpr bool std::__format::__enable_insertable<no_value_type<wchar_t>> = true;
7675
template <>
77-
inline constexpr bool __enable_insertable<no_end<wchar_t>> = true;
76+
inline constexpr bool std::__format::__enable_insertable<no_end<wchar_t>> = true;
7877
template <>
79-
inline constexpr bool __enable_insertable<no_insert<wchar_t>> = true;
78+
inline constexpr bool std::__format::__enable_insertable<no_insert<wchar_t>> = true;
8079
template <>
81-
inline constexpr bool __enable_insertable<valid<wchar_t>> = true;
80+
inline constexpr bool std::__format::__enable_insertable<valid<wchar_t>> = true;
8281
#endif
83-
} // namespace std::__format
8482

8583
static_assert(!std::__format::__insertable<no_value_type<char>>);
8684
static_assert(!std::__format::__insertable<no_end<char>>);
@@ -95,12 +93,10 @@ static_assert(!std::__format::__insertable<no_specialization<wchar_t>>);
9593
static_assert(std::__format::__insertable<valid<wchar_t>>);
9694
#endif
9795

98-
namespace std::__format {
9996
template <>
100-
inline constexpr bool __enable_insertable<valid<signed char>> = true;
97+
inline constexpr bool std::__format::__enable_insertable<valid<signed char>> = true;
10198
template <>
102-
inline constexpr bool __enable_insertable<valid<unsigned char>> = true;
103-
} // namespace std::__format
99+
inline constexpr bool std::__format::__enable_insertable<valid<unsigned char>> = true;
104100

105101
static_assert(!std::__format::__insertable<valid<signed char>>);
106102
static_assert(!std::__format::__insertable<valid<unsigned char>>);

0 commit comments

Comments
 (0)