From 52e2d49380aea26c702eaa51f15ba813f2e9c21d Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Fri, 31 Jan 2025 08:53:18 -0500 Subject: [PATCH] Move concepts into detail namespace --- include/boost/decimal/detail/concepts.hpp | 104 +++++++++++----------- include/boost/decimal/format.hpp | 2 +- test/test_format.cpp | 8 +- 3 files changed, 55 insertions(+), 59 deletions(-) diff --git a/include/boost/decimal/detail/concepts.hpp b/include/boost/decimal/detail/concepts.hpp index 5961969d4..166341562 100644 --- a/include/boost/decimal/detail/concepts.hpp +++ b/include/boost/decimal/detail/concepts.hpp @@ -52,9 +52,7 @@ #include #endif -namespace boost::decimal::concepts { - -namespace detail { +namespace boost::decimal::detail::concepts { template struct op_valid_impl @@ -115,8 +113,6 @@ BOOST_DECIMAL_HAS_MEMBER_FUNCTION(end) BOOST_DECIMAL_HAS_MEMBER_FUNCTION(real) BOOST_DECIMAL_HAS_MEMBER_FUNCTION(imag) -} // Namespace detail - template concept integral = boost::decimal::detail::is_integral_v; @@ -154,21 +150,21 @@ concept unsigned_arithmetic = arithmetic && std::is_unsigned_v; template concept arbitrary_unsigned_arithmetic_type = unsigned_arithmetic || - (detail::op_valid_v> && - detail::op_valid_v> && - detail::op_valid_v> && - detail::op_valid_v> && - detail::op_valid_v> && - detail::op_valid_v> && - detail::op_valid_v> && - detail::op_valid_v> && - detail::op_valid_v> && - detail::op_valid_v>); + (op_valid_v> && + op_valid_v> && + op_valid_v> && + op_valid_v> && + op_valid_v> && + op_valid_v> && + op_valid_v> && + op_valid_v> && + op_valid_v> && + op_valid_v>); template concept arbitrary_signed_arithmetic_type = signed_arithmetic || (arbitrary_unsigned_arithmetic_type && - (detail::op_valid_v> || + (op_valid_v> || std::numeric_limits::is_signed)); template @@ -193,8 +189,8 @@ concept arbitrary_real_type = arbitrary_arithmetic_type && template concept arbitrary_complex_type = complex || - (detail::has_real_v && - detail::has_imag_v); + (has_real_v && + has_imag_v); template concept arbitrary_real_or_complex_type = arbitrary_real_type || @@ -222,49 +218,49 @@ concept output_iterator = derived_from::iterato derived_from::iterator_category, std::output_iterator_tag>; template -concept is_container = detail::has_begin_v && - detail::has_end_v; +concept is_container = has_begin_v && + has_end_v; template concept random_access_container = is_container && - boost::decimal::concepts::random_access_iterator; + boost::decimal::detail::concepts::random_access_iterator; template concept decimal_floating_point_type = boost::decimal::detail::is_decimal_floating_point_v; -} // boost::decimal::concepts +} // boost::decimal::detail::concepts #define BOOST_DECIMAL_HAS_CONCEPTS 1 -#define BOOST_DECIMAL_INTEGRAL boost::decimal::concepts::integral -#define BOOST_DECIMAL_SIGNED_INTEGRAL boost::decimal::concepts::signed_integral -#define BOOST_DECIMAL_UNSIGNED_INTEGRAL boost::decimal::concepts::unsigned_integral -#define BOOST_DECIMAL_REAL boost::decimal::concepts::real -#define BOOST_DECIMAL_COMPLEX boost::decimal::concepts::complex -#define BOOST_DECIMAL_REAL_OR_COMPLEX boost::decimal::concepts::real_or_complex -#define BOOST_DECIMAL_ARITHMETIC boost::decimal::concepts::arithmetic -#define BOOST_DECIMAL_NUMERICAL boost::decimal::concepts::numerical -#define BOOST_DECIMAL_SIGNED_ARITHMETIC boost::decimal::concepts::signed_arithmetic -#define BOOST_DECIMAL_UNSIGNED_ARITHMETIC boost::decimal::concepts::unsigned_arithmetic -#define BOOST_DECIMAL_ARBITRARY_UNSIGNED_ARITHMETIC boost::decimal::concepts::arbitrary_unsigned_arithmetic_type -#define BOOST_DECIMAL_ARBITRARY_SIGNED_ARITHMETIC boost::decimal::concepts::arbitrary_signed_arithmetic_type -#define BOOST_DECIMAL_ARBITRARY_ARITHMETIC boost::decimal::concepts::arbitrary_arithmetic_type -#define BOOST_DECIMAL_ARBITRARY_UNSIGNED_INTEGER boost::decimal::concepts::arbitrary_unsigned_integer_type -#define BOOST_DECIMAL_ARBITRARY_SIGNED_INTEGER boost::decimal::concepts::arbitrary_signed_integer_type -#define BOOST_DECIMAL_ARBITRARY_INTEGER boost::decimal::concepts::arbitrary_integer_type -#define BOOST_DECIMAL_ARBITRARY_REAL boost::decimal::concepts::arbitrary_real_type -#define BOOST_DECIMAL_ARBITRARY_COMPLEX boost::decimal::concepts::arbitrary_complex_type -#define BOOST_DECIMAL_ARBITRARY_REAL_OR_COMPLEX boost::decimal::concepts::arbitrary_real_or_complex_type -#define BOOST_DECIMAL_ARBITRARY_NUMERICAL boost::decimal::concepts::arbitrary_numerical_type -#define BOOST_DECIMAL_DECIMAL_FLOATING_TYPE boost::decimal::concepts::decimal_floating_point_type - -#define BOOST_DECIMAL_CONTAINER boost::decimal::concepts::is_container -#define BOOST_DECIMAL_RANDOM_ACCESS_CONTAINER boost::decimal::concepts::random_access_container - -#define BOOST_DECIMAL_FORWARD_ITER boost::decimal::concepts::forward_iterator -#define BOOST_DECIMAL_BIDIRECTIONAL_ITER boost::decimal::concepts::bidirectional_iterator -#define BOOST_DECIMAL_RANDOM_ACCESS_ITER boost::decimal::concepts::random_access_iterator -#define BOOST_DECIMAL_OUTPUT_ITER(I, T) boost::decimal::concepts::output_iterator +#define BOOST_DECIMAL_INTEGRAL boost::decimal::detail::concepts::integral +#define BOOST_DECIMAL_SIGNED_INTEGRAL boost::decimal::detail::concepts::signed_integral +#define BOOST_DECIMAL_UNSIGNED_INTEGRAL boost::decimal::detail::concepts::unsigned_integral +#define BOOST_DECIMAL_REAL boost::decimal::detail::concepts::real +#define BOOST_DECIMAL_COMPLEX boost::decimal::detail::concepts::complex +#define BOOST_DECIMAL_REAL_OR_COMPLEX boost::decimal::detail::concepts::real_or_complex +#define BOOST_DECIMAL_ARITHMETIC boost::decimal::detail::concepts::arithmetic +#define BOOST_DECIMAL_NUMERICAL boost::decimal::detail::concepts::numerical +#define BOOST_DECIMAL_SIGNED_ARITHMETIC boost::decimal::detail::concepts::signed_arithmetic +#define BOOST_DECIMAL_UNSIGNED_ARITHMETIC boost::decimal::detail::concepts::unsigned_arithmetic +#define BOOST_DECIMAL_ARBITRARY_UNSIGNED_ARITHMETIC boost::decimal::detail::concepts::arbitrary_unsigned_arithmetic_type +#define BOOST_DECIMAL_ARBITRARY_SIGNED_ARITHMETIC boost::decimal::detail::concepts::arbitrary_signed_arithmetic_type +#define BOOST_DECIMAL_ARBITRARY_ARITHMETIC boost::decimal::detail::concepts::arbitrary_arithmetic_type +#define BOOST_DECIMAL_ARBITRARY_UNSIGNED_INTEGER boost::decimal::detail::concepts::arbitrary_unsigned_integer_type +#define BOOST_DECIMAL_ARBITRARY_SIGNED_INTEGER boost::decimal::detail::concepts::arbitrary_signed_integer_type +#define BOOST_DECIMAL_ARBITRARY_INTEGER boost::decimal::detail::concepts::arbitrary_integer_type +#define BOOST_DECIMAL_ARBITRARY_REAL boost::decimal::detail::concepts::arbitrary_real_type +#define BOOST_DECIMAL_ARBITRARY_COMPLEX boost::decimal::detail::concepts::arbitrary_complex_type +#define BOOST_DECIMAL_ARBITRARY_REAL_OR_COMPLEX boost::decimal::detail::concepts::arbitrary_real_or_complex_type +#define BOOST_DECIMAL_ARBITRARY_NUMERICAL boost::decimal::detail::concepts::arbitrary_numerical_type +#define BOOST_DECIMAL_DECIMAL_FLOATING_TYPE boost::decimal::detail::concepts::decimal_floating_point_type + +#define BOOST_DECIMAL_CONTAINER boost::decimal::detail::concepts::is_container +#define BOOST_DECIMAL_RANDOM_ACCESS_CONTAINER boost::decimal::detail::concepts::random_access_container + +#define BOOST_DECIMAL_FORWARD_ITER boost::decimal::detail::concepts::forward_iterator +#define BOOST_DECIMAL_BIDIRECTIONAL_ITER boost::decimal::detail::concepts::bidirectional_iterator +#define BOOST_DECIMAL_RANDOM_ACCESS_ITER boost::decimal::detail::concepts::random_access_iterator +#define BOOST_DECIMAL_OUTPUT_ITER(I, T) boost::decimal::detail::concepts::output_iterator #define BOOST_DECIMAL_REQUIRES_ITER(X) requires X #define BOOST_DECIMAL_REQUIRES(X, T) -> T requires X @@ -276,14 +272,14 @@ concept decimal_floating_point_type = boost::decimal::detail::is_decimal_floatin #ifdef BOOST_DECIMAL_EXEC_COMPATIBLE #include -namespace boost::decimal::concepts { +namespace boost::decimal::detail::concepts { template concept execution_policy = std::is_execution_policy_v>; -} // Namespace boost::decimal::concepts +} // Namespace boost::decimal::detail::concepts -#define BOOST_DECIMAL_EXECUTION_POLICY boost::decimal::concepts::execution_policy +#define BOOST_DECIMAL_EXECUTION_POLICY boost::decimal::detail::concepts::execution_policy #endif // Has diff --git a/include/boost/decimal/format.hpp b/include/boost/decimal/format.hpp index 6ecd2306e..102aa29fc 100644 --- a/include/boost/decimal/format.hpp +++ b/include/boost/decimal/format.hpp @@ -105,7 +105,7 @@ constexpr auto parse_impl(ParseContext &ctx) namespace std { -template +template struct formatter { constexpr formatter() : ctx_precision(6), diff --git a/test/test_format.cpp b/test/test_format.cpp index 2cde83a59..9fe2452e6 100644 --- a/test/test_format.cpp +++ b/test/test_format.cpp @@ -10,7 +10,7 @@ using namespace boost::decimal; #ifdef BOOST_DECIMAL_HAS_FORMAT_SUPPORT -template +template void test_general() { // For unknown reasons Clang does not like this empty bracket and throws compiler errors @@ -85,7 +85,7 @@ void test_general() BOOST_TEST_EQ(std::format("{:G}", -std::numeric_limits::signaling_NaN()), "-NAN(SNAN)"); } -template +template void test_fixed() { BOOST_TEST_EQ(std::format("{:f}", T {21, 6, true}), "-21000000.000000"); @@ -116,7 +116,7 @@ void test_fixed() BOOST_TEST_EQ(std::format("{:F}", -std::numeric_limits::signaling_NaN()), "-NAN(SNAN)"); } -template +template void test_scientific() { BOOST_TEST_EQ(std::format("{:e}", T {21, 6, true}), "-2.100000e+07"); @@ -147,7 +147,7 @@ void test_scientific() BOOST_TEST_EQ(std::format("{:10.3E}", T {0}), " 0.000E+00"); } -template +template void test_hex() { BOOST_TEST_EQ(std::format("{:.0a}", T {0}), "0p+00");