Skip to content

Commit 3ebe45f

Browse files
committed
Put many implementation details in unnamed namespace to work around llvm/llvm-project#90154
1 parent 04b5e51 commit 3ebe45f

15 files changed

+62
-4
lines changed

source/bounded/arithmetic/increment_decrement.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ namespace bounded {
2323
OPERATORS_IMPORT_COMPOUND_ASSIGNMENT(export)
2424
export using operators::binary::operator-; \
2525

26+
namespace {
27+
2628
template<typename T>
2729
concept incrementable_by_bounded = requires(T value) {
2830
value += constant<1>;
@@ -32,6 +34,8 @@ concept decrementable_by_bounded = requires(T value) {
3234
value -= constant<1>;
3335
};
3436

37+
} // namespace
38+
3539
inline namespace arithmetic {
3640

3741
export constexpr auto operator++(incrementable_by_bounded auto & value) -> decltype(auto) {

source/bounded/arithmetic/modulus.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import std_module;
2121

2222
namespace bounded {
2323

24+
namespace {
2425

2526
using smax_t = numeric_traits::max_signed_t;
2627
using umax_t = numeric_traits::max_unsigned_t;
@@ -78,6 +79,8 @@ constexpr auto sign_free_value = [](auto const dividend, auto divisor) {
7879
return current;
7980
};
8081

82+
} // namespace
83+
8184
constexpr auto modulus_operator_range(auto const lhs, auto const rhs) {
8285
// The sign of the result is equal to the sign of the lhs. The sign of the
8386
// rhs does not matter. Therefore, we use the absolute value of the rhs; we

source/bounded/arithmetic/operators.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ BOUNDED_COMMON_ARITHMETIC(export)
3939

4040
} // namespace bounded
4141

42+
namespace {
43+
4244
static_assert(homogeneous_equals(
4345
bounded::constant<0> - bounded::constant<0>,
4446
bounded::constant<0>
@@ -88,4 +90,6 @@ static_assert([]{
8890
BOUNDED_ASSERT(post_increment == bounded::constant<0>);
8991
BOUNDED_ASSERT(z == bounded::constant<1>);
9092
return true;
91-
}());
93+
}());
94+
95+
} // namespace

source/bounded/arithmetic/operators_builtin.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ BOUNDED_INTEGER_MIXED_OPERATOR_OVERLOADS(>>)
4545

4646
} // namespace bounded
4747

48+
namespace {
49+
4850
static_assert(homogeneous_equals(
4951
bounded::integer<1, 10>(bounded::constant<9>) + std::integral_constant<int, 5>{},
5052
bounded::integer<6, 15>(bounded::constant<14>)
@@ -106,3 +108,5 @@ static_assert(plus_equals(9U, bounded::constant<3>) == 12);
106108
static_assert(minus_equals(9, bounded::constant<68>) == -59);
107109
static_assert(divides_equals(-59, bounded::constant<10>) == -5);
108110
static_assert(modulus_equals(-5, bounded::constant<4>) == -1);
111+
112+
} // namespace

source/bounded/arithmetic/plus.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ import std_module;
1818

1919
namespace bounded {
2020

21+
namespace {
22+
2123
constexpr auto max_signed = numeric_traits::max_value<numeric_traits::max_signed_t>;
2224

25+
} // namespace
26+
2327
template<auto lhs, auto rhs>
2428
constexpr auto safer_add() {
2529
constexpr auto modulo_equivalent_value = static_cast<numeric_traits::max_unsigned_t>(lhs) + static_cast<numeric_traits::max_unsigned_t>(rhs);

source/bounded/arithmetic/pointer.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@ import std_module;
1515

1616
namespace bounded {
1717

18+
namespace {
19+
1820
// This is faster to compile than `std::is_pointer_v`
1921
template<typename>
2022
constexpr auto is_pointer = false;
2123

2224
template<typename T>
2325
constexpr auto is_pointer<T *> = true;
2426

27+
} // namespace
28+
2529
export template<typename T, bounded_integer Integer> requires(
2630
(is_pointer<T> or (std::is_array_v<T> and numeric_traits::max_value<Integer> <= constant<std::extent_v<T>>))
2731
)
@@ -42,6 +46,8 @@ constexpr auto operator+(Integer const number, T const & array) {
4246

4347
} // namespace bounded
4448

49+
namespace {
50+
4551
using array_type = int[5];
4652
constexpr array_type array{ 0, 1, 2, 3, 4 };
4753

@@ -71,3 +77,5 @@ static_assert(
7177
"Incorrect array indexing with bounded::integer."
7278
);
7379
#endif
80+
81+
} // namespace

source/bounded/arithmetic/unary_minus.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ constexpr auto operator-(integer<minimum, maximum> const value) {
4747

4848
} // namespace bounded
4949

50+
namespace {
51+
5052
static_assert(homogeneous_equals(
5153
-bounded::constant<0>,
5254
bounded::constant<0>
@@ -102,4 +104,6 @@ static_assert(homogeneous_equals(
102104
static_assert(homogeneous_equals(
103105
-bounded::integer<-3, 6>(bounded::constant<4>),
104106
bounded::integer<-6, 3>(bounded::constant<-4>)
105-
));
107+
));
108+
109+
} // namespace

source/bounded/arithmetic/unary_plus.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export constexpr auto operator+(bounded_integer auto const value) {
1818

1919
} // namespace bounded
2020

21+
namespace {
22+
2123
static_assert(homogeneous_equals(
2224
+bounded::constant<0>,
2325
bounded::constant<0>
@@ -44,3 +46,5 @@ static_assert(homogeneous_equals(
4446
+x,
4547
x
4648
));
49+
50+
} // namespace

source/bounded/construct.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ constexpr auto construct = construct_t<T>();
2828

2929
} // namespace bounded
3030

31+
namespace {
32+
3133
static_assert(bounded::construct<int>() == 0);
3234
static_assert(bounded::construct<int>(2) == 2);
3335
static_assert(noexcept(bounded::construct<int>()));
@@ -43,3 +45,5 @@ struct convert_to_int_throws {
4345
};
4446

4547
static_assert(!noexcept(bounded::construct<int>(convert_to_int_throws())));
48+
49+
} // namespace

source/bounded/construct_at.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ export constexpr auto construct_at = construct_at_t();
7070

7171
} // namespace bounded
7272

73+
namespace {
74+
7375
struct empty {};
7476

7577
struct accepts_anything {
@@ -115,3 +117,4 @@ static_assert(!noexcept(bounded::construct_at(bounded::declval<int &>(), make_no
115117
auto make_no_lazy_construction_convert_to_int_throws() noexcept -> bounded::no_lazy_construction<convert_to_int_throws>;
116118
static_assert(!noexcept(bounded::construct_at(bounded::declval<int &>(), make_no_lazy_construction_convert_to_int_throws)));
117119

120+
} // namespace

source/bounded/safe_compare.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ import std_module;
1313

1414
namespace bounded {
1515

16+
namespace {
17+
1618
constexpr auto max_signed = numeric_traits::max_value<numeric_traits::max_signed_t>;
1719

20+
} // namespace
21+
1822
export template<builtin_integer LHS, builtin_integer RHS>
1923
constexpr auto safe_compare(LHS const lhs, RHS const rhs) -> std::strong_ordering {
2024
if constexpr (signed_builtin<LHS> == signed_builtin<RHS>) {

source/bounded/safe_equal.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ import std_module;
1313

1414
namespace bounded {
1515

16+
namespace {
17+
1618
constexpr auto max_signed = numeric_traits::max_value<numeric_traits::max_signed_t>;
1719

20+
} // namespace
21+
1822
export template<builtin_integer LHS, builtin_integer RHS>
1923
constexpr auto safe_equal(LHS const lhs, RHS const rhs) -> bool {
2024
if constexpr (signed_builtin<LHS> == signed_builtin<RHS>) {

source/containers/array.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ struct std::tuple_element<index, ::containers::array<T, size>> {
170170
using type = T;
171171
};
172172

173+
namespace {
173174

174175
constexpr auto size = 5_bi;
175176
constexpr containers::array<int, size> a = {};
@@ -224,3 +225,5 @@ static_assert(array_non_copyable_empty.size() == 0_bi);
224225
constexpr auto large_size = 10000_bi;
225226
constexpr auto large_array_n = containers::make_array_n(large_size, 0);
226227
static_assert(large_array_n.size() == large_size);
228+
229+
} // namespace

source/containers/begin_end.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ constexpr auto end(Range && r) {
6565
}
6666

6767
} // namespace containers
68+
namespace {
6869

6970
using namespace bounded::literal;
7071

@@ -112,3 +113,5 @@ struct {
112113
}
113114
} constexpr data_and_size;
114115
static_assert(containers::begin(data_and_size) == containers::end(data_and_size));
116+
117+
} // namespace

source/containers/size.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ constexpr auto size(c_array<T, size_> const &) {
3737
}
3838

3939
} // namespace containers
40-
40+
namespace {
4141
using namespace bounded::literal;
4242

4343
constexpr int a[] = {0, 1, 2, 3, 4};
@@ -84,4 +84,6 @@ struct member_begin_end {
8484
return begin() + 4;
8585
}
8686
};
87-
static_assert(containers::size(member_begin_end()) == 4);
87+
static_assert(containers::size(member_begin_end()) == 4);
88+
89+
} // namespace

0 commit comments

Comments
 (0)