Skip to content

Commit 896401f

Browse files
committed
Disable string constructor when strings are not avilable
1 parent 2f42158 commit 896401f

File tree

6 files changed

+59
-0
lines changed

6 files changed

+59
-0
lines changed

include/boost/decimal/decimal128_t.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ BOOST_DECIMAL_EXPORT class decimal128_t final
205205
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
206206
friend constexpr auto detail::to_chars_hex_impl(char* first, char* last, const TargetDecimalType& value) noexcept -> to_chars_result;
207207

208+
#if !defined(BOOST_DECIMAL_DISABLE_CLIB)
208209
constexpr decimal128_t(const char* str, std::size_t len);
210+
#endif
209211

210212
public:
211213
// 3.2.4.1 construct/copy/destroy
@@ -278,6 +280,8 @@ BOOST_DECIMAL_EXPORT class decimal128_t final
278280

279281
explicit constexpr decimal128_t(bool value) noexcept;
280282

283+
#if !defined(BOOST_DECIMAL_DISABLE_CLIB)
284+
281285
explicit constexpr decimal128_t(const char* str);
282286

283287
#ifndef BOOST_DECIMAL_HAS_STD_STRING_VIEW
@@ -286,6 +290,8 @@ BOOST_DECIMAL_EXPORT class decimal128_t final
286290
explicit constexpr decimal128_t(std::string_view str);
287291
#endif
288292

293+
#endif
294+
289295
// 3.2.4.4 Conversion to integral type
290296
explicit constexpr operator bool() const noexcept;
291297
explicit constexpr operator int() const noexcept;
@@ -901,6 +907,8 @@ constexpr decimal128_t::decimal128_t(const Decimal val) noexcept
901907
*this = to_decimal<decimal128_t>(val);
902908
}
903909

