Skip to content

Commit e02d08a

Browse files
authored
Merge pull request #847 from cppalliance/detail_concepts
Move concepts into detail namespace
2 parents f51da45 + 52e2d49 commit e02d08a

File tree

3 files changed

+55
-59
lines changed

3 files changed

+55
-59
lines changed

include/boost/decimal/detail/concepts.hpp

Lines changed: 50 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@
5252
#include <complex>
5353
#endif
5454

55-
namespace boost::decimal::concepts {
56-
57-
namespace detail {
55+
namespace boost::decimal::detail::concepts {
5856

5957
template <typename X, typename Y, typename Op>
6058
struct op_valid_impl
@@ -115,8 +113,6 @@ BOOST_DECIMAL_HAS_MEMBER_FUNCTION(end)
115113
BOOST_DECIMAL_HAS_MEMBER_FUNCTION(real)
116114
BOOST_DECIMAL_HAS_MEMBER_FUNCTION(imag)
117115

118-
} // Namespace detail
119-
120116
template <typename T>
121117
concept integral = boost::decimal::detail::is_integral_v<T>;
122118

@@ -154,21 +150,21 @@ concept unsigned_arithmetic = arithmetic<T> && std::is_unsigned_v<T>;
154150

155151
template <typename T>
156152
concept arbitrary_unsigned_arithmetic_type = unsigned_arithmetic<T> ||
157-
(detail::op_valid_v<T, T, std::equal_to<>> &&
158-
detail::op_valid_v<T, T, std::not_equal_to<>> &&
159-
detail::op_valid_v<T, T, std::greater<>> &&
160-
detail::op_valid_v<T, T, std::less<>> &&
161-
detail::op_valid_v<T, T, std::greater_equal<>> &&
162-
detail::op_valid_v<T, T, std::less_equal<>> &&
163-
detail::op_valid_v<T, T, std::plus<>> &&
164-
detail::op_valid_v<T, T, std::minus<>> &&
165-
detail::op_valid_v<T, T, std::multiplies<>> &&
166-
detail::op_valid_v<T, T, std::divides<>>);
153+
(op_valid_v<T, T, std::equal_to<>> &&
154+
op_valid_v<T, T, std::not_equal_to<>> &&
155+
op_valid_v<T, T, std::greater<>> &&
156+
op_valid_v<T, T, std::less<>> &&
157+
op_valid_v<T, T, std::greater_equal<>> &&
158+
op_valid_v<T, T, std::less_equal<>> &&
159+
op_valid_v<T, T, std::plus<>> &&
160+
op_valid_v<T, T, std::minus<>> &&
161+
op_valid_v<T, T, std::multiplies<>> &&
162+
op_valid_v<T, T, std::divides<>>);
167163

168164
template <typename T>
169165
concept arbitrary_signed_arithmetic_type = signed_arithmetic<T> ||
170166
(arbitrary_unsigned_arithmetic_type<T> &&
171-
(detail::op_valid_v<T, T, std::negate<>> ||
167+
(op_valid_v<T, T, std::negate<>> ||
172168
std::numeric_limits<T>::is_signed));
173169

174170
template <typename T>
@@ -193,8 +189,8 @@ concept arbitrary_real_type = arbitrary_arithmetic_type<T> &&
193189

194190
template <typename T>
195191
concept arbitrary_complex_type = complex<T> ||
196-
(detail::has_real_v<T> &&
197-
detail::has_imag_v<T>);
192+
(has_real_v<T> &&
193+
has_imag_v<T>);
198194

199195
template <typename T>
200196
concept arbitrary_real_or_complex_type = arbitrary_real_type<T> ||
@@ -222,49 +218,49 @@ concept output_iterator = derived_from<typename std::iterator_traits<I>::iterato
222218
derived_from<typename std::iterator_traits<T>::iterator_category, std::output_iterator_tag>;
223219

224220
template <typename T>
225-
concept is_container = detail::has_begin_v<T> &&
226-
detail::has_end_v<T>;
221+
concept is_container = has_begin_v<T> &&
222+
has_end_v<T>;
227223

228224
template <typename T>
229225
concept random_access_container = is_container<T> &&
230-
boost::decimal::concepts::random_access_iterator<typename T::iterator>;
226+
boost::decimal::detail::concepts::random_access_iterator<typename T::iterator>;
231227

232228
template <typename T>
233229
concept decimal_floating_point_type = boost::decimal::detail::is_decimal_floating_point_v<T>;
234230

235-
} // boost::decimal::concepts
231+
} // boost::decimal::detail::concepts
236232

237233
#define BOOST_DECIMAL_HAS_CONCEPTS 1
238234

239-
#define BOOST_DECIMAL_INTEGRAL boost::decimal::concepts::integral
240-
#define BOOST_DECIMAL_SIGNED_INTEGRAL boost::decimal::concepts::signed_integral
241-
#define BOOST_DECIMAL_UNSIGNED_INTEGRAL boost::decimal::concepts::unsigned_integral
242-
#define BOOST_DECIMAL_REAL boost::decimal::concepts::real
243-
#define BOOST_DECIMAL_COMPLEX boost::decimal::concepts::complex
244-
#define BOOST_DECIMAL_REAL_OR_COMPLEX boost::decimal::concepts::real_or_complex
245-
#define BOOST_DECIMAL_ARITHMETIC boost::decimal::concepts::arithmetic
246-
#define BOOST_DECIMAL_NUMERICAL boost::decimal::concepts::numerical
247-
#define BOOST_DECIMAL_SIGNED_ARITHMETIC boost::decimal::concepts::signed_arithmetic
248-
#define BOOST_DECIMAL_UNSIGNED_ARITHMETIC boost::decimal::concepts::unsigned_arithmetic
249-
#define BOOST_DECIMAL_ARBITRARY_UNSIGNED_ARITHMETIC boost::decimal::concepts::arbitrary_unsigned_arithmetic_type
250-
#define BOOST_DECIMAL_ARBITRARY_SIGNED_ARITHMETIC boost::decimal::concepts::arbitrary_signed_arithmetic_type
251-
#define BOOST_DECIMAL_ARBITRARY_ARITHMETIC boost::decimal::concepts::arbitrary_arithmetic_type
252-
#define BOOST_DECIMAL_ARBITRARY_UNSIGNED_INTEGER boost::decimal::concepts::arbitrary_unsigned_integer_type
253-
#define BOOST_DECIMAL_ARBITRARY_SIGNED_INTEGER boost::decimal::concepts::arbitrary_signed_integer_type
254-
#define BOOST_DECIMAL_ARBITRARY_INTEGER boost::decimal::concepts::arbitrary_integer_type
255-
#define BOOST_DECIMAL_ARBITRARY_REAL boost::decimal::concepts::arbitrary_real_type
256-
#define BOOST_DECIMAL_ARBITRARY_COMPLEX boost::decimal::concepts::arbitrary_complex_type
257-
#define BOOST_DECIMAL_ARBITRARY_REAL_OR_COMPLEX boost::decimal::concepts::arbitrary_real_or_complex_type
258-
#define BOOST_DECIMAL_ARBITRARY_NUMERICAL boost::decimal::concepts::arbitrary_numerical_type
259-
#define BOOST_DECIMAL_DECIMAL_FLOATING_TYPE boost::decimal::concepts::decimal_floating_point_type
260-
261-
#define BOOST_DECIMAL_CONTAINER boost::decimal::concepts::is_container
262-
#define BOOST_DECIMAL_RANDOM_ACCESS_CONTAINER boost::decimal::concepts::random_access_container
263-
264-
#define BOOST_DECIMAL_FORWARD_ITER boost::decimal::concepts::forward_iterator
265-
#define BOOST_DECIMAL_BIDIRECTIONAL_ITER boost::decimal::concepts::bidirectional_iterator
266-
#define BOOST_DECIMAL_RANDOM_ACCESS_ITER boost::decimal::concepts::random_access_iterator
267-
#define BOOST_DECIMAL_OUTPUT_ITER(I, T) boost::decimal::concepts::output_iterator<I, T>
235+
#define BOOST_DECIMAL_INTEGRAL boost::decimal::detail::concepts::integral
236+
#define BOOST_DECIMAL_SIGNED_INTEGRAL boost::decimal::detail::concepts::signed_integral
237+
#define BOOST_DECIMAL_UNSIGNED_INTEGRAL boost::decimal::detail::concepts::unsigned_integral
238+
#define BOOST_DECIMAL_REAL boost::decimal::detail::concepts::real
239+
#define BOOST_DECIMAL_COMPLEX boost::decimal::detail::concepts::complex
240+
#define BOOST_DECIMAL_REAL_OR_COMPLEX boost::decimal::detail::concepts::real_or_complex
241+
#define BOOST_DECIMAL_ARITHMETIC boost::decimal::detail::concepts::arithmetic
242+
#define BOOST_DECIMAL_NUMERICAL boost::decimal::detail::concepts::numerical
243+
#define BOOST_DECIMAL_SIGNED_ARITHMETIC boost::decimal::detail::concepts::signed_arithmetic
244+
#define BOOST_DECIMAL_UNSIGNED_ARITHMETIC boost::decimal::detail::concepts::unsigned_arithmetic
245+
#define BOOST_DECIMAL_ARBITRARY_UNSIGNED_ARITHMETIC boost::decimal::detail::concepts::arbitrary_unsigned_arithmetic_type
246+
#define BOOST_DECIMAL_ARBITRARY_SIGNED_ARITHMETIC boost::decimal::detail::concepts::arbitrary_signed_arithmetic_type
247+
#define BOOST_DECIMAL_ARBITRARY_ARITHMETIC boost::decimal::detail::concepts::arbitrary_arithmetic_type
248+
#define BOOST_DECIMAL_ARBITRARY_UNSIGNED_INTEGER boost::decimal::detail::concepts::arbitrary_unsigned_integer_type
249+
#define BOOST_DECIMAL_ARBITRARY_SIGNED_INTEGER boost::decimal::detail::concepts::arbitrary_signed_integer_type
250+
#define BOOST_DECIMAL_ARBITRARY_INTEGER boost::decimal::detail::concepts::arbitrary_integer_type
251+
#define BOOST_DECIMAL_ARBITRARY_REAL boost::decimal::detail::concepts::arbitrary_real_type
252+
#define BOOST_DECIMAL_ARBITRARY_COMPLEX boost::decimal::detail::concepts::arbitrary_complex_type
253+
#define BOOST_DECIMAL_ARBITRARY_REAL_OR_COMPLEX boost::decimal::detail::concepts::arbitrary_real_or_complex_type
254+
#define BOOST_DECIMAL_ARBITRARY_NUMERICAL boost::decimal::detail::concepts::arbitrary_numerical_type
255+
#define BOOST_DECIMAL_DECIMAL_FLOATING_TYPE boost::decimal::detail::concepts::decimal_floating_point_type
256+
257+
#define BOOST_DECIMAL_CONTAINER boost::decimal::detail::concepts::is_container
258+
#define BOOST_DECIMAL_RANDOM_ACCESS_CONTAINER boost::decimal::detail::concepts::random_access_container
259+
260+
#define BOOST_DECIMAL_FORWARD_ITER boost::decimal::detail::concepts::forward_iterator
261+
#define BOOST_DECIMAL_BIDIRECTIONAL_ITER boost::decimal::detail::concepts::bidirectional_iterator
262+
#define BOOST_DECIMAL_RANDOM_ACCESS_ITER boost::decimal::detail::concepts::random_access_iterator
263+
#define BOOST_DECIMAL_OUTPUT_ITER(I, T) boost::decimal::detail::concepts::output_iterator<I, T>
268264
#define BOOST_DECIMAL_REQUIRES_ITER(X) requires X
269265

270266
#define BOOST_DECIMAL_REQUIRES(X, T) -> T requires X<T>
@@ -276,14 +272,14 @@ concept decimal_floating_point_type = boost::decimal::detail::is_decimal_floatin
276272
#ifdef BOOST_DECIMAL_EXEC_COMPATIBLE
277273
#include <execution>
278274

279-
namespace boost::decimal::concepts {
275+
namespace boost::decimal::detail::concepts {
280276

281277
template <typename T>
282278
concept execution_policy = std::is_execution_policy_v<std::remove_cvref_t<T>>;
283279

284-
} // Namespace boost::decimal::concepts
280+
} // Namespace boost::decimal::detail::concepts
285281

286-
#define BOOST_DECIMAL_EXECUTION_POLICY boost::decimal::concepts::execution_policy
282+
#define BOOST_DECIMAL_EXECUTION_POLICY boost::decimal::detail::concepts::execution_policy
287283

288284
#endif // Has <execution>
289285

include/boost/decimal/format.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ constexpr auto parse_impl(ParseContext &ctx)
105105

106106
namespace std {
107107

108-
template <boost::decimal::concepts::decimal_floating_point_type T>
108+
template <boost::decimal::detail::concepts::decimal_floating_point_type T>
109109
struct formatter<T>
110110
{
111111
constexpr formatter() : ctx_precision(6),

test/test_format.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ using namespace boost::decimal;
1010

1111
#ifdef BOOST_DECIMAL_HAS_FORMAT_SUPPORT
1212

13-
template <concepts::decimal_floating_point_type T>
13+
template <typename T>
1414
void test_general()
1515
{
1616
// For unknown reasons Clang does not like this empty bracket and throws compiler errors
@@ -85,7 +85,7 @@ void test_general()
8585
BOOST_TEST_EQ(std::format("{:G}", -std::numeric_limits<T>::signaling_NaN()), "-NAN(SNAN)");
8686
}
8787

88-
template <concepts::decimal_floating_point_type T>
88+
template <typename T>
8989
void test_fixed()
9090
{
9191
BOOST_TEST_EQ(std::format("{:f}", T {21, 6, true}), "-21000000.000000");
@@ -116,7 +116,7 @@ void test_fixed()
116116
BOOST_TEST_EQ(std::format("{:F}", -std::numeric_limits<T>::signaling_NaN()), "-NAN(SNAN)");
117117
}
118118

119-
template <concepts::decimal_floating_point_type T>
119+
template <typename T>
120120
void test_scientific()
121121
{
122122
BOOST_TEST_EQ(std::format("{:e}", T {21, 6, true}), "-2.100000e+07");
@@ -147,7 +147,7 @@ void test_scientific()
147147
BOOST_TEST_EQ(std::format("{:10.3E}", T {0}), " 0.000E+00");
148148
}
149149

150-
template <concepts::decimal_floating_point_type T>
150+
template <typename T>
151151
void test_hex()
152152
{
153153
BOOST_TEST_EQ(std::format("{:.0a}", T {0}), "0p+00");

0 commit comments

Comments
 (0)