11 #ifndef INCLUDE_MOLASSEMBLER_TEMPLE_CONTAINER_TRAITS_H
12 #define INCLUDE_MOLASSEMBLER_TEMPLE_CONTAINER_TRAITS_H
19 namespace Molassembler {
34 using detector_t =
typename make_void<T>::type;
36 template<
class Default,
class,
template<
class...>
class,
class...>
38 using value_t = std::false_type;
42 template<
class Default,
template<
class...>
class Op,
class... Args>
43 struct detector<Default, detector_t<Op<Args...> >, Op, Args...> {
44 using value_t = std::true_type;
45 using type = Op<Args...>;
50 template<
template<
class...>
class Op,
class... Args>
51 using is_detected =
typename detector<nonesuch, void, Op, Args...>::value_t;
53 template<
template<
class...>
class Op,
class... Args>
54 constexpr
bool is_detected_v = is_detected<Op, Args...>::value;
56 template<
class Container>
57 using TestHasInsert = decltype(
58 std::declval<Container>().insert(
59 std::declval<getValueType<Container>>()
63 template<
class Container>
64 using TestHasPushBack = decltype(
65 std::declval<Container>().push_back(
66 std::declval<getValueType<Container>>()
70 template<
class Container>
71 using TestHasEmplace = decltype(
72 std::declval<Container>().emplace(
73 std::declval<getValueType<Container>>()
77 template<
class Container>
78 using TestHasEmplaceBack = decltype(
79 std::declval<Container>().emplace_back(
80 std::declval<getValueType<Container>>()
84 template<
class Container>
85 using TestHasSize = decltype(std::declval<Container>().
size());
87 template<
class Container>
88 using TestHasReserve = decltype(std::declval<Container>().reserve(0));
90 template<
class Container>
91 using TestIsTuplelike = decltype(std::tuple_size<Container>::value);
93 template<
class Container>
94 using TestIsPairlike = decltype(std::declval<Container>().
first);
102 template<
class Container>
103 struct hasInsert : std::integral_constant<bool, Detail::is_detected_v<Detail::TestHasInsert, Container>> {};
109 template<
class Container>
110 struct hasPushBack : std::integral_constant<bool, Detail::is_detected_v<Detail::TestHasPushBack, Container>> {};
116 template<
class Container>
117 struct hasEmplace : std::integral_constant<bool, Detail::is_detected_v<Detail::TestHasEmplace, Container>> {};
123 template<
class Container>
124 struct hasEmplaceBack : std::integral_constant<bool, Detail::is_detected_v<Detail::TestHasEmplaceBack, Container>> {};
130 template<
class Container>
131 struct hasSize : std::integral_constant<bool, Detail::is_detected_v<Detail::TestHasSize, Container>> {};
137 template<
class Container>
138 struct hasReserve : std::integral_constant<bool, Detail::is_detected_v<Detail::TestHasReserve, Container>> {};
144 template<
class Container>
145 struct isTuplelike : std::integral_constant<bool, Detail::is_detected_v<Detail::TestIsTuplelike, Container>> {};
151 template<
class Container>
152 struct isPairlike : std::integral_constant<bool, Detail::is_detected_v<Detail::TestIsPairlike, Container> && !isTuplelike<Container>::value> {};
Has a push_back method accepting the container value type.
Definition: ContainerTraits.h:110
Has an emplace method accepting the container value type.
Definition: ContainerTraits.h:117
unsigned size(Shape shape)
Fetch the number of vertices of a shape.
Has a nullary size member.
Definition: ContainerTraits.h:131
Has an emplace_back method accepting the container value type.
Definition: ContainerTraits.h:124
Has first and second members, but no support for std::tuple_size.
Definition: ContainerTraits.h:152
Provides a few basic function and container traits.
Has support for std::tuple_size.
Definition: ContainerTraits.h:145
constexpr Get< 0 > first
Calls std::get<0> on any argument it is invoked with.
Definition: Functor.h:123
Has an insert method accepting the container value type.
Definition: ContainerTraits.h:103
Has a reserve member accepting an integer type.
Definition: ContainerTraits.h:138