Skip to content

Commit 6ede201

Browse files
committed
Change signature to avoid making fast type friends
1 parent 8124648 commit 6ede201

File tree

4 files changed

+29
-15
lines changed

4 files changed

+29
-15
lines changed

include/boost/decimal/charconv.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,8 +1109,9 @@ constexpr auto to_chars_hex_impl(char* first, char* last, const TargetDecimalTyp
11091109
return to_chars_integer_impl<std::uint32_t>(first, last, static_cast<std::uint32_t>(abs_exp));
11101110
}
11111111

1112-
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
1113-
constexpr auto to_chars_cohort_preserving_scientific(char* first, char* last, const TargetDecimalType& value) noexcept -> to_chars_result
1112+
template <typename TargetDecimalType>
1113+
constexpr auto to_chars_cohort_preserving_scientific(char* first, char* last, const TargetDecimalType& value) noexcept
1114+
BOOST_DECIMAL_REQUIRES_RETURN(is_ieee_type_v, TargetDecimalType, to_chars_result)
11141115
{
11151116
using unsigned_integer = typename TargetDecimalType::significand_type;
11161117

@@ -1170,6 +1171,13 @@ constexpr auto to_chars_cohort_preserving_scientific(char* first, char* last, co
11701171
return to_chars_integer_impl<std::uint32_t>(first, last, abs_exp);
11711172
}
11721173

1174+
template <typename TargetDecimalType>
1175+
constexpr auto to_chars_cohort_preserving_scientific(char*, char* last, const TargetDecimalType&) noexcept
1176+
BOOST_DECIMAL_REQUIRES_RETURN(!is_ieee_type_v, TargetDecimalType, to_chars_result)
1177+
{
1178+
return {last, std::errc::invalid_argument};
1179+
}
1180+
11731181
#ifdef _MSC_VER
11741182
# pragma warning(push)
11751183
# pragma warning(disable: 4702) // Unreachable code

include/boost/decimal/decimal128_t.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,9 @@ constexpr auto to_chars_fixed_impl(char* first, char* last, const TargetDecimalT
9898
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
9999
constexpr auto to_chars_hex_impl(char* first, char* last, const TargetDecimalType& value) noexcept -> to_chars_result;
100100

101-
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
102-
constexpr auto to_chars_cohort_preserving_scientific(char* first, char* last, const TargetDecimalType& value) noexcept -> to_chars_result;
101+
template <typename TargetDecimalType>
102+
constexpr auto to_chars_cohort_preserving_scientific(char* first, char* last, const TargetDecimalType& value) noexcept
103+
BOOST_DECIMAL_REQUIRES_RETURN(is_ieee_type_v, TargetDecimalType, to_chars_result);
103104

104105
} //namespace detail
105106

@@ -207,9 +208,10 @@ BOOST_DECIMAL_EXPORT class decimal128_t final
207208

208209
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
209210
friend constexpr auto detail::to_chars_hex_impl(char* first, char* last, const TargetDecimalType& value) noexcept -> to_chars_result;
210-
211-
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
212-
friend constexpr auto detail::to_chars_cohort_preserving_scientific(char* first, char* last, const TargetDecimalType& value) noexcept -> to_chars_result;
211+
212+
template <typename TargetDecimalType>
213+
friend constexpr auto detail::to_chars_cohort_preserving_scientific(char* first, char* last, const TargetDecimalType& value) noexcept
214+
BOOST_DECIMAL_REQUIRES_RETURN(detail::is_ieee_type_v, TargetDecimalType, to_chars_result);
213215

214216
#if !defined(BOOST_DECIMAL_DISABLE_CLIB)
215217
constexpr decimal128_t(const char* str, std::size_t len);

include/boost/decimal/decimal32_t.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ constexpr auto to_chars_fixed_impl(char* first, char* last, const TargetDecimalT
102102
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
103103
constexpr auto to_chars_hex_impl(char* first, char* last, const TargetDecimalType& value) noexcept -> to_chars_result;
104104

105-
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
106-
constexpr auto to_chars_cohort_preserving_scientific(char* first, char* last, const TargetDecimalType& value) noexcept -> to_chars_result;
105+
template <typename TargetDecimalType>
106+
constexpr auto to_chars_cohort_preserving_scientific(char* first, char* last, const TargetDecimalType& value) noexcept
107+
BOOST_DECIMAL_REQUIRES_RETURN(is_ieee_type_v, TargetDecimalType, to_chars_result);
107108

108109
template <bool checked, BOOST_DECIMAL_DECIMAL_FLOATING_TYPE T>
109110
constexpr auto d32_fma_impl(T x, T y, T z) noexcept -> T;
@@ -218,8 +219,9 @@ BOOST_DECIMAL_EXPORT class decimal32_t final // NOLINT(cppcoreguidelines-special
218219
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
219220
friend constexpr auto detail::to_chars_hex_impl(char* first, char* last, const TargetDecimalType& value) noexcept -> to_chars_result;
220221

221-
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
222-
friend constexpr auto detail::to_chars_cohort_preserving_scientific(char* first, char* last, const TargetDecimalType& value) noexcept -> to_chars_result;
222+
template <typename TargetDecimalType>
223+
friend constexpr auto detail::to_chars_cohort_preserving_scientific(char* first, char* last, const TargetDecimalType& value) noexcept
224+
BOOST_DECIMAL_REQUIRES_RETURN(detail::is_ieee_type_v, TargetDecimalType, to_chars_result);
223225

224226
#if !defined(BOOST_DECIMAL_DISABLE_CLIB)
225227
constexpr decimal32_t(const char* str, std::size_t len);

include/boost/decimal/decimal64_t.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ constexpr auto to_chars_fixed_impl(char* first, char* last, const TargetDecimalT
101101
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
102102
constexpr auto to_chars_hex_impl(char* first, char* last, const TargetDecimalType& value) noexcept -> to_chars_result;
103103

104-
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
105-
constexpr auto to_chars_cohort_preserving_scientific(char* first, char* last, const TargetDecimalType& value) noexcept -> to_chars_result;
104+
template <typename TargetDecimalType>
105+
constexpr auto to_chars_cohort_preserving_scientific(char* first, char* last, const TargetDecimalType& value) noexcept
106+
BOOST_DECIMAL_REQUIRES_RETURN(is_ieee_type_v, TargetDecimalType, to_chars_result);
106107

107108
template <bool checked, BOOST_DECIMAL_DECIMAL_FLOATING_TYPE T>
108109
constexpr auto d64_fma_impl(T x, T y, T z) noexcept -> T;
@@ -223,8 +224,9 @@ BOOST_DECIMAL_EXPORT class decimal64_t final
223224
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
224225
friend constexpr auto detail::to_chars_hex_impl(char* first, char* last, const TargetDecimalType& value) noexcept -> to_chars_result;
225226

226-
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
227-
friend constexpr auto detail::to_chars_cohort_preserving_scientific(char* first, char* last, const TargetDecimalType& value) noexcept -> to_chars_result;
227+
template <typename TargetDecimalType>
228+
friend constexpr auto detail::to_chars_cohort_preserving_scientific(char* first, char* last, const TargetDecimalType& value) noexcept
229+
BOOST_DECIMAL_REQUIRES_RETURN(detail::is_ieee_type_v, TargetDecimalType, to_chars_result);
228230

229231
template <bool checked, BOOST_DECIMAL_DECIMAL_FLOATING_TYPE T>
230232
friend constexpr auto detail::d64_fma_impl(T x, T y, T z) noexcept -> T;

0 commit comments

Comments
 (0)