Skip to content

Commit 9de5528

Browse files
committed
Default to explicit conversions for integer
1 parent e2d2e2a commit 9de5528

File tree

6 files changed

+33
-6
lines changed

6 files changed

+33
-6
lines changed

include/boost/decimal/decimal128_t.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ BOOST_DECIMAL_EXPORT class decimal128_t final
218218
#else
219219
template <typename Float, std::enable_if_t<detail::is_floating_point_v<Float>, bool> = true>
220220
#endif
221-
#ifndef BOOST_DECIMAL_ALLOW_IMPLICIT_CONVERSIONS
221+
#if !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_CONVERSIONS) && !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_FLOAT_CONVERSIONS)
222222
explicit
223223
#endif
224224
BOOST_DECIMAL_CXX20_CONSTEXPR decimal128_t(Float val) noexcept;
@@ -243,6 +243,9 @@ BOOST_DECIMAL_EXPORT class decimal128_t final
243243
#else
244244
template <typename Integer, std::enable_if_t<detail::is_integral_v<Integer>, bool> = true>
245245
#endif
246+
#if !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_CONVERSIONS) && !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_INTEGER_CONVERSIONS)
247+
explicit
248+
#endif
246249
constexpr decimal128_t(Integer val) noexcept;
247250

248251
template <typename Integer>

include/boost/decimal/decimal32_t.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ BOOST_DECIMAL_EXPORT class decimal32_t final // NOLINT(cppcoreguidelines-special
224224
#else
225225
template <typename Float, std::enable_if_t<detail::is_floating_point_v<Float>, bool> = true>
226226
#endif
227-
#ifndef BOOST_DECIMAL_ALLOW_IMPLICIT_CONVERSIONS
227+
#if !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_CONVERSIONS) && !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_FLOAT_CONVERSIONS)
228228
explicit
229229
#endif
230230
BOOST_DECIMAL_CXX20_CONSTEXPR decimal32_t(Float val) noexcept;
@@ -250,6 +250,9 @@ BOOST_DECIMAL_EXPORT class decimal32_t final // NOLINT(cppcoreguidelines-special
250250
#else
251251
template <BOOST_DECIMAL_INTEGRAL Integer, std::enable_if_t<detail::is_integral_v<Integer>, bool> = true>
252252
#endif
253+
#if !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_CONVERSIONS) && !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_INTEGER_CONVERSIONS)
254+
explicit
255+
#endif
253256
constexpr decimal32_t(Integer val) noexcept;
254257

255258
template <typename Integer>

include/boost/decimal/decimal64_t.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ BOOST_DECIMAL_EXPORT class decimal64_t final
236236
#else
237237
template <typename Float, std::enable_if_t<detail::is_floating_point_v<Float>, bool> = true>
238238
#endif
239-
#ifndef BOOST_DECIMAL_ALLOW_IMPLICIT_CONVERSIONS
239+
#if !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_CONVERSIONS) && !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_FLOAT_CONVERSIONS)
240240
explicit
241241
#endif
242242
BOOST_DECIMAL_CXX20_CONSTEXPR decimal64_t(Float val) noexcept;
@@ -262,6 +262,9 @@ BOOST_DECIMAL_EXPORT class decimal64_t final
262262
#else
263263
template <typename Integer, std::enable_if_t<detail::is_integral_v<Integer>, bool> = true>
264264
#endif
265+
#if !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_CONVERSIONS) && !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_INTEGER_CONVERSIONS)
266+
explicit
267+
#endif
265268
constexpr decimal64_t(Integer val) noexcept;
266269

267270
template <typename Integer>

include/boost/decimal/decimal_fast128_t.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,20 @@ BOOST_DECIMAL_EXPORT class decimal_fast128_t final
178178
#else
179179
template <typename Integer, std::enable_if_t<detail::is_integral_v<Integer>, bool> = true>
180180
#endif
181+
#if !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_CONVERSIONS) && !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_INTEGER_CONVERSIONS)
182+
explicit
183+
#endif
181184
constexpr decimal_fast128_t(Integer val) noexcept;
182185

183186
#ifdef BOOST_DECIMAL_HAS_CONCEPTS
184187
template <BOOST_DECIMAL_REAL Float>
185188
#else
186189
template <typename Float, std::enable_if_t<detail::is_floating_point_v<Float>, bool> = true>
187190
#endif
188-
explicit BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast128_t(Float val) noexcept;
191+
#if !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_CONVERSIONS) && !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_FLOAT_CONVERSIONS)
192+
explicit
193+
#endif
194+
BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast128_t(Float val) noexcept;
189195

190196
#ifdef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
191197
explicit BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast128_t(long double val) noexcept = delete;

include/boost/decimal/decimal_fast32_t.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,16 @@ BOOST_DECIMAL_EXPORT class decimal_fast32_t final
159159
explicit constexpr decimal_fast32_t(bool value) noexcept;
160160

161161
template <typename Integer, std::enable_if_t<detail::is_integral_v<Integer>, bool> = true>
162+
#if !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_CONVERSIONS) && !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_INTEGER_CONVERSIONS)
163+
explicit
164+
#endif
162165
constexpr decimal_fast32_t(Integer coeff) noexcept;
163166

164167
template <typename Float, std::enable_if_t<detail::is_floating_point_v<Float>, bool> = true>
165-
explicit BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast32_t(Float val) noexcept;
168+
#if !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_CONVERSIONS) && !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_FLOAT_CONVERSIONS)
169+
explicit
170+
#endif
171+
BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast32_t(Float val) noexcept;
166172

167173
#ifdef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
168174
explicit constexpr decimal_fast32_t(long double val) noexcept = delete;

include/boost/decimal/decimal_fast64_t.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,20 @@ BOOST_DECIMAL_EXPORT class decimal_fast64_t final
189189
#else
190190
template <typename Integer, std::enable_if_t<detail::is_integral_v<Integer>, bool> = true>
191191
#endif
192+
#if !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_CONVERSIONS) && !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_INTEGER_CONVERSIONS)
193+
explicit
194+
#endif
192195
constexpr decimal_fast64_t(Integer val) noexcept;
193196

194197
#ifdef BOOST_DECIMAL_HAS_CONCEPTS
195198
template <BOOST_DECIMAL_REAL Float>
196199
#else
197200
template <typename Float, std::enable_if_t<detail::is_floating_point_v<Float>, bool> = true>
198201
#endif
199-
explicit BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast64_t(Float val) noexcept;
202+
#if !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_CONVERSIONS) && !defined(BOOST_DECIMAL_ALLOW_IMPLICIT_FLOAT_CONVERSIONS)
203+
explicit
204+
#endif
205+
BOOST_DECIMAL_CXX20_CONSTEXPR decimal_fast64_t(Float val) noexcept;
200206

201207
#ifdef BOOST_DECIMAL_UNSUPPORTED_LONG_DOUBLE
202208
explicit constexpr decimal_fast64_t(long double val) noexcept = delete;

0 commit comments

Comments
 (0)