From dc369b4c559b33868ffdb99eb4a2feadd90a84f2 Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Thu, 27 Feb 2020 09:32:48 +0100 Subject: new_type: remove doc comments --- include/newtype/derivable.hpp | 63 --- include/newtype/derivation_clause.hpp | 45 -- include/newtype/deriving.hpp | 3 - include/newtype/impl/type_traits_extensions.hpp | 563 ------------------------ include/newtype/new_type.hpp | 149 ------- 5 files changed, 823 deletions(-) diff --git a/include/newtype/derivable.hpp b/include/newtype/derivable.hpp index faa844d..c798c59 100644 --- a/include/newtype/derivable.hpp +++ b/include/newtype/derivable.hpp @@ -12,80 +12,17 @@ namespace nt using tag_type = DerivableTag; }; - /** - * @brief A set of standard derivation tags - * - * This convenience namespace contains all standard derivation tags. - * - * @since 1.0.0 - */ inline namespace derivables { - /** - * @brief A tag to enable derivation of arithmetic operators - * - * @since 1.0.0 - */ auto constexpr Arithmetic = derivable{}; - - /** - * @brief A tag to enable derivation of "equality comparison with base type" operators - * - * @note Deriving this feature seriously weakens the using nt::new_type instance - * @since 1.0.0 - */ auto constexpr EqBase = derivable{}; - - /** - * @brief A tag to enable derivation of a specialization of std::hash - * - * @since 1.0.0 - */ auto constexpr Hash = derivable{}; - - /** - * @brief A tag to enable derivation of the implicit "conversion to base type" operator - * - * @note If this tag is not present in the derivation clause of any given nt::new_type, the type instance only supports explicit - * "conversion to base type" - * @since 1.0.0 - */ auto constexpr ImplicitConversion = derivable{}; - - /** - * @brief A tag to enable access to the members of the base type object through a pointer - * - * @since 1.0.0 - */ auto constexpr Indirection = derivable{}; - - /** - * @brief A tag to enable derivation of the iterator accessors - * - * @since 1.0.0 - */ auto constexpr Iterable = derivable{}; - - /** - * @brief A tag to enable derivation of the stream input operator - * - * @since 1.0.0 - */ auto constexpr Read = derivable{}; - - /** - * @brief A tag to enable derivation of the relational operators - * - * @since 1.0.0 - */ auto constexpr Relational = derivable{}; - - /** - * @brief A tag to enable derivation of the stream output operator - * - * @since 1.0.0 - */ auto constexpr Show = derivable{}; } // namespace derivables diff --git a/include/newtype/derivation_clause.hpp b/include/newtype/derivation_clause.hpp index edb2f85..6de70e1 100644 --- a/include/newtype/derivation_clause.hpp +++ b/include/newtype/derivation_clause.hpp @@ -9,11 +9,6 @@ namespace nt { - /** - * A @p deriving clause type - * - * @tparam DerivableTags A list of tag types defining a set of derivable features - */ template struct derivation_clause { @@ -21,88 +16,48 @@ namespace nt { } - /** - * Check whether the derivation clause contains a given derivable - */ template auto constexpr operator()(derivable) const noexcept -> bool { return (std::is_same_v || ...); } - /** - * Check whether the derivation clause contains all derivables in a given lists - */ template auto constexpr operator()(derivable, derivable...) const noexcept -> bool { return (*this)(derivable{}) && (*this)(derivable{}...); } - /** - * Check whether this derivation clause is less than an other derivation clause - * - * A derivation clause is considered less than an other derivation clause iff. its set of derivables is a strict subset of - * the set derivables of the other. - */ template auto constexpr operator<(derivation_clause other) const noexcept -> bool { return (sizeof...(DerivableTags) < sizeof...(OtherDerivableTags)) && other(derivable{}...); } - /** - * Check whether this derivation clause is greater than an other derivation clause - * - * A derivation clause is considered greater than an other derivation clause iff. its set of derivables is a strict superset - * of the set derivables of the other. - */ template auto constexpr operator>(derivation_clause other) const noexcept -> bool { return other < *this; } - /** - * Check whether this derivation clause is equal to an other derivation clause - * - * Two derivation clauses are considered equal if both have the same set of derivables - */ template auto constexpr operator==(derivation_clause other) const noexcept -> bool { return sizeof...(DerivableTags) == sizeof...(OtherDerivableTags) && other(derivable{}...); } - /** - * Check whether this derivation clause is not equal to an other derivation clause - * - * Two derivation clauses are considered not equal if neither has the same set of derivables as the other - */ template auto constexpr operator!=(derivation_clause other) const noexcept -> bool { return !(*this == other); } - /** - * Check whether this derivation clause is less-than or equal to an other derivation clause - * - * @see nt::distinct::operator== - * @see nt::distinct::operator< - */ template auto constexpr operator<=(derivation_clause other) const noexcept -> bool { return *this < other || *this == other; } - /** - * Check whether this derivation clause is greater-than or equal to an other derivation clause - * - * @see nt::distinct::operator== - * @see nt::distinct::operator< - */ template auto constexpr operator>=(derivation_clause other) const noexcept -> bool { diff --git a/include/newtype/deriving.hpp b/include/newtype/deriving.hpp index e762c9b..ae10bab 100644 --- a/include/newtype/deriving.hpp +++ b/include/newtype/deriving.hpp @@ -10,9 +10,6 @@ namespace nt { - /** - * Create a new derivation clause with the given derivables - */ template auto constexpr deriving(derivable... features) noexcept -> derivation_clause { diff --git a/include/newtype/impl/type_traits_extensions.hpp b/include/newtype/impl/type_traits_extensions.hpp index ee33730..a9bd6af 100644 --- a/include/newtype/impl/type_traits_extensions.hpp +++ b/include/newtype/impl/type_traits_extensions.hpp @@ -14,125 +14,57 @@ namespace nt::impl inline namespace equality_comparable { - /** - * @brief A trait to test if a given type is comparable using operator== - * - * @tparam T The type to test - * @note This specialization forms the base case for non-equals-comparable T - */ template struct is_equality_comparable : std::false_type { }; - /** - * @brief A trait to test if a given type is comparable using operator== - * - * @tparam T The type to test - * @note This specialization forms the case for equals-comparable T - */ template struct is_equality_comparable() == std::declval())>> : std::true_type { }; - /** - * @brief A variable template to test if a given type is comparable using operator== - * - * @tparam T The type to test - */ template auto constexpr is_equality_comparable_v = is_equality_comparable::value; - /** - * @brief A trait to test if a given type is noexcept comparable using operator== - * - * @tparam T The type to test - * @note This specialization forms the base case for non-noexcept equals-comparable or non-equals-comparable T - */ template struct is_nothrow_equality_comparable : std::false_type { }; - /** - * @brief A trait to test if a given type is noexcept comparable using operator== - * - * @tparam T The type to test - * @note This specialization forms the case for equals-comparable T detemining if T is noexcept comparable using operator== - */ template struct is_nothrow_equality_comparable() == std::declval())>> : std::bool_constant() == std::declval())> { }; - /** - * @brief A variable template to test if a given type is noexcept comparable using operator== - * - * @tparam T The type to test - */ template auto constexpr is_nothrow_equality_comparable_v = is_nothrow_equality_comparable::value; - /** - * @brief A trait to test if a given type is comparable using operator!= - * - * @tparam T The type to test - * @note This specialization forms the base case for non-not-equals-comparable T - */ template struct is_inequality_comparable : std::false_type { }; - /** - * @brief A trait to test if a given type is comparable using operator!= - * - * @tparam T The type to test - * @note This specialization forms the case for not-equals-comparable T - */ template struct is_inequality_comparable() != std::declval())>> : std::true_type { }; - /** - * @brief A variable template to test if a given type is comparable using operator!= - * - * @tparam T The type to test - */ template auto constexpr is_inequality_comparable_v = is_inequality_comparable::value; - /** - * @brief A trait to test if a given type is noexcept comparable using operator!= - * - * @tparam T The type to test - * @note This specialization forms the base case for non-noexcept not-equals-comparable or non-not-equals-comparable T - */ template struct is_nothrow_inequality_comparable : std::false_type { }; - /** - * @brief A trait to test if a given type is noexcept comparable using operator== - * - * @tparam T The type to test - * @note This specialization forms the case for equals-comparable T detemining if T is noexcept comparable using operator!= - */ template struct is_nothrow_inequality_comparable() != std::declval())>> : std::bool_constant() != std::declval())> { }; - /** - * @brief A variable template to test if a given type is noexcept comparable using operator!= - * - * @tparam T The type to test - */ template auto constexpr is_nothrow_inequality_comparable_v = is_nothrow_inequality_comparable::value; @@ -141,250 +73,112 @@ namespace nt::impl inline namespace relationally_comparable { - /** - * @brief A trait to test if a given type is comparable using operator< - * - * @tparam T The type to test - * @note This specialization forms the base case for non-less-than-comparable T - */ template struct is_less_than_comparable : std::false_type { }; - /** - * @brief A trait to test if a given type is comparable using operator< - * - * @tparam T The type to test - * @note This specialization forms the case for less-than-comparable T - */ template struct is_less_than_comparable() < std::declval())>> : std::true_type { }; - /** - * @brief A variable template to test if a given type is comparable using operator< - * - * @tparam T The type to test - */ template auto constexpr is_less_than_comparable_v = is_less_than_comparable::value; - /** - * @brief A trait to test if a given type is noexcept comparable using operator< - * - * @tparam T The type to test - * @note This specialization forms the base case for non-noexcept less-than-comparable or non-less-than-comparable T - */ template struct is_nothrow_less_than_comparable : std::false_type { }; - /** - * @brief A trait to test if a given type is noexcept comparable using operator< - * - * @tparam T The type to test - * @note This specialization forms the case for less-than-comparable T detemining if T is noexcept comparable using operator< - */ template struct is_nothrow_less_than_comparable() < std::declval())>> : std::bool_constant() < std::declval())> { }; - /** - * @brief A variable template to test if a given type is noexcept comparable using operator< - * - * @tparam T The type to test - */ template auto constexpr is_nothrow_less_than_comparable_v = is_nothrow_less_than_comparable::value; - /** - * @brief A trait to test if a given type is comparable using operator> - * - * @tparam T The type to test - * @note This specialization forms the base case for non-greater-than-comparable T - */ template struct is_greater_than_comparable : std::false_type { }; - /** - * @brief A trait to test if a given type is comparable using operator> - * - * @tparam T The type to test - * @note This specialization forms the case for greater-than-comparable T - */ template struct is_greater_than_comparable() > std::declval())>> : std::true_type { }; - /** - * @brief A variable template to test if a given type is comparable using operator> - * - * @tparam T The type to test - */ template auto constexpr is_greater_than_comparable_v = is_greater_than_comparable::value; - /** - * @brief A trait to test if a given type is noexcept comparable using operator> - * - * @tparam T The type to test - * @note This specialization forms the base case for non-noexcept greater-than-comparable or non-greater-than-comparable T - */ template struct is_nothrow_greater_than_comparable : std::false_type { }; - /** - * @brief A trait to test if a given type is noexcept comparable using operator> - * - * @tparam T The type to test - * @note This specialization forms the case for greater-than-comparable T detemining if T is noexcept comparable using operator> - */ template struct is_nothrow_greater_than_comparable() > std::declval())>> : std::bool_constant() > std::declval())> { }; - /** - * @brief A variable template to test if a given type is noexcept comparable using operator> - * - * @tparam T The type to test - */ template auto constexpr is_nothrow_greater_than_comparable_v = is_nothrow_greater_than_comparable::value; - /** - * @brief A trait to test if a given type is comparable using operator<= - * - * @tparam T The type to test - * @note This specialization forms the base case for non-less-than-or-equal-to-comparable T - */ template struct is_less_than_equal_to_comparable : std::false_type { }; - /** - * @brief A trait to test if a given type is comparable using operator<= - * - * @tparam T The type to test - * @note This specialization forms the case for less-than-or-equal-to-comparable T - */ template struct is_less_than_equal_to_comparable() <= std::declval())>> : std::true_type { }; - /** - * @brief A variable template to test if a given type is comparable using operator<= - * - * @tparam T The type to test - */ template auto constexpr is_less_than_equal_to_comparable_v = is_less_than_equal_to_comparable::value; - /** - * @brief A trait to test if a given type is noexcept comparable using operator<= - * - * @tparam T The type to test - * @note This specialization forms the base case for non-noexcept less-than-or-equal-to-comparable or non-less-than-or-equal-to-comparable T - */ template struct is_nothrow_less_than_equal_to_comparable : std::false_type { }; - /** - * @brief A trait to test if a given type is noexcept comparable using operator<= - * - * @tparam T The type to test - * @note This specialization forms the case for less-than-or-equal-to-comparable T detemining if T is noexcept comparable using operator<= - */ template struct is_nothrow_less_than_equal_to_comparable() <= std::declval())>> : std::bool_constant() <= std::declval())> { }; - /** - * @brief A variable template to test if a given type is noexcept comparable using operator<= - * - * @tparam T The type to test - */ template auto constexpr is_nothrow_less_than_equal_to_comparable_v = is_nothrow_less_than_equal_to_comparable::value; - /** - * @brief A trait to test if a given type is comparable using operator>= - * - * @tparam T The type to test - * @note This specialization forms the base case for non-greater-than-or-equal-to-comparable T - */ template struct is_greater_than_equal_to_comparable : std::false_type { }; - /** - * @brief A trait to test if a given type is comparable using operator>= - * - * @tparam T The type to test - * @note This specialization forms the case for greater-than-or-equal-to-comparable T - */ template struct is_greater_than_equal_to_comparable() >= std::declval())>> : std::true_type { }; - /** - * @brief A variable template to test if a given type is comparable using operator>= - * - * @tparam T The type to test - */ template auto constexpr is_greater_than_equal_to_comparable_v = is_greater_than_equal_to_comparable::value; - /** - * @brief A trait to test if a given type is noexcept comparable using operator>= - * - * @tparam T The type to test - * @note This specialization forms the base case for non-noexcept greater-than-or-equal-to-comparable or - * non-greater-than-or-equal-to-comparable T - */ template struct is_nothrow_greater_than_equal_to_comparable : std::false_type { }; - /** - * @brief A trait to test if a given type is noexcept comparable using operator>= - * - * @tparam T The type to test - * @note This specialization forms the case for greater-than-or-equal-to-comparable T detemining if T is noexcept comparable using - * operator>= - */ template struct is_nothrow_greater_than_equal_to_comparable() >= std::declval())>> : std::bool_constant() >= std::declval())> { }; - /** - * @brief A variable template to test if a given type is noexcept comparable using operator>= - * - * @tparam T The type to test - */ template auto constexpr is_nothrow_greater_than_equal_to_comparable_v = is_nothrow_greater_than_equal_to_comparable::value; } // namespace relationally_comparable @@ -392,126 +186,58 @@ namespace nt::impl inline namespace iostreamable { - /** - * @brief A trait to test if a given type is output streamable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-output-streamable T - */ template struct is_output_streamable : std::false_type { }; - /** - * @brief A trait to test if a given type is output streamable - * - * @tparam T The type to test - * @note This specialization forms the case for output-streamable T - */ template struct is_output_streamable() << std::declval())>> : std::true_type { }; - /** - * @brief A variable template to test if a given type is output streamable - * - * @tparam T The type to test - */ template auto constexpr is_output_streamable_v = is_output_streamable::value; - /** - * @brief A trait to test if a given type is noexcept output streamable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-noexcept output-streamable or non-output-streamable T - */ template struct is_nothrow_output_streamable : std::false_type { }; - /** - * @brief A trait to test if a given type is noexcept output streamable - * - * @tparam T The type to test - * @note This specialization forms the case for output-streamable T detemining if T is noexcept output-streamable - */ template struct is_nothrow_output_streamable() << std::declval())>> : std::bool_constant() << std::declval())> { }; - /** - * @brief A variable template to test if a given type is noexcept output streamable - * - * @tparam T The type to test - */ template auto constexpr is_nothrow_output_streamable_v = is_nothrow_output_streamable::value; - /** - * @brief A trait to test if a given type is input streamable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-input-streamable T - */ template struct is_input_streamable : std::false_type { }; - /** - * @brief A trait to test if a given type is input streamable - * - * @tparam T The type to test - * @note This specialization forms the case for input-streamable T - */ template struct is_input_streamable() >> std::declval())>> : std::true_type { }; - /** - * @brief A variable template to test if a given type is input streamable - * - * @tparam T The type to test - */ template auto constexpr is_input_streamable_v = is_input_streamable::value; - /** - * @brief A trait to test if a given type is noexcept input streamable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-noexcept input-streamable or non-input-streamable T - */ template struct is_nothrow_input_streamable : std::false_type { }; - /** - * @brief A trait to test if a given type is noexcept input streamable - * - * @tparam T The type to test - * @note This specialization forms the case for input-streamable T detemining if T is noexcept input-streamable - */ template struct is_nothrow_input_streamable() >> std::declval())>> : std::bool_constant() >> std::declval())> { }; - /** - * @brief A variable template to test if a given type is noexcept input streamable - * - * @tparam T The type to test - */ template auto constexpr is_nothrow_input_streamable_v = is_nothrow_input_streamable::value; @@ -520,247 +246,111 @@ namespace nt::impl inline namespace arithmetic { - /** - * @brief A trait to test if a given type is addable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-addable T - */ template struct is_addable : std::false_type { }; - /** - * @brief A trait to test if a given type is addable - * - * @tparam T The type to test - * @note This specialization forms the case for addable T - */ template struct is_addable() + std::declval())>> : std::true_type { }; - /** - * @brief A variable template to test if a given type is addable - * - * @tparam T The type to test - */ template auto constexpr is_addable_v = is_addable::value; - /** - * @brief A trait to test if a given type is noexcept addable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-noexcept addable or non-addable T - */ template struct is_nothrow_addable : std::false_type { }; - /** - * @brief A trait to test if a given type is noexcept addable - * - * @tparam T The type to test - * @note This specialization forms the case for addable T detemining if T is noexcept addable - */ template struct is_nothrow_addable() + std::declval())>> : std::bool_constant() + std::declval())> { }; - /** - * @brief A variable template to test if a given type is noexcept addable - * - * @tparam T The type to test - */ template auto constexpr is_nothrow_addable_v = is_nothrow_addable::value; - /** - * @brief A trait to test if a given type is subtractable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-subtractable T - */ template struct is_subtractable : std::false_type { }; - /** - * @brief A trait to test if a given type is subtractable - * - * @tparam T The type to test - * @note This specialization forms the case for subtractable T - */ template struct is_subtractable() - std::declval())>> : std::true_type { }; - /** - * @brief A variable template to test if a given type is subtractable - * - * @tparam T The type to test - */ template auto constexpr is_subtractable_v = is_subtractable::value; - /** - * @brief A trait to test if a given type is noexcept subtractable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-noexcept subtractable or non-subtractable T - */ template struct is_nothrow_subtractable : std::false_type { }; - /** - * @brief A trait to test if a given type is noexcept subtractable - * - * @tparam T The type to test - * @note This specialization forms the case for subtractable T detemining if T is noexcept subtractable - */ template struct is_nothrow_subtractable() - std::declval())>> : std::bool_constant() - std::declval())> { }; - /** - * @brief A variable template to test if a given type is noexcept subtractable - * - * @tparam T The type to test - */ template auto constexpr is_nothrow_subtractable_v = is_nothrow_subtractable::value; - /** - * @brief A trait to test if a given type is multipliable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-multipliable T - */ template struct is_multipliable : std::false_type { }; - /** - * @brief A trait to test if a given type is multipliable - * - * @tparam T The type to test - * @note This specialization forms the case for multipliable T - */ template struct is_multipliable() * std::declval())>> : std::true_type { }; - /** - * @brief A variable template to test if a given type is multipliable - * - * @tparam T The type to test - */ template auto constexpr is_multipliable_v = is_multipliable::value; - /** - * @brief A trait to test if a given type is noexcept multipliable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-noexcept multipliable or non-multipliable T - */ template struct is_nothrow_multipliable : std::false_type { }; - /** - * @brief A trait to test if a given type is noexcept multipliable - * - * @tparam T The type to test - * @note This specialization forms the case for multipliable T detemining if T is noexcept multipliable - */ template struct is_nothrow_multipliable() * std::declval())>> : std::bool_constant() * std::declval())> { }; - /** - * @brief A variable template to test if a given type is noexcept multipliable - * - * @tparam T The type to test - */ template auto constexpr is_nothrow_multipliable_v = is_nothrow_multipliable::value; - /** - * @brief A trait to test if a given type is dividable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-dividable T - */ template struct is_dividable : std::false_type { }; - /** - * @brief A trait to test if a given type is dividable - * - * @tparam T The type to test - * @note This specialization forms the case for dividable T - */ template struct is_dividable() / std::declval())>> : std::true_type { }; - /** - * @brief A variable template to test if a given type is dividable - * - * @tparam T The type to test - */ template auto constexpr is_dividable_v = is_dividable::value; - /** - * @brief A trait to test if a given type is noexcept dividable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-noexcept dividable or non-dividable T - */ template struct is_nothrow_dividable : std::false_type { }; - /** - * @brief A trait to test if a given type is noexcept dividable - * - * @tparam T The type to test - * @note This specialization forms the case for dividable T detemining if T is noexcept dividable - */ template struct is_nothrow_dividable() / std::declval())>> : std::bool_constant() / std::declval())> { }; - /** - * @brief A variable template to test if a given type is noexcept dividable - * - * @tparam T The type to test - */ template auto constexpr is_nothrow_dividable_v = is_nothrow_dividable::value; @@ -769,247 +359,111 @@ namespace nt::impl inline namespace compound_arithmetic { - /** - * @brief A trait to test if a given type is add-assignable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-add-assignable T - */ template struct is_add_assignable : std::false_type { }; - /** - * @brief A trait to test if a given type is add-assignable - * - * @tparam T The type to test - * @note This specialization forms the case for add-assignable T - */ template struct is_add_assignable() += std::declval())>> : std::true_type { }; - /** - * @brief A variable template to test if a given type is add-assignable - * - * @tparam T The type to test - */ template auto constexpr is_add_assignable_v = is_add_assignable::value; - /** - * @brief A trait to test if a given type is noexcept add-assignable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-noexcept add-assignable or non-add-assignable T - */ template struct is_nothrow_add_assignable : std::false_type { }; - /** - * @brief A trait to test if a given type is noexcept add-assignable - * - * @tparam T The type to test - * @note This specialization forms the case for add-assignable T detemining if T is noexcept add-assignable - */ template struct is_nothrow_add_assignable() += std::declval())>> : std::bool_constant() += std::declval())> { }; - /** - * @brief A variable template to test if a given type is noexcept add-assignable - * - * @tparam T The type to test - */ template auto constexpr is_nothrow_add_assignable_v = is_nothrow_add_assignable::value; - /** - * @brief A trait to test if a given type is subtract-assignable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-subtract-assignable T - */ template struct is_subtract_assignable : std::false_type { }; - /** - * @brief A trait to test if a given type is subtract-assignable - * - * @tparam T The type to test - * @note This specialization forms the case for subtract-assignable T - */ template struct is_subtract_assignable() -= std::declval())>> : std::true_type { }; - /** - * @brief A variable template to test if a given type is subtract-assignable - * - * @tparam T The type to test - */ template auto constexpr is_subtract_assignable_v = is_subtract_assignable::value; - /** - * @brief A trait to test if a given type is noexcept subtract-assignable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-noexcept subtract-assignable or non-subtract-assignable T - */ template struct is_nothrow_subtract_assignable : std::false_type { }; - /** - * @brief A trait to test if a given type is noexcept subtract-assignable - * - * @tparam T The type to test - * @note This specialization forms the case for subtract-assignable T detemining if T is noexcept subtract-assignable - */ template struct is_nothrow_subtract_assignable() -= std::declval())>> : std::bool_constant() -= std::declval())> { }; - /** - * @brief A variable template to test if a given type is noexcept subtract-assignable - * - * @tparam T The type to test - */ template auto constexpr is_nothrow_subtract_assignable_v = is_nothrow_subtract_assignable::value; - /** - * @brief A trait to test if a given type is multiply-assignable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-multiply-assignable T - */ template struct is_multiply_assignable : std::false_type { }; - /** - * @brief A trait to test if a given type is multiply-assignable - * - * @tparam T The type to test - * @note This specialization forms the case for multiply-assignable T - */ template struct is_multiply_assignable() *= std::declval())>> : std::true_type { }; - /** - * @brief A variable template to test if a given type is multiply-assignable - * - * @tparam T The type to test - */ template auto constexpr is_multiply_assignable_v = is_multiply_assignable::value; - /** - * @brief A trait to test if a given type is noexcept multiply-assignable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-noexcept multiply-assignable or non-multiply-assignable T - */ template struct is_nothrow_multiply_assignable : std::false_type { }; - /** - * @brief A trait to test if a given type is noexcept multiply-assignable - * - * @tparam T The type to test - * @note This specialization forms the case for multiply-assignable T detemining if T is noexcept multiply-assignable - */ template struct is_nothrow_multiply_assignable() *= std::declval())>> : std::bool_constant() *= std::declval())> { }; - /** - * @brief A variable template to test if a given type is noexcept multiply-assignable - * - * @tparam T The type to test - */ template auto constexpr is_nothrow_multiply_assignable_v = is_nothrow_multiply_assignable::value; - /** - * @brief A trait to test if a given type is divide-assignable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-divide-assignable T - */ template struct is_divide_assignable : std::false_type { }; - /** - * @brief A trait to test if a given type is divide-assignable - * - * @tparam T The type to test - * @note This specialization forms the case for divide-assignable T - */ template struct is_divide_assignable() /= std::declval())>> : std::true_type { }; - /** - * @brief A variable template to test if a given type is divide-assignable - * - * @tparam T The type to test - */ template auto constexpr is_divide_assignable_v = is_divide_assignable::value; - /** - * @brief A trait to test if a given type is noexcept divide-assignable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-noexcept divide-assignable or non-divide-assignable T - */ template struct is_nothrow_divide_assignable : std::false_type { }; - /** - * @brief A trait to test if a given type is noexcept divide-assignable - * - * @tparam T The type to test - * @note This specialization forms the case for divide-assignable T detemining if T is noexcept divide-assignable - */ template struct is_nothrow_divide_assignable() /= std::declval())>> : std::bool_constant() /= std::declval())> { }; - /** - * @brief A variable template to test if a given type is noexcept divide-assignable - * - * @tparam T The type to test - */ template auto constexpr is_nothrow_divide_assignable_v = is_nothrow_divide_assignable::value; @@ -1018,34 +472,17 @@ namespace nt::impl inline namespace std_support { - /** - * @brief A trait to test if a given type is hashable - * - * @tparam T The type to test - * @note This specialization forms the base case for non-hashable T - */ template struct is_hashable : std::false_type { }; - /** - * @brief A trait to test if a given type is hashable - * - * @tparam T The type to test - * @note This specialization forms the case for hashable T - */ template struct is_hashable const &>()(std::declval()))>> : std::is_same const &>()(std::declval()))> { }; - /** - * @brief A variable template to test if a given type is hashable - * - * @tparam T The type to test - */ template auto constexpr is_hashable_v = is_hashable::value; diff --git a/include/newtype/new_type.hpp b/include/newtype/new_type.hpp index 474ac88..24ac71a 100644 --- a/include/newtype/new_type.hpp +++ b/include/newtype/new_type.hpp @@ -16,9 +16,6 @@ namespace nt { - /** - * Create a new type based on an existing one - */ template class new_type : impl::new_type_move_assignment @@ -79,114 +76,50 @@ namespace nt using super = impl::new_type_move_assignment; public: - /// Member Type Aliases - - /** - * The base type of this nt::new_type - */ using base_type = BaseType; - - /** - * The tag type of this nt::new_type - */ using tag_type = TagType; - - /** - * The type of the derivation clause of this nt::newtype - */ using derivation_clause_type = decltype(DerivationClause); - /// Static Data Members - - /** - * The derivation clause fo this nt::new_type - */ auto constexpr static derivation_clause = DerivationClause; - /// Constructors - using super::super; - /** - * Construct an instance of this nt::new_type by default initializing the contained object - */ constexpr new_type() noexcept(std::is_nothrow_default_constructible_v) = default; - - /** - * Copy-construct an instance of this nt::new_type from an existing one - */ constexpr new_type(new_type const &) noexcept(std::is_nothrow_copy_constructible_v) = default; - - /** - * Move-construct an instance of this nt::new_type from an existing one - */ constexpr new_type(new_type &&) noexcept(std::is_nothrow_move_constructible_v) = default; - /// Assignment Operators - - /** - * Copy-assign the value of an existing instance of this nt::new_type to this instance - */ auto constexpr operator=(new_type const &) noexcept(std::is_nothrow_copy_assignable_v) -> new_type & = default; - - /** - * Move-assign the value of an existing instance of this nt::new_type to this instance - */ auto constexpr operator=(new_type &&) noexcept(std::is_nothrow_move_assignable_v) -> new_type & = default; - /// Accessors - - /** - * Retrieve a copy of the object contained by this new_type object - */ auto constexpr decay() const noexcept(std::is_nothrow_copy_constructible_v) -> BaseType { return this->m_value; } - /** - * Retrieve a copy of the object contained by this new_type object - */ template * = nullptr> constexpr operator base_type() const noexcept(std::is_nothrow_copy_constructible_v) { return decay(); } - /** - * Convert this instance into the equivalent base type value - */ template * = nullptr> explicit constexpr operator base_type() const noexcept(std::is_nothrow_copy_constructible_v) { return decay(); } - /// Member Access Through Pointer - - /** - * Perform "member access through pointer" via a pointer to object contained by this new_type - */ template auto constexpr operator-> () noexcept -> std::enable_if_t { return std::addressof(this->m_value); } - /** - * Perform "member access through pointer" via a pointer to object contained by this new_type - */ template auto constexpr operator-> () const noexcept -> std::enable_if_t { return std::addressof(this->m_value); } - /// Iterators - - /** - * Get an iterator to the beginning of the object contained by this new_type - */ template * = nullptr> auto constexpr begin() -> std::enable_if_t, typename NewType::iterator> @@ -194,9 +127,6 @@ namespace nt return this->m_value.begin(); } - /** - * Get an iterator to the beginning of the object contained by this new_type - */ template auto constexpr begin() const -> std::enable_if_t, typename NewType::const_iterator> @@ -212,11 +142,6 @@ namespace nt } }; - /// Equality Comparison Operators - - /** - * Check two instances of new_type for equality - */ template auto constexpr operator==(new_type const & lhs, @@ -226,9 +151,6 @@ namespace nt return lhs.decay() == rhs.decay(); } - /** - * Check an instance of new_type for equality with an instance of BaseType - */ template auto constexpr operator==(new_type const & lhs, BaseType const & rhs) noexcept(impl::is_nothrow_equality_comparable_v) @@ -237,9 +159,6 @@ namespace nt return lhs.decay() == rhs; } - /** - * Check an instance of BaseType for equality with an instance of new_type - */ template auto constexpr operator==(BaseType const & lhs, @@ -249,9 +168,6 @@ namespace nt return lhs == rhs.decay(); } - /** - * Check two instances of new_type for in-equality - */ template auto constexpr operator!=(new_type const & lhs, @@ -261,9 +177,6 @@ namespace nt return lhs.decay() != rhs.decay(); } - /** - * Check an instance of new_type for in-equality with an instance of BaseType - */ template auto constexpr operator!=(new_type const & lhs, BaseType const & rhs) noexcept(impl::is_nothrow_inequality_comparable_v) @@ -272,9 +185,6 @@ namespace nt return lhs.decay() != rhs; } - /** - * Check an instance of BaseType for in-equality with an instance of new_type - */ template auto constexpr operator!=(BaseType const & lhs, @@ -284,11 +194,6 @@ namespace nt return lhs != rhs.decay(); } - /// Relational Comparison Operators - - /** - * Compare two instances of the same new_type using '<' (less-than) - */ template auto constexpr operator<(new_type const & lhs, @@ -298,9 +203,6 @@ namespace nt return lhs.decay() < rhs.decay(); } - /** - * Compare two instances of the same new_type using '>' (greater-than) - */ template auto constexpr operator>(new_type const & lhs, @@ -310,9 +212,6 @@ namespace nt return lhs.decay() > rhs.decay(); } - /** - * Compare two instances of the same new_type using '<=' (less-than-equal) - */ template auto constexpr operator<=(new_type const & lhs, @@ -322,9 +221,6 @@ namespace nt return lhs.decay() <= rhs.decay(); } - /** - * Compare two instances of the same new_type using '>=' (greater-than-equal) - */ template auto constexpr operator>=(new_type const & lhs, @@ -334,11 +230,6 @@ namespace nt return lhs.decay() >= rhs.decay(); } - /// Stream I/O Operators - - /** - * Write an instance of new_type to a standard ostream - */ template auto operator<<(std::basic_ostream & output, new_type const & source) noexcept( impl::is_nothrow_output_streamable_v, BaseType>) @@ -348,9 +239,6 @@ namespace nt return output << source.decay(); } - /** - * Read an instance of new_type from the a standard istream - */ template auto operator>>(std::basic_istream & input, new_type & target) noexcept( impl::is_nothrow_input_streamable_v, BaseType>) @@ -360,11 +248,6 @@ namespace nt return input >> target.m_value; } - /// Arithmetic Operators - - /** - * Add two instances of the same new_type - */ template auto constexpr operator+(new_type const & lhs, new_type const & rhs) noexcept( @@ -374,9 +257,6 @@ namespace nt return {lhs.decay() + rhs.decay()}; } - /** - * Add two instances of the same new_type by overwriting the first one - */ template auto constexpr operator+=(new_type & lhs, new_type const & rhs) noexcept(impl::is_nothrow_add_assignable_v) @@ -387,9 +267,6 @@ namespace nt return lhs; } - /** - * Subtract two instances of the same new_type - */ template auto constexpr operator-(new_type const & lhs, new_type const & rhs) noexcept( @@ -399,9 +276,6 @@ namespace nt return {lhs.decay() - rhs.decay()}; } - /** - * Subtract two instances of the same new_type by overwriting the first one - */ template auto constexpr operator-=(new_type & lhs, @@ -413,9 +287,6 @@ namespace nt return lhs; } - /** - * Multiply two instances of the same new_type - */ template auto constexpr operator*(new_type const & lhs, new_type const & rhs) noexcept( @@ -425,9 +296,6 @@ namespace nt return {lhs.decay() * rhs.decay()}; } - /** - * Multiply two instances of the same new_type by overwriting the first one - */ template auto constexpr operator*=(new_type & lhs, @@ -439,9 +307,6 @@ namespace nt return lhs; } - /** - * Divide two instances of the same nt::new_type - */ template auto constexpr operator/(new_type const & lhs, new_type const & rhs) noexcept( @@ -451,9 +316,6 @@ namespace nt return {lhs.decay() / rhs.decay()}; } - /** - * Divide two instances of the same new_type by overwriting the first one - */ template auto constexpr operator/=(new_type & lhs, new_type const & rhs) noexcept(impl::is_nothrow_divide_assignable_v) @@ -464,11 +326,6 @@ namespace nt return lhs; } - /// Iterators - - /** - * Get an iterator to the beginning of the object contained by an instance of new_type - */ template auto constexpr begin(new_type & obj) -> std::enable_if_t, @@ -477,9 +334,6 @@ namespace nt return begin(obj.m_value); } - /** - * Get a constant iterator to the beginning of the object contained by an instance of new_type - */ template auto constexpr begin(new_type const & obj) -> std::enable_if_t, @@ -500,9 +354,6 @@ namespace nt namespace std { - /** - * Hash an instance of new_type using the hash implementation of the base type - */ template struct hash> { -- cgit v1.2.3