11 #ifndef smtk_graph_TypeTraits_h
12 #define smtk_graph_TypeTraits_h
14 #include "smtk/common/TypeTraits.h"
17 #include "smtk/graph/ArcProperties.h"
18 #include "smtk/graph/ExplicitArcs.h"
23 #include <type_traits>
36 template<
typename ArcTraits,
typename Storage>
45 template<
typename ArcTraits>
48 typename std::enable_if<
50 typename ArcProperties<ArcTraits>::isExplicit,
51 negation<typename ArcProperties<ArcTraits>::isOrdered>>::value,
55 Cannot use explicit arc storage for arcs that do not satisfy the explicit property.)");
58 "Ordered explicit arcs aren't yet supported.");
75 template<
typename ArcTraits>
78 typename std::enable_if<
80 typename ArcProperties<ArcTraits>::isExplicit,
81 typename ArcProperties<ArcTraits>::isOrdered>::value,
85 Cannot use explicit arc storage for arcs that do not satisfy the explicit property.)");
88 "Cannot use ordered storage for unordered arcs.");
105 template<
typename ArcTraits>
108 typename std::enable_if<ArcProperties<ArcTraits>::isImplicit::value, ArcTraits>::type>
113 "Cannot use implicit storage for this arc type.");
114 using type = ArcTraits;
128 template<
typename Iterable>
132 static std::true_type testIterable(
133 decltype(std::distance(std::declval<X>(), std::declval<X>()))*);
135 static std::false_type testIterable(...);
138 using type = decltype(testIterable<Iterable>(
nullptr));
139 static constexpr
bool value = type::value;
142 template<
typename Container>
146 static std::true_type testContainer(
147 decltype(std::distance(std::declval<X>().begin(), std::declval<X>().end()))*);
149 static std::false_type testContainer(...);
152 using type = decltype(testContainer<Container>(
nullptr));
153 static constexpr
bool value = type::value;
156 template<
typename T,
typename =
void>
164 typename std::enable_if<std::is_base_of<
165 std::forward_iterator_tag,
166 typename std::iterator_traits<T>::iterator_category>::value>::type> :
public std::true_type
170 template<
typename T,
typename =
void>
178 typename std::enable_if<
179 is_forward_iterable<decltype(std::declval<T>().begin())>::value &&
180 is_forward_iterable<decltype(std::declval<T>().end())>::value>::type> :
public std::true_type
184 template<
typename API,
typename Functor,
typename Input>
188 static std::true_type testVisitable(
189 decltype(std::declval<X>().visit(std::declval<Input>(), std::declval<const Functor&>()))*);
191 static std::false_type testVisitable(...);
194 using type = decltype(testVisitable<API>(
nullptr));
195 static constexpr
bool value = type::value;
198 template<
typename Functor,
typename Input>
202 static std::true_type testAccepts(decltype(std::declval<X>()(std::declval<Input>()))*);
204 static std::false_type testAccepts(...);
207 using type = decltype(testAccepts<Functor>(
nullptr));
208 static constexpr
bool value = type::value;
212 template<
typename Traits,
typename =
void>
219 template<
typename Traits>
222 using type =
typename Traits::NodeContainer;
225 template<
typename Traits>
228 using NodeTypes =
typename Traits::NodeTypes;
229 using ArcTypes =
typename Traits::ArcTypes;