diff --git a/include/hyperion/mpl/type.h b/include/hyperion/mpl/type.h index f7b8f60..2aed62a 100644 --- a/include/hyperion/mpl/type.h +++ b/include/hyperion/mpl/type.h @@ -49,6 +49,7 @@ /// /// using namespace hyperion::mpl; /// +/// // alternatively, use `decltype_()` /// constexpr auto type1 = Type{}; /// constexpr auto type2 = Type{}; /// @@ -94,7 +95,7 @@ namespace hyperion::mpl { /// @return another instance of this `Type` specialization template requires std::same_as - [[nodiscard]] constexpr auto self() noexcept -> Type { + [[nodiscard]] constexpr auto self() const noexcept -> Type { return {}; } @@ -114,7 +115,7 @@ namespace hyperion::mpl { /// @return The inner `MetaType` or `MetaValue` of `this` `Type` template requires std::same_as - [[nodiscard]] constexpr auto inner() noexcept -> TDelay + [[nodiscard]] constexpr auto inner() const noexcept -> TDelay requires std::is_default_constructible_v && MetaValue { return {}; @@ -140,7 +141,7 @@ namespace hyperion::mpl { /// @return Whether the `type` of this `Type` is also a metaprogramming type template requires std::same_as - [[nodiscard]] constexpr auto has_inner() noexcept -> bool { + [[nodiscard]] constexpr auto has_inner() const noexcept -> bool { return MetaValue; } @@ -171,7 +172,7 @@ namespace hyperion::mpl { /// @tparam TMetaFunction The template metafunction to apply to this `Type` /// @return The result of applying `TMetaFunction`, as a `Value` specialization template typename TMetaFunction> - [[nodiscard]] constexpr auto apply() noexcept -> std::enable_if_t< + [[nodiscard]] constexpr auto apply() const noexcept -> std::enable_if_t< TypeMetaFunction && MetaValue>, Value::value, decltype(TMetaFunction::value)>>; @@ -202,7 +203,7 @@ namespace hyperion::mpl { && (!MetaType::type>) [[nodiscard]] constexpr auto apply() // NOLINTNEXTLINE(modernize-type-traits) - noexcept -> Type::type> { + const noexcept -> Type::type> { return {}; } @@ -238,7 +239,7 @@ namespace hyperion::mpl { || MetaType::type>) [[nodiscard]] constexpr auto apply() // NOLINTNEXTLINE(modernize-type-traits) - noexcept { + const noexcept { if constexpr(MetaValue::type>) { return Value::type::value, std::remove_cvref_t::type::value)>>{}; @@ -286,7 +287,7 @@ namespace hyperion::mpl { [[nodiscard]] constexpr auto apply( [[maybe_unused]] TFunction&& func) // NOLINT(*-missing-std-forward) // NOLINTNEXTLINE(modernize-type-traits) - noexcept -> Type>::type> { + const noexcept -> Type>::type> { return {}; } @@ -323,7 +324,7 @@ namespace hyperion::mpl { template [[nodiscard]] constexpr auto apply([[maybe_unused]] TFunction&& func) // NOLINT(*-missing-std-forward) - noexcept -> std::enable_if_t< + const noexcept -> std::enable_if_t< MetaFunctionOf> && MetaValue>>, Value>::value, @@ -365,7 +366,7 @@ namespace hyperion::mpl { && (!MetaType::type>) && MetaValue [[nodiscard]] constexpr auto apply( - [[maybe_unused]] TFunction&& func) noexcept { // NOLINT(*-missing-std-forward) + [[maybe_unused]] TFunction&& func) const noexcept { // NOLINT(*-missing-std-forward) return type{}.apply(TFunction{}); } @@ -403,7 +404,7 @@ namespace hyperion::mpl { requires MetaFunctionOf && MetaValue> && MetaValue [[nodiscard]] constexpr auto - apply([[maybe_unused]] TFunction&& func) noexcept { // NOLINT(*-missing-std-forward) + apply([[maybe_unused]] TFunction&& func) const noexcept { // NOLINT(*-missing-std-forward) return type{}.apply(TFunction{}); } @@ -440,7 +441,7 @@ namespace hyperion::mpl { /// @return The result of checking this `Type` specialization against `TPredicate`, as a /// `Value` specialization template typename TPredicate> - [[nodiscard]] constexpr auto satisfies() noexcept -> std::enable_if_t< + [[nodiscard]] constexpr auto satisfies() const noexcept -> std::enable_if_t< TypeMetaFunction && MetaValue> && std::same_as::value)>, bool>, Value::value, bool>>; @@ -485,7 +486,7 @@ namespace hyperion::mpl { bool> [[nodiscard]] constexpr auto satisfies([[maybe_unused]] TPredicate&& predicate) // NOLINT(*-missing-std-forward) - noexcept -> meta_result_t> { + const noexcept -> meta_result_t> { return {}; } @@ -529,7 +530,7 @@ namespace hyperion::mpl { template [[nodiscard]] constexpr auto satisfies([[maybe_unused]] TPredicate&& predicate) // NOLINT(*-missing-std-forward) - noexcept -> std::enable_if_t< + const noexcept -> std::enable_if_t< MetaFunctionOf> && MetaType>> && MetaValue>::type> @@ -584,7 +585,7 @@ namespace hyperion::mpl { && MetaValue [[nodiscard]] constexpr auto satisfies([[maybe_unused]] TPredicate&& predicate) // NOLINT(*-forward) - noexcept { + const noexcept { return type{}.satisfies(TPredicate{}); } @@ -627,7 +628,7 @@ namespace hyperion::mpl { template [[nodiscard]] constexpr auto satisfies([[maybe_unused]] TPredicate&& predicate) // NOLINT(*-forward) - noexcept -> std::enable_if_t< + const noexcept -> std::enable_if_t< MetaFunctionOf && MetaType> && MetaValue::type> && std::same_as< @@ -656,7 +657,7 @@ namespace hyperion::mpl { /// @param rhs The `Type` specialization to compare to /// @return Whether `this` and `rhs` are the same `Type` specialization template - [[nodiscard]] constexpr auto is([[maybe_unused]] const Type& rhs) noexcept + [[nodiscard]] constexpr auto is([[maybe_unused]] const Type& rhs) const noexcept -> Value, bool>; /// @brief Returns whether the `type` of `this` `Type` specialization is the same as, @@ -688,7 +689,7 @@ namespace hyperion::mpl { /// `type` of `rhs` template [[nodiscard]] constexpr auto - is_qualification_of([[maybe_unused]] const Type& rhs) noexcept { + is_qualification_of([[maybe_unused]] const Type& rhs) const noexcept { return Type{}.is(Type>{}); } @@ -705,7 +706,7 @@ namespace hyperion::mpl { /// /// @return Whether the `type` of `this` is `const` template - [[nodiscard]] constexpr auto is_const() noexcept + [[nodiscard]] constexpr auto is_const() const noexcept -> std::enable_if_t, Value>, bool>>; @@ -722,7 +723,7 @@ namespace hyperion::mpl { /// /// @return Whether the `type` of `this` is an lvalue reference template - [[nodiscard]] constexpr auto is_lvalue_reference() noexcept + [[nodiscard]] constexpr auto is_lvalue_reference() const noexcept -> std::enable_if_t, Value, bool>>; @@ -739,7 +740,7 @@ namespace hyperion::mpl { /// /// @return Whether the `type` of `this` is an rvalue reference template - [[nodiscard]] constexpr auto is_rvalue_reference() noexcept + [[nodiscard]] constexpr auto is_rvalue_reference() const noexcept -> std::enable_if_t, Value, bool>>; @@ -756,13 +757,13 @@ namespace hyperion::mpl { /// /// @return Whether the `type` of `this` is `volatile` template - [[nodiscard]] constexpr auto is_volatile() noexcept + [[nodiscard]] constexpr auto is_volatile() const noexcept -> std::enable_if_t, Value>, bool>>; template requires std::same_as - [[nodiscard]] constexpr auto as_const() noexcept { + [[nodiscard]] constexpr auto as_const() const noexcept { using constified = std::add_const_t>; if constexpr(Type{}.is_lvalue_reference()) { return Type>{}; @@ -777,7 +778,7 @@ namespace hyperion::mpl { template requires std::same_as - [[nodiscard]] constexpr auto as_lvalue_reference() noexcept { + [[nodiscard]] constexpr auto as_lvalue_reference() const noexcept { using base_type = std::remove_reference_t; if constexpr(Type{}.is_lvalue_reference()) { return Type{}; @@ -789,7 +790,7 @@ namespace hyperion::mpl { template requires std::same_as - [[nodiscard]] constexpr auto as_rvalue_reference() noexcept { + [[nodiscard]] constexpr auto as_rvalue_reference() const noexcept { using base_type = std::remove_reference_t; if constexpr(Type{}.is_rvalue_reference()) { return Type{}; @@ -801,7 +802,7 @@ namespace hyperion::mpl { template requires std::same_as - [[nodiscard]] constexpr auto as_volatile() noexcept { + [[nodiscard]] constexpr auto as_volatile() const noexcept { using volatilified = std::add_volatile_t>; if constexpr(Type{}.is_lvalue_reference()) { return Type>{}; @@ -816,140 +817,141 @@ namespace hyperion::mpl { template [[nodiscard]] constexpr auto - is_convertible_to([[maybe_unused]] const Type& rhs) noexcept + is_convertible_to([[maybe_unused]] const Type& rhs) const noexcept -> Value, bool>; template [[nodiscard]] constexpr auto - is_derived_from([[maybe_unused]] const Type& rhs) noexcept + is_derived_from([[maybe_unused]] const Type& rhs) const noexcept -> Value && !std::same_as, bool>; template - [[nodiscard]] constexpr auto is_base_of([[maybe_unused]] const Type& rhs) noexcept + [[nodiscard]] constexpr auto + is_base_of([[maybe_unused]] const Type& rhs) const noexcept -> Value && !std::same_as, bool>; template typename TList, typename... TTypes> [[nodiscard]] constexpr auto - is_constructible_from([[maybe_unused]] const TList& list) noexcept + is_constructible_from([[maybe_unused]] const TList& list) const noexcept -> std::enable_if_t>, Value, bool>>; template [[nodiscard]] constexpr auto - is_constructible_from([[maybe_unused]] const Type&... list) noexcept + is_constructible_from([[maybe_unused]] const Type&... list) const noexcept -> Value, bool>; template typename TList, typename... TTypes> [[nodiscard]] constexpr auto - is_noexcept_constructible_from([[maybe_unused]] const TList& list) noexcept + is_noexcept_constructible_from([[maybe_unused]] const TList& list) const noexcept -> std::enable_if_t>, Value, bool>>; template [[nodiscard]] constexpr auto - is_noexcept_constructible_from([[maybe_unused]] const Type&... list) noexcept + is_noexcept_constructible_from([[maybe_unused]] const Type&... list) const noexcept -> Value, bool>; template - [[nodiscard]] constexpr auto is_default_constructible() noexcept + [[nodiscard]] constexpr auto is_default_constructible() const noexcept -> std::enable_if_t, Value, bool>>; template - [[nodiscard]] constexpr auto is_noexcept_default_constructible() noexcept + [[nodiscard]] constexpr auto is_noexcept_default_constructible() const noexcept -> std::enable_if_t, Value, bool>>; template - [[nodiscard]] constexpr auto is_trivially_default_constructible() noexcept + [[nodiscard]] constexpr auto is_trivially_default_constructible() const noexcept -> std::enable_if_t, Value, bool>>; template - [[nodiscard]] constexpr auto is_copy_constructible() noexcept + [[nodiscard]] constexpr auto is_copy_constructible() const noexcept -> std::enable_if_t, Value, bool>>; template - [[nodiscard]] constexpr auto is_noexcept_copy_constructible() noexcept + [[nodiscard]] constexpr auto is_noexcept_copy_constructible() const noexcept -> std::enable_if_t, Value, bool>>; template - [[nodiscard]] constexpr auto is_trivially_copy_constructible() noexcept + [[nodiscard]] constexpr auto is_trivially_copy_constructible() const noexcept -> std::enable_if_t, Value, bool>>; template - [[nodiscard]] constexpr auto is_move_constructible() noexcept + [[nodiscard]] constexpr auto is_move_constructible() const noexcept -> std::enable_if_t, Value, bool>>; template - [[nodiscard]] constexpr auto is_noexcept_move_constructible() noexcept + [[nodiscard]] constexpr auto is_noexcept_move_constructible() const noexcept -> std::enable_if_t, Value, bool>>; template - [[nodiscard]] constexpr auto is_trivially_move_constructible() noexcept + [[nodiscard]] constexpr auto is_trivially_move_constructible() const noexcept -> std::enable_if_t, Value, bool>>; template - [[nodiscard]] constexpr auto is_copy_assignable() noexcept + [[nodiscard]] constexpr auto is_copy_assignable() const noexcept -> std::enable_if_t, Value, bool>>; template - [[nodiscard]] constexpr auto is_noexcept_copy_assignable() noexcept + [[nodiscard]] constexpr auto is_noexcept_copy_assignable() const noexcept -> std::enable_if_t, Value, bool>>; template - [[nodiscard]] constexpr auto is_trivially_copy_assignable() noexcept + [[nodiscard]] constexpr auto is_trivially_copy_assignable() const noexcept -> std::enable_if_t, Value, bool>>; template - [[nodiscard]] constexpr auto is_move_assignable() noexcept + [[nodiscard]] constexpr auto is_move_assignable() const noexcept -> std::enable_if_t, Value, bool>>; template - [[nodiscard]] constexpr auto is_noexcept_move_assignable() noexcept + [[nodiscard]] constexpr auto is_noexcept_move_assignable() const noexcept -> std::enable_if_t, Value, bool>>; template - [[nodiscard]] constexpr auto is_trivially_move_assignable() noexcept + [[nodiscard]] constexpr auto is_trivially_move_assignable() const noexcept -> std::enable_if_t, Value, bool>>; template - [[nodiscard]] constexpr auto - is_destructible() noexcept -> std::enable_if_t, - Value, bool>>; + [[nodiscard]] constexpr auto is_destructible() const noexcept + -> std::enable_if_t, + Value, bool>>; template - [[nodiscard]] constexpr auto is_noexcept_destructible() noexcept + [[nodiscard]] constexpr auto is_noexcept_destructible() const noexcept -> std::enable_if_t, Value, bool>>; template - [[nodiscard]] constexpr auto is_trivially_destructible() noexcept + [[nodiscard]] constexpr auto is_trivially_destructible() const noexcept -> std::enable_if_t, Value, bool>>; template [[nodiscard]] constexpr auto - is_swappable() noexcept -> std::enable_if_t, - Value, bool>>; + is_swappable() const noexcept -> std::enable_if_t, + Value, bool>>; template - [[nodiscard]] constexpr auto is_noexcept_swappable() noexcept + [[nodiscard]] constexpr auto is_noexcept_swappable() const noexcept -> std::enable_if_t, Value, bool>>; @@ -957,7 +959,7 @@ namespace hyperion::mpl { type, std::add_lvalue_reference_t>> [[nodiscard]] constexpr auto - is_swappable_with([[maybe_unused]] const Type& rhs = Type{}) noexcept + is_swappable_with([[maybe_unused]] const Type& rhs = Type{}) const noexcept -> Value, type, std::add_lvalue_reference_t>, @@ -968,7 +970,8 @@ namespace hyperion::mpl { type, std::add_lvalue_reference_t>> [[nodiscard]] constexpr auto - is_noexcept_swappable_with([[maybe_unused]] const Type& rhs = Type{}) noexcept + is_noexcept_swappable_with([[maybe_unused]] const Type& rhs + = Type{}) const noexcept -> Value, type, @@ -977,10 +980,27 @@ namespace hyperion::mpl { bool>; template - [[nodiscard]] constexpr auto sizeof_() noexcept + [[nodiscard]] constexpr auto sizeof_() const noexcept -> std::enable_if_t, Value>; }; + /// @brief Returns an `mpl::Type` representing the type of the given argument + /// + /// # Requirements + /// - `TType` must be a reference-qualified type + /// + /// # Example + /// @code {.cpp} + /// constexpr auto value = true; + /// constexpr auto value_type = decltype_(value); + /// + /// static_assert(value_type.is(decltype_())); + /// static_assert(value_type == decltype_()); + /// @endcode + /// + /// @tparam TType The type of the argument to get the type of + /// @param type The argument to get the type of + /// @return an `mpl::Type` representing the type of `type` template requires std::is_reference_v [[nodiscard]] constexpr auto @@ -991,6 +1011,22 @@ namespace hyperion::mpl { return {}; } + /// @brief Returns an `mpl::Type` representing the type of the given argument + /// + /// # Requirements + /// - `TType` must _not_ be a reference-qualified type + /// + /// # Example + /// @code {.cpp} + /// constexpr auto value_type = decltype_(1); + /// + /// static_assert(value_type.is(decltype_())); + /// static_assert(value_type == decltype_()); + /// @endcode + /// + /// @tparam TType The type of the argument to get the type of + /// @param type The argument to get the type of + /// @return an `mpl::Type` representing the type of `type` template requires(!std::is_reference_v) [[nodiscard]] constexpr auto @@ -999,12 +1035,26 @@ namespace hyperion::mpl { return {}; } + /// @brief Returns an `mpl::Type` representing the type `TType` + /// + /// # Example + /// @code {.cpp} + /// constexpr auto value_type = decltype_(1); + /// constexpr auto int_type = decltype_(); + /// + /// static_assert(value_type.is(int_type)); + /// static_assert(value_type == int_type); + /// @endcode + /// + /// @tparam TType The type to represent as an `mpl::Type` + /// @return an `mpl::Type` representing the type `TType` template [[nodiscard]] constexpr auto decltype_() noexcept -> std::conditional_t, TType, Type> { return {}; } + template [[nodiscard]] constexpr auto operator==([[maybe_unused]] const Type& lhs, @@ -1027,7 +1077,7 @@ namespace hyperion::mpl { template template typename TMetaFunction> - [[nodiscard]] constexpr auto Type::apply() noexcept -> std::enable_if_t< + [[nodiscard]] constexpr auto Type::apply() const noexcept -> std::enable_if_t< TypeMetaFunction && MetaValue>, Value::value, decltype(TMetaFunction::value)>> { return {}; @@ -1037,7 +1087,7 @@ namespace hyperion::mpl { template [[nodiscard]] constexpr auto Type::apply([[maybe_unused]] TFunction&& func) // NOLINT(*-missing-std-forward) - noexcept -> std::enable_if_t< + const noexcept -> std::enable_if_t< MetaFunctionOf> && MetaValue>>, Value>::value, @@ -1047,7 +1097,7 @@ namespace hyperion::mpl { template template typename TPredicate> - [[nodiscard]] constexpr auto Type::satisfies() noexcept -> std::enable_if_t< + [[nodiscard]] constexpr auto Type::satisfies() const noexcept -> std::enable_if_t< TypeMetaFunction && MetaValue> && std::same_as::value)>, bool>, Value::value, bool>> { @@ -1058,7 +1108,7 @@ namespace hyperion::mpl { template [[nodiscard]] constexpr auto Type::satisfies([[maybe_unused]] TPredicate&& predicate) // NOLINT(*-missing-std-forward) - noexcept -> std::enable_if_t< + const noexcept -> std::enable_if_t< MetaFunctionOf> && MetaType>> && MetaValue>::type> @@ -1073,7 +1123,7 @@ namespace hyperion::mpl { template [[nodiscard]] constexpr auto Type::satisfies([[maybe_unused]] TPredicate&& predicate) // NOLINT(*-forward) - noexcept -> std::enable_if_t< + const noexcept -> std::enable_if_t< MetaFunctionOf && MetaType> && MetaValue::type> && std::same_as< @@ -1086,14 +1136,15 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is([[maybe_unused]] const Type& rhs) noexcept + [[nodiscard]] constexpr auto + Type::is([[maybe_unused]] const Type& rhs) const noexcept -> Value, bool> { return {}; } template template - [[nodiscard]] constexpr auto Type::is_const() noexcept + [[nodiscard]] constexpr auto Type::is_const() const noexcept -> std::enable_if_t, Value>, bool>> { return {}; @@ -1101,7 +1152,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_lvalue_reference() noexcept + [[nodiscard]] constexpr auto Type::is_lvalue_reference() const noexcept -> std::enable_if_t, Value, bool>> { return {}; @@ -1109,7 +1160,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_rvalue_reference() noexcept + [[nodiscard]] constexpr auto Type::is_rvalue_reference() const noexcept -> std::enable_if_t, Value, bool>> { return {}; @@ -1117,7 +1168,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_volatile() noexcept + [[nodiscard]] constexpr auto Type::is_volatile() const noexcept -> std::enable_if_t, Value>, bool>> { return {}; @@ -1126,7 +1177,7 @@ namespace hyperion::mpl { template template [[nodiscard]] constexpr auto - Type::is_convertible_to([[maybe_unused]] const Type& rhs) noexcept + Type::is_convertible_to([[maybe_unused]] const Type& rhs) const noexcept -> Value, bool> { return {}; } @@ -1134,7 +1185,7 @@ namespace hyperion::mpl { template template [[nodiscard]] constexpr auto - Type::is_derived_from([[maybe_unused]] const Type& rhs) noexcept + Type::is_derived_from([[maybe_unused]] const Type& rhs) const noexcept -> Value && !std::same_as, bool> { return {}; } @@ -1142,7 +1193,7 @@ namespace hyperion::mpl { template template [[nodiscard]] constexpr auto - Type::is_base_of([[maybe_unused]] const Type& rhs) noexcept + Type::is_base_of([[maybe_unused]] const Type& rhs) const noexcept -> Value && !std::same_as, bool> { return {}; } @@ -1150,7 +1201,7 @@ namespace hyperion::mpl { template template typename TList, typename... TTypes> [[nodiscard]] constexpr auto - Type::is_constructible_from([[maybe_unused]] const TList& list) noexcept + Type::is_constructible_from([[maybe_unused]] const TList& list) const noexcept -> std::enable_if_t>, Value, bool>> { return {}; @@ -1159,7 +1210,7 @@ namespace hyperion::mpl { template template [[nodiscard]] constexpr auto - Type::is_constructible_from([[maybe_unused]] const Type&... list) noexcept + Type::is_constructible_from([[maybe_unused]] const Type&... list) const noexcept -> Value, bool> { return {}; } @@ -1167,7 +1218,7 @@ namespace hyperion::mpl { template template typename TList, typename... TTypes> [[nodiscard]] constexpr auto Type::is_noexcept_constructible_from( - [[maybe_unused]] const TList& list) noexcept + [[maybe_unused]] const TList& list) const noexcept -> std::enable_if_t>, Value, bool>> { return {}; @@ -1176,14 +1227,14 @@ namespace hyperion::mpl { template template [[nodiscard]] constexpr auto Type::is_noexcept_constructible_from( - [[maybe_unused]] const Type&... list) noexcept + [[maybe_unused]] const Type&... list) const noexcept -> Value, bool> { return {}; } template template - [[nodiscard]] constexpr auto Type::is_default_constructible() noexcept + [[nodiscard]] constexpr auto Type::is_default_constructible() const noexcept -> std::enable_if_t, Value, bool>> { return {}; @@ -1191,7 +1242,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_noexcept_default_constructible() noexcept + [[nodiscard]] constexpr auto Type::is_noexcept_default_constructible() const noexcept -> std::enable_if_t, Value, bool>> { return {}; @@ -1199,7 +1250,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_trivially_default_constructible() noexcept + [[nodiscard]] constexpr auto Type::is_trivially_default_constructible() const noexcept -> std::enable_if_t, Value, bool>> { @@ -1208,7 +1259,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_copy_constructible() noexcept + [[nodiscard]] constexpr auto Type::is_copy_constructible() const noexcept -> std::enable_if_t, Value, bool>> { return {}; @@ -1216,7 +1267,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_noexcept_copy_constructible() noexcept + [[nodiscard]] constexpr auto Type::is_noexcept_copy_constructible() const noexcept -> std::enable_if_t, Value, bool>> { @@ -1225,7 +1276,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_trivially_copy_constructible() noexcept + [[nodiscard]] constexpr auto Type::is_trivially_copy_constructible() const noexcept -> std::enable_if_t, Value, bool>> { return {}; @@ -1233,7 +1284,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_move_constructible() noexcept + [[nodiscard]] constexpr auto Type::is_move_constructible() const noexcept -> std::enable_if_t, Value, bool>> { return {}; @@ -1241,7 +1292,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_noexcept_move_constructible() noexcept + [[nodiscard]] constexpr auto Type::is_noexcept_move_constructible() const noexcept -> std::enable_if_t, Value, bool>> { return {}; @@ -1249,7 +1300,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_trivially_move_constructible() noexcept + [[nodiscard]] constexpr auto Type::is_trivially_move_constructible() const noexcept -> std::enable_if_t, Value, bool>> { return {}; @@ -1257,7 +1308,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_copy_assignable() noexcept + [[nodiscard]] constexpr auto Type::is_copy_assignable() const noexcept -> std::enable_if_t, Value, bool>> { return {}; @@ -1265,7 +1316,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_noexcept_copy_assignable() noexcept + [[nodiscard]] constexpr auto Type::is_noexcept_copy_assignable() const noexcept -> std::enable_if_t, Value, bool>> { return {}; @@ -1273,7 +1324,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_trivially_copy_assignable() noexcept + [[nodiscard]] constexpr auto Type::is_trivially_copy_assignable() const noexcept -> std::enable_if_t, Value, bool>> { return {}; @@ -1281,7 +1332,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_move_assignable() noexcept + [[nodiscard]] constexpr auto Type::is_move_assignable() const noexcept -> std::enable_if_t, Value, bool>> { return {}; @@ -1289,7 +1340,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_noexcept_move_assignable() noexcept + [[nodiscard]] constexpr auto Type::is_noexcept_move_assignable() const noexcept -> std::enable_if_t, Value, bool>> { return {}; @@ -1297,7 +1348,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_trivially_move_assignable() noexcept + [[nodiscard]] constexpr auto Type::is_trivially_move_assignable() const noexcept -> std::enable_if_t, Value, bool>> { return {}; @@ -1305,7 +1356,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_destructible() noexcept + [[nodiscard]] constexpr auto Type::is_destructible() const noexcept -> std::enable_if_t, Value, bool>> { return {}; @@ -1313,7 +1364,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_noexcept_destructible() noexcept + [[nodiscard]] constexpr auto Type::is_noexcept_destructible() const noexcept -> std::enable_if_t, Value, bool>> { return {}; @@ -1321,7 +1372,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_trivially_destructible() noexcept + [[nodiscard]] constexpr auto Type::is_trivially_destructible() const noexcept -> std::enable_if_t, Value, bool>> { return {}; @@ -1329,14 +1380,14 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::is_swappable() noexcept + [[nodiscard]] constexpr auto Type::is_swappable() const noexcept -> std::enable_if_t, Value, bool>> { return {}; } template template - [[nodiscard]] constexpr auto Type::is_noexcept_swappable() noexcept + [[nodiscard]] constexpr auto Type::is_noexcept_swappable() const noexcept -> std::enable_if_t, Value, bool>> { return {}; @@ -1345,7 +1396,7 @@ namespace hyperion::mpl { template template [[nodiscard]] constexpr auto - Type::is_swappable_with([[maybe_unused]] const Type& rhs) noexcept -> Value< + Type::is_swappable_with([[maybe_unused]] const Type& rhs) const noexcept -> Value< std::is_swappable_with_v< std::conditional_t, type, std::add_lvalue_reference_t>, TRhs>, @@ -1356,7 +1407,7 @@ namespace hyperion::mpl { template template [[nodiscard]] constexpr auto - Type::is_noexcept_swappable_with([[maybe_unused]] const Type& rhs) noexcept + Type::is_noexcept_swappable_with([[maybe_unused]] const Type& rhs) const noexcept -> Value< std::is_nothrow_swappable_with_v, type, @@ -1368,7 +1419,7 @@ namespace hyperion::mpl { template template - [[nodiscard]] constexpr auto Type::sizeof_() noexcept + [[nodiscard]] constexpr auto Type::sizeof_() const noexcept -> std::enable_if_t, Value> { return {}; } diff --git a/include/hyperion/mpl/value.h b/include/hyperion/mpl/value.h index 4dc1d46..34ead2c 100644 --- a/include/hyperion/mpl/value.h +++ b/include/hyperion/mpl/value.h @@ -127,7 +127,7 @@ namespace hyperion::mpl { /// @return The result of applying `TMetaFunction`, as a `Value` specialization template typename TMetaFunction> requires TypeMetaFunction && MetaValue> - [[nodiscard]] constexpr auto apply() noexcept -> Value::value> { + [[nodiscard]] constexpr auto apply() const noexcept -> Value::value> { return {}; } @@ -157,7 +157,7 @@ namespace hyperion::mpl { /// @tparam TMetaFunction The template metafunction to apply to this `Value` /// @return The result of applying `TMetaFunction`, as a `Type` specialization template typename TMetaFunction> - [[nodiscard]] constexpr auto apply() noexcept + [[nodiscard]] constexpr auto apply() const noexcept -> std::enable_if_t && MetaType> && !MetaValue::type>, Type::type>>; @@ -188,7 +188,7 @@ namespace hyperion::mpl { /// @tparam TMetaFunction The template metafunction to apply to this `Value` /// @return The result of applying `TMetaFunction`, as a `Value` specialization template typename TMetaFunction> - [[nodiscard]] constexpr auto apply() noexcept + [[nodiscard]] constexpr auto apply() const noexcept -> std::enable_if_t && MetaType> && MetaValue::type>, Value::type::value>>; @@ -219,7 +219,7 @@ namespace hyperion::mpl { /// @return The result of applying `TMetaFunction`, as a `Value` specialization template typename TMetaFunction> requires ValueMetaFunction && MetaValue> - [[nodiscard]] constexpr auto apply() noexcept -> Value::value> { + [[nodiscard]] constexpr auto apply() const noexcept -> Value::value> { return {}; } @@ -249,7 +249,7 @@ namespace hyperion::mpl { /// @tparam TMetaFunction The template metafunction to apply to this `Value` /// @return The result of applying `TMetaFunction`, as a `Type` specialization template typename TMetaFunction> - [[nodiscard]] constexpr auto apply() noexcept + [[nodiscard]] constexpr auto apply() const noexcept -> std::enable_if_t && MetaType> && !MetaValue::type>, Type::type>>; @@ -280,7 +280,7 @@ namespace hyperion::mpl { /// @tparam TMetaFunction The template metafunction to apply to this `Value` /// @return The result of applying `TMetaFunction`, as a `Value` specialization template typename TMetaFunction> - [[nodiscard]] constexpr auto apply() noexcept + [[nodiscard]] constexpr auto apply() const noexcept -> std::enable_if_t && MetaType> && MetaValue::type>, Value::type::value>>; @@ -317,7 +317,7 @@ namespace hyperion::mpl { template [[nodiscard]] constexpr auto apply([[maybe_unused]] TFunction&& func) // NOLINT(*-missing-std-forward) - noexcept + const noexcept -> std::enable_if_t && MetaType> && !MetaType::type>, @@ -355,7 +355,7 @@ namespace hyperion::mpl { requires MetaFunctionOf && MetaValue> [[nodiscard]] constexpr auto apply([[maybe_unused]] TFunction&& func) // NOLINT(*-missing-std-forward) - noexcept -> Value::value> { + const noexcept -> Value::value> { return {}; } @@ -389,7 +389,7 @@ namespace hyperion::mpl { template typename TPredicate> requires ValueMetaFunction && MetaValue> && std::same_as::value)>, bool> - [[nodiscard]] constexpr auto satisfies() noexcept -> Value::value> { + [[nodiscard]] constexpr auto satisfies() const noexcept -> Value::value> { return {}; } @@ -423,7 +423,7 @@ namespace hyperion::mpl { template typename TPredicate> requires TypeMetaFunction && MetaValue> && std::same_as::value)>, bool> - [[nodiscard]] constexpr auto satisfies() noexcept -> Value::value> { + [[nodiscard]] constexpr auto satisfies() const noexcept -> Value::value> { return {}; } @@ -463,7 +463,7 @@ namespace hyperion::mpl { bool> [[nodiscard]] constexpr auto satisfies([[maybe_unused]] TPredicate&& predicate) // NOLINT(*-missing-std-forward) - noexcept -> meta_result_t { + const noexcept -> meta_result_t { return {}; } }; @@ -1005,7 +1005,7 @@ namespace hyperion::mpl { template template typename TMetaFunction> - [[nodiscard]] constexpr auto Value::apply() noexcept + [[nodiscard]] constexpr auto Value::apply() const noexcept -> std::enable_if_t && MetaType> && !MetaValue::type>, Type::type>> { @@ -1014,7 +1014,7 @@ namespace hyperion::mpl { template template typename TMetaFunction> - [[nodiscard]] constexpr auto Value::apply() noexcept + [[nodiscard]] constexpr auto Value::apply() const noexcept -> std::enable_if_t && MetaType> && MetaValue::type>, Value::type::value>> { @@ -1023,7 +1023,7 @@ namespace hyperion::mpl { template template typename TMetaFunction> - [[nodiscard]] constexpr auto Value::apply() noexcept + [[nodiscard]] constexpr auto Value::apply() const noexcept -> std::enable_if_t && MetaType> && !MetaValue::type>, Type::type>> { @@ -1032,7 +1032,7 @@ namespace hyperion::mpl { template template typename TMetaFunction> - [[nodiscard]] constexpr auto Value::apply() noexcept + [[nodiscard]] constexpr auto Value::apply() const noexcept -> std::enable_if_t && MetaType> && MetaValue::type>, Value::type::value>> { @@ -1043,7 +1043,7 @@ namespace hyperion::mpl { template [[nodiscard]] constexpr auto Value::apply([[maybe_unused]] TFunction&& func) // NOLINT(*-missing-std-forward) - noexcept + const noexcept -> std::enable_if_t && MetaType> && !MetaType::type>,