forked from mpusz/mp-units
refactor: explicit
usage unified accross the library
This commit is contained in:
@@ -36,7 +36,7 @@ The simplest representation type that fulfills the above requirements can look a
|
||||
std::intmax_t value_;
|
||||
public:
|
||||
my_rep() = default;
|
||||
explicit constexpr my_rep(std::intmax_t v) noexcept : value_(v) {}
|
||||
constexpr explicit my_rep(std::intmax_t v) noexcept : value_(v) {}
|
||||
|
||||
[[nodiscard]] bool operator==(my_rep) const = default;
|
||||
|
||||
|
@@ -43,9 +43,9 @@ struct basic_fixed_string {
|
||||
using iterator = CharT*;
|
||||
using const_iterator = const CharT*;
|
||||
|
||||
constexpr basic_fixed_string(CharT ch) noexcept { data_[0] = ch; }
|
||||
constexpr explicit(false) basic_fixed_string(CharT ch) noexcept { data_[0] = ch; }
|
||||
|
||||
constexpr basic_fixed_string(const CharT (&txt)[N + 1]) noexcept
|
||||
constexpr explicit(false) basic_fixed_string(const CharT (&txt)[N + 1]) noexcept
|
||||
{
|
||||
if constexpr (N != 0)
|
||||
for (std::size_t i = 0; i < N; ++i) data_[i] = txt[i];
|
||||
|
@@ -133,15 +133,15 @@ public:
|
||||
quantity(quantity&&) = default;
|
||||
|
||||
template<safe_convertible_to_<rep> Value>
|
||||
explicit(!(is_same_v<dimension, dim_one> && is_same_v<unit, ::units::one>))
|
||||
constexpr quantity(const Value& v) : value_(v) {}
|
||||
constexpr explicit(!(is_same_v<dimension, dim_one> && is_same_v<unit, ::units::one>))
|
||||
quantity(const Value& v) : value_(v) {}
|
||||
|
||||
template<safe_castable_to_<quantity> Q>
|
||||
constexpr quantity(const Q& q) : value_(quantity_cast<quantity>(q).count()) {}
|
||||
constexpr explicit(false) quantity(const Q& q) : value_(quantity_cast<quantity>(q).count()) {}
|
||||
|
||||
template<QuantityLike Q>
|
||||
requires safe_castable_to_<quantity_like_type<Q>, quantity>
|
||||
explicit constexpr quantity(const Q& q) : quantity(quantity_like_type<Q>(quantity_like_traits<Q>::count(q))) {}
|
||||
constexpr explicit quantity(const Q& q) : quantity(quantity_like_type<Q>(quantity_like_traits<Q>::count(q))) {}
|
||||
|
||||
quantity& operator=(const quantity&) = default;
|
||||
quantity& operator=(quantity&&) = default;
|
||||
|
@@ -70,7 +70,7 @@ public:
|
||||
|
||||
template<QuantityPoint QP2>
|
||||
requires std::is_convertible_v<typename QP2::quantity_type, quantity_type>
|
||||
constexpr quantity_point(const QP2& qp) : q_{qp.relative()} {}
|
||||
constexpr explicit(false) quantity_point(const QP2& qp) : q_{qp.relative()} {}
|
||||
|
||||
quantity_point& operator=(const quantity_point&) = default;
|
||||
quantity_point& operator=(quantity_point&&) = default;
|
||||
|
@@ -51,7 +51,7 @@ struct ratio {
|
||||
std::intmax_t den;
|
||||
std::intmax_t exp;
|
||||
|
||||
explicit constexpr ratio(std::intmax_t n, std::intmax_t d = 1, std::intmax_t e = 0): num(n), den(d), exp(e)
|
||||
constexpr explicit ratio(std::intmax_t n, std::intmax_t d = 1, std::intmax_t e = 0): num(n), den(d), exp(e)
|
||||
{
|
||||
gsl_Expects(den != 0);
|
||||
detail::normalize(num, den, exp);
|
||||
|
@@ -44,7 +44,7 @@ public:
|
||||
min_expl() requires (Mode != 1) = default;
|
||||
|
||||
// construction from std::int64_t
|
||||
explicit constexpr min_expl(std::intmax_t v) noexcept requires (Mode != 2) : value_(v) {}
|
||||
constexpr explicit min_expl(std::intmax_t v) noexcept requires (Mode != 2) : value_(v) {}
|
||||
|
||||
// copy construction
|
||||
min_expl(const min_expl&) requires (Mode != 3) = default;
|
||||
|
Reference in New Issue
Block a user