910+
#if !defined(BOOST_DECIMAL_DISABLE_CLIB)
911+
904912
constexpr decimal128_t::decimal128_t(const char* str, std::size_t len)
905913
{
906914
if (str == nullptr || len == 0)
@@ -938,6 +946,8 @@ inline decimal128_t::decimal128_t(const std::string& str) : decimal128_t(str.c_s
938946
constexpr decimal128_t::decimal128_t(std::string_view str) : decimal128_t(str.data(), str.size()) {}
939947
#endif
940948

949+
#endif // BOOST_DECIMAL_DISABLE_CLIB
950+
941951
constexpr decimal128_t::operator bool() const noexcept
942952
{
943953
constexpr decimal128_t zero {0, 0};

include/boost/decimal/decimal32_t.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ BOOST_DECIMAL_EXPORT class decimal32_t final // NOLINT(cppcoreguidelines-special
215215
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
216216
friend constexpr auto detail::to_chars_hex_impl(char* first, char* last, const TargetDecimalType& value) noexcept -> to_chars_result;
217217

218+
#if !defined(BOOST_DECIMAL_DISABLE_CLIB)
218219
constexpr decimal32_t(const char* str, std::size_t len);
220+
#endif
219221

220222
public:
221223
// 3.2.2.1 construct/copy/destroy:
@@ -306,12 +308,16 @@ BOOST_DECIMAL_EXPORT class decimal32_t final // NOLINT(cppcoreguidelines-special
306308

307309
explicit constexpr decimal32_t(const char* str);
308310

311+
#if !defined(BOOST_DECIMAL_DISABLE_CLIB)
312+
309313
#ifndef BOOST_DECIMAL_HAS_STD_STRING_VIEW
310314
explicit inline decimal32_t(const std::string& str);
311315
#else
312316
explicit constexpr decimal32_t(std::string_view str);
313317
#endif
314318

319+
#endif
320+
315321
constexpr decimal32_t(const decimal32_t& val) noexcept = default;
316322
constexpr decimal32_t(decimal32_t&& val) noexcept = default;
317323
constexpr auto operator=(const decimal32_t& val) noexcept -> decimal32_t& = default;
@@ -738,6 +744,8 @@ constexpr decimal32_t::decimal32_t(const T1 coeff, const T2 exp) noexcept : deci
738744

739745
constexpr decimal32_t::decimal32_t(const bool value) noexcept : decimal32_t(static_cast<significand_type>(value), 0, false) {}
740746

747+
#if !defined(BOOST_DECIMAL_DISABLE_CLIB)
748+
741749
constexpr decimal32_t::decimal32_t(const char* str, const std::size_t len)
742750
{
743751
if (str == nullptr || len == 0)
@@ -775,6 +783,8 @@ inline decimal32_t::decimal32_t(const std::string& str) : decimal32_t(str.c_str(
775783
constexpr decimal32_t::decimal32_t(std::string_view str) : decimal32_t(str.data(), str.size()) {}
776784
#endif
777785

786+
#endif // BOOST_DECIMAL_DISABLE_CLIB
787+
778788
constexpr auto from_bits(const std::uint32_t bits) noexcept -> decimal32_t
779789
{
780790
decimal32_t result;

include/boost/decimal/decimal64_t.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ BOOST_DECIMAL_EXPORT class decimal64_t final
223223
template <bool checked, BOOST_DECIMAL_DECIMAL_FLOATING_TYPE T>
224224
friend constexpr auto detail::d64_fma_impl(T x, T y, T z) noexcept -> T;
225225

226+
#if !defined(BOOST_DECIMAL_DISABLE_CLIB)
226227
constexpr decimal64_t(const char* str, std::size_t len);
228+
#endif
227229

228230
public:
229231
// 3.2.3.1 construct/copy/destroy
@@ -341,6 +343,8 @@ BOOST_DECIMAL_EXPORT class decimal64_t final
341343

342344
explicit constexpr decimal64_t(bool value) noexcept;
343345

346+
#if !defined(BOOST_DECIMAL_DISABLE_CLIB)
347+
344348
explicit constexpr decimal64_t(const char* str);
345349

346350
#ifndef BOOST_DECIMAL_HAS_STD_STRING_VIEW
@@ -349,6 +353,8 @@ BOOST_DECIMAL_EXPORT class decimal64_t final
349353
explicit constexpr decimal64_t(std::string_view str);
350354
#endif
351355

356+
#endif
357+
352358
// cmath functions that are easier as friends
353359
friend constexpr auto signbit BOOST_DECIMAL_PREVENT_MACRO_SUBSTITUTION (decimal64_t rhs) noexcept -> bool;
354360
friend constexpr auto isnan BOOST_DECIMAL_PREVENT_MACRO_SUBSTITUTION (decimal64_t rhs) noexcept -> bool;
@@ -814,6 +820,7 @@ constexpr auto decimal64_t::operator=(const Integer& val) noexcept
814820
return *this;
815821
}
816822

823+
#if !defined(BOOST_DECIMAL_DISABLE_CLIB)
817824
constexpr decimal64_t::decimal64_t(const char* str, std::size_t len)
818825
{
819826
if (str == nullptr || len == 0)
@@ -851,6 +858,8 @@ inline decimal64_t::decimal64_t(const std::string& str) : decimal64_t(str.c_str(
851858
constexpr decimal64_t::decimal64_t(std::string_view str) : decimal64_t(str.data(), str.size()) {}
852859
#endif
853860

861+
#endif // BOOST_DECIMAL_DISABLE_CLIB
862+
854863
constexpr decimal64_t::operator bool() const noexcept
855864
{
856865
constexpr decimal64_t zero {0, 0};

include/boost/decimal/decimal_fast128_t.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ BOOST_DECIMAL_EXPORT class decimal_fast128_t final
185185
template <BOOST_DECIMAL_DECIMAL_FLOATING_TYPE TargetDecimalType>
186186
friend constexpr auto detail::to_chars_hex_impl(char* first, char* last, const TargetDecimalType& value) noexcept -> to_chars_result;
187187

188+
#if !defined(BOOST_DECIMAL_DISABLE_CLIB)
188189
constexpr decimal_fast128_t(const char* str, std::size_t len);
190+
#endif
189191

190192
public:
191193
constexpr decimal_fast128_t() noexcept = default;
@@ -239,6 +241,8 @@ BOOST_DECIMAL_EXPORT class decimal_fast128_t final
239241

240242
friend constexpr auto direct_init_d128(significand_type significand, exponent_type exponent, bool sign) noexcept -> decimal_fast128_t;
241243

244+
#if !defined(BOOST_DECIMAL_DISABLE_CLIB)
245+
242246
constexpr decimal_fast128_t(const char* str);
243247

244248
#ifndef BOOST_DECIMAL_HAS_STD_STRING_VIEW
@@ -247,6 +251,8 @@ BOOST_DECIMAL_EXPORT class decimal_fast128_t final
247251
explicit constexpr decimal_fast128_t(std::string_view str);
248252
#endif
249253

254+
#endif // BOOST_DECIMAL_DISABLE_CLIB
255+
250256
// Classification functions
251257
friend constexpr auto signbit(const decimal_fast128_t& val) noexcept -> bool;
252258
friend constexpr auto isinf(const decimal_fast128_t& val) noexcept -> bool;
@@ -558,6 +564,8 @@ constexpr auto direct_init_d128(const decimal_fast128_t::significand_type signif
558564
return val;
559565
}
560566

567+
#if !defined(BOOST_DECIMAL_DISABLE_CLIB)
568+
561569
constexpr decimal_fast128_t::decimal_fast128_t(const char* str, const std::size_t len)
562570
{
563571
if (str == nullptr || len == 0)
@@ -595,6 +603,8 @@ inline decimal_fast128_t::decimal_fast128_t(const std::string& str) : decimal_fa
595603
constexpr decimal_fast128_t::decimal_fast128_t(std::string_view str) : decimal_fast128_t(str.data(), str.size()) {}
596604
#endif
597605

606+
#endif // BOOST_DECIMAL_DISABLE_CLIB
607+
598608
constexpr auto signbit(const decimal_fast128_t& val) noexcept -> bool
599609
{
600610
return val.sign_;

include/boost/decimal/decimal_fast32_t.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ BOOST_DECIMAL_EXPORT class decimal_fast32_t final
185185
template <typename DecimalType, typename T>
186186
friend constexpr auto detail::generic_div_impl(const T& lhs, const T& rhs) noexcept -> DecimalType;
187187

188+
#if !defined(BOOST_DECIMAL_DISABLE_CLIB)
188189
constexpr decimal_fast32_t(const char* str, std::size_t len);
190+
#endif
189191

190192
public:
191193
constexpr decimal_fast32_t() noexcept = default;
@@ -217,6 +219,8 @@ BOOST_DECIMAL_EXPORT class decimal_fast32_t final
217219
explicit constexpr decimal_fast32_t(long double val) noexcept = delete;
218220
#endif
219221

222+
#if !defined(BOOST_DECIMAL_DISABLE_CLIB)
223+
220224
explicit constexpr decimal_fast32_t(const char* str);
221225

222226
#ifndef BOOST_DECIMAL_HAS_STD_STRING_VIEW
@@ -225,6 +229,8 @@ BOOST_DECIMAL_EXPORT class decimal_fast32_t final
225229
explicit constexpr decimal_fast32_t(std::string_view str);
226230
#endif
227231

232+
#endif // BOOST_DECIMAL_DISABLE_CLIB
233+
228234
constexpr decimal_fast32_t(const decimal_fast32_t& val) noexcept = default;
229235
constexpr decimal_fast32_t(decimal_fast32_t&& val) noexcept = default;
230236
constexpr auto operator=(const decimal_fast32_t& val) noexcept -> decimal_fast32_t& = default;
@@ -550,6 +556,8 @@ constexpr auto direct_init(const detail::decimal_fast32_t_components& x) noexcep
550556
return val;
551557
}
552558

559+
#if !defined(BOOST_DECIMAL_DISABLE_CLIB)
560+
553561
constexpr decimal_fast32_t::decimal_fast32_t(const char* str, const std::size_t len)
554562
{
555563
if (str == nullptr || len == 0)
@@ -587,6 +595,8 @@ inline decimal_fast32_t::decimal_fast32_t(const std::string& str) : decimal_fast
587595
constexpr decimal_fast32_t::decimal_fast32_t(std::string_view str) : decimal_fast32_t(str.data(), str.size()) {}
588596
#endif
589597

598+
#endif // BOOST_DECIMAL_DISABLE_CLIB
599+
590600
constexpr auto signbit(const decimal_fast32_t val) noexcept -> bool
591601
{
592602
return val.sign_;

include/boost/decimal/decimal_fast64_t.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ BOOST_DECIMAL_EXPORT class decimal_fast64_t final
192192
template <bool checked, BOOST_DECIMAL_DECIMAL_FLOATING_TYPE T>
193193
friend constexpr auto detail::d64_fma_impl(T x, T y, T z) noexcept -> T;
194194

195+
#if !defined(BOOST_DECIMAL_DISABLE_CLIB)
195196
constexpr decimal_fast64_t(const char* str, std::size_t len);
197+
#endif
196198

197199
public:
198200
constexpr decimal_fast64_t() noexcept = default;
@@ -246,6 +248,8 @@ BOOST_DECIMAL_EXPORT class decimal_fast64_t final
246248

247249
friend constexpr auto direct_init_d64(decimal_fast64_t::significand_type significand, decimal_fast64_t::exponent_type exponent, bool sign) noexcept -> decimal_fast64_t;
248250

251+
#if !defined(BOOST_DECIMAL_DISABLE_CLIB)
252+
249253
explicit constexpr decimal_fast64_t(const char* str);
250254

251255
#ifndef BOOST_DECIMAL_HAS_STD_STRING_VIEW
@@ -254,6 +258,8 @@ BOOST_DECIMAL_EXPORT class decimal_fast64_t final
254258
explicit constexpr decimal_fast64_t(std::string_view str);
255259
#endif
256260

261+
#endif // BOOST_DECIMAL_DISABLE_CLIB
262+
257263
// Classification functions
258264
friend constexpr auto signbit(decimal_fast64_t val) noexcept -> bool;
259265
friend constexpr auto isinf(decimal_fast64_t val) noexcept -> bool;
@@ -557,6 +563,8 @@ constexpr auto direct_init_d64(const decimal_fast64_t::significand_type signific
557563
return val;
558564
}
559565

566+
#if !defined(BOOST_DECIMAL_DISABLE_CLIB)
567+
560568
constexpr decimal_fast64_t::decimal_fast64_t(const char* str, const std::size_t len)
561569
{
562570
if (str == nullptr || len == 0)
@@ -594,6 +602,8 @@ inline decimal_fast64_t::decimal_fast64_t(const std::string& str) : decimal_fast
594602
constexpr decimal_fast64_t::decimal_fast64_t(std::string_view str) : decimal_fast64_t(str.data(), str.size()) {}
595603
#endif
596604

605+
#endif // BOOST_DECIMAL_DISABLE_CLIB
606+
597607
constexpr auto signbit(const decimal_fast64_t val) noexcept -> bool
598608
{
599609
return val.sign_;

0 commit comments

Comments
 (0)