diff --git a/src/core/include/mp-units/bits/ratio.h b/src/core/include/mp-units/bits/ratio.h index bcd5ca69..96c67747 100644 --- a/src/core/include/mp-units/bits/ratio.h +++ b/src/core/include/mp-units/bits/ratio.h @@ -69,7 +69,7 @@ MP_UNITS_EXPORT struct ratio { std::intmax_t num; std::intmax_t den; - // NOLINTNEXTLINE(bugprone-easily-swappable-parameters) + // NOLINTNEXTLINE(bugprone-easily-swappable-parameters, google-explicit-constructor, hicpp-explicit-conversions) MP_UNITS_CONSTEVAL explicit(false) ratio(std::intmax_t n, std::intmax_t d = 1) : num{n}, den{d} { gsl_Expects(den != 0); diff --git a/src/core/include/mp-units/ext/fixed_string.h b/src/core/include/mp-units/ext/fixed_string.h index f093d2e8..8dac2822 100644 --- a/src/core/include/mp-units/ext/fixed_string.h +++ b/src/core/include/mp-units/ext/fixed_string.h @@ -63,6 +63,7 @@ struct basic_fixed_string { using size_type = std::size_t; using difference_type = std::ptrdiff_t; + // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) constexpr explicit(false) basic_fixed_string(const CharT (&txt)[N + 1]) noexcept { gsl_Expects(txt[N] == CharT{}); diff --git a/src/core/include/mp-units/framework/customization_points.h b/src/core/include/mp-units/framework/customization_points.h index 59259c4d..9111890a 100644 --- a/src/core/include/mp-units/framework/customization_points.h +++ b/src/core/include/mp-units/framework/customization_points.h @@ -136,6 +136,7 @@ template struct convert_explicitly { using value_type = T; T value; + // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) constexpr explicit(false) convert_explicitly(T v) noexcept(std::is_nothrow_constructible_v) : value(std::move(v)) { } @@ -145,6 +146,7 @@ template struct convert_implicitly { using value_type = T; T value; + // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) constexpr explicit(false) convert_implicitly(T v) noexcept(std::is_nothrow_constructible_v) : value(std::move(v)) { } diff --git a/src/core/include/mp-units/framework/quantity.h b/src/core/include/mp-units/framework/quantity.h index 3500f0a7..a4880f48 100644 --- a/src/core/include/mp-units/framework/quantity.h +++ b/src/core/include/mp-units/framework/quantity.h @@ -152,6 +152,7 @@ public: } template Q> + // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) constexpr explicit(!std::convertible_to) quantity(const Q& q) : numerical_value_is_an_implementation_detail_( detail::sudo_cast(q).numerical_value_is_an_implementation_detail_) @@ -163,6 +164,7 @@ public: quantity::reference, typename quantity_like_traits::rep>, quantity> constexpr explicit(is_specialization_of::to_numerical_value(std::declval())), convert_explicitly> || + // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) !std::convertible_to::rep, Rep>) quantity(const Q& q) : quantity( ::mp_units::quantity{quantity_like_traits::to_numerical_value(q).value, quantity_like_traits::reference}) diff --git a/src/core/include/mp-units/framework/quantity_point.h b/src/core/include/mp-units/framework/quantity_point.h index 6ad79403..adacb6b7 100644 --- a/src/core/include/mp-units/framework/quantity_point.h +++ b/src/core/include/mp-units/framework/quantity_point.h @@ -188,6 +188,7 @@ public: template QP> requires std::constructible_from // TODO add perfect forwarding + // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) constexpr explicit(!std::convertible_to) quantity_point(const QP& qp) : quantity_from_origin_is_an_implementation_detail_([&] { if constexpr (point_origin == QP::point_origin) @@ -208,6 +209,7 @@ public: convert_explicitly> || !std::convertible_to< quantity::reference, typename quantity_point_like_traits::rep>, quantity_type>) + // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) quantity_point(const QP& qp) : quantity_from_origin_is_an_implementation_detail_(quantity_point_like_traits::to_quantity(qp).value) { @@ -292,7 +294,7 @@ public: convert_explicitly> || !std::convertible_to::reference, typename quantity_point_like_traits::rep>>) constexpr - // NOLINTNEXTLINE(*-explicit-conversions, google-explicit-constructor) + // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) operator QP_() const& noexcept( noexcept(quantity_point_like_traits::from_quantity(quantity_from_origin_is_an_implementation_detail_)) && std::is_nothrow_copy_constructible_v) @@ -310,7 +312,7 @@ public: convert_explicitly> || !std::convertible_to::reference, typename quantity_point_like_traits::rep>>) constexpr - // NOLINTNEXTLINE(*-explicit-conversions, google-explicit-constructor) + // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) operator QP_() && noexcept( noexcept(quantity_point_like_traits::from_quantity(quantity_from_origin_is_an_implementation_detail_)) && std::is_nothrow_move_constructible_v) diff --git a/src/core/include/mp-units/framework/reference.h b/src/core/include/mp-units/framework/reference.h index b7636810..8050055a 100644 --- a/src/core/include/mp-units/framework/reference.h +++ b/src/core/include/mp-units/framework/reference.h @@ -189,10 +189,12 @@ template template requires RepresentationOf, get_quantity_spec(R{}).character> +// NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) constexpr auto operator*(R, Rep&&) = delete; template requires RepresentationOf, get_quantity_spec(R{}).character> +// NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) constexpr auto operator/(R, Rep&&) = delete; template @@ -213,10 +215,12 @@ template template requires Quantity> +// NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) constexpr auto operator*(R, Q&& q) = delete; template requires Quantity> +// NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward) constexpr auto operator/(R, Q&& q) = delete; [[nodiscard]] consteval AssociatedUnit auto common_reference(AssociatedUnit auto u1, AssociatedUnit auto u2, diff --git a/src/core/include/mp-units/framework/symbol_text.h b/src/core/include/mp-units/framework/symbol_text.h index f64e2d5b..d36aa082 100644 --- a/src/core/include/mp-units/framework/symbol_text.h +++ b/src/core/include/mp-units/framework/symbol_text.h @@ -89,12 +89,13 @@ struct symbol_text { fixed_u8string unicode_; fixed_string ascii_; + // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) constexpr explicit(false) symbol_text(char ch) : unicode_(static_cast(ch)), ascii_(ch) { gsl_Expects(detail::is_basic_literal_character_set_char(ch)); } - // NOLINTNEXTLINE(*-avoid-c-arrays) + // NOLINTNEXTLINE(*-avoid-c-arrays, google-explicit-constructor, hicpp-explicit-conversions) constexpr explicit(false) symbol_text(const char (&txt)[N + 1]) : unicode_(detail::to_u8string(basic_fixed_string{txt})), ascii_(txt) { @@ -102,6 +103,7 @@ struct symbol_text { gsl_Expects(detail::is_basic_literal_character_set(txt)); } + // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) constexpr explicit(false) symbol_text(const fixed_string& txt) : unicode_(detail::to_u8string(txt)), ascii_(txt) { gsl_Expects(detail::is_basic_literal_character_set(txt.data_)); diff --git a/test/static/custom_rep_test_min_impl.cpp b/test/static/custom_rep_test_min_impl.cpp index 4b8465e9..a473f276 100644 --- a/test/static/custom_rep_test_min_impl.cpp +++ b/test/static/custom_rep_test_min_impl.cpp @@ -43,8 +43,10 @@ public: using value_type = T; min_impl() = default; + // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) constexpr explicit(false) min_impl(T v) noexcept : value_(v) {} template + // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) constexpr explicit(false) min_impl(min_impl i) noexcept : value_(static_cast(static_cast(i))) { } diff --git a/test/static/quantity_test.cpp b/test/static/quantity_test.cpp index adc2b96f..4931ce74 100644 --- a/test/static/quantity_test.cpp +++ b/test/static/quantity_test.cpp @@ -264,7 +264,9 @@ struct derived_quantity : quantity { using R = quantity; derived_quantity() = default; + // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) constexpr explicit(!std::is_trivial_v) derived_quantity(const R& t) : R(t) {} + // NOLINTNEXTLINE(google-explicit-constructor, hicpp-explicit-conversions) constexpr explicit(!std::is_trivial_v) derived_quantity(R&& t) : R(std::move(t)) {} constexpr derived_quantity& operator=(const R& t)