Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions include/strong_type/type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
namespace strong {
struct uninitialized_t {
};
static constexpr uninitialized_t uninitialized{};
constexpr uninitialized_t uninitialized{};

template<typename M, typename T>
using modifier = typename M::template modifier<T>;
Expand Down Expand Up @@ -236,7 +236,7 @@ struct require_move_assignable
};

template <typename ...>
static constexpr bool always_false = false;
constexpr bool always_false = false;

template <bool> struct valid_type;
template <>
Expand All @@ -247,11 +247,10 @@ using void_t = void;


template <typename Needle, typename Type, typename Modifier>
static constexpr bool modifier_is
constexpr bool modifier_is
= std::is_base_of<modifier<Needle, Type>, modifier<Modifier,Type>>::value;

template <typename Needle, typename Type, typename Haystack>
static
constexpr
bool
type_implements
Expand All @@ -264,7 +263,6 @@ template <
typename Type,
typename ... Ms
>
static
constexpr
bool
modifier_is<Needle, Type, Modifier<Ms...>>
Expand All @@ -276,7 +274,6 @@ template <
typename Type,
typename ... Haystack
>
static
constexpr
bool type_implements<Modifier<Needles...>, Type, Modifier<Haystack...>>
= (modifier_is<Modifier<Needles>, Type, Modifier<Haystack...>> && ...);
Expand Down Expand Up @@ -339,15 +336,15 @@ type_implements<Modifier<Needles...>, Type, Modifier<Haystack...>>
#endif

template <typename T, typename M>
static constexpr bool type_is = false;
constexpr bool type_is = false;

#if __cplusplus >= 201703L
template <typename T, typename Tag, typename ... Ms, typename M>
static constexpr bool type_is<strong::type<T, Tag, Ms...>, M>
constexpr bool type_is<strong::type<T, Tag, Ms...>, M>
= (impl::type_implements<M, strong::type<T, Tag, Ms...>, Ms> || ...);
#else
template <typename T, typename Tag, typename ... Ms, typename M>
static constexpr bool type_is<strong::type<T, Tag, Ms...>, M>
constexpr bool type_is<strong::type<T, Tag, Ms...>, M>
= impl::disjunction<std::integral_constant<bool, impl::type_implements<M, strong::type<T, Tag, Ms...>, Ms>>...>::value;
#endif

Expand All @@ -359,7 +356,7 @@ using get_strong = decltype(get_strong_(static_cast<T*>(nullptr)));
}

template <typename T, typename M>
static constexpr bool type_is_v = impl::type_is<impl::get_strong<T>, M>;
constexpr bool type_is_v = impl::type_is<impl::get_strong<T>, M>;

template <typename T, typename M>
using type_is = std::integral_constant<bool, type_is_v<T,M>>;
Expand Down