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.");
69 template<
typename ArcTraits>
72 typename std::enable_if<
74 typename ArcProperties<ArcTraits>::isExplicit,
75 typename ArcProperties<ArcTraits>::isOrdered>::value,
79 Cannot use explicit arc storage for arcs that do not satisfy the explicit property.)");
82 "Cannot use ordered storage for unordered arcs.");
93 template<
typename ArcTraits>
96 typename std::enable_if<ArcProperties<ArcTraits>::isImplicit::value, ArcTraits>::type>
101 "Cannot use implicit storage for this arc type.");
102 using type = ArcTraits;
110 template<
typename Iterable>
114 static std::true_type testIterable(
115 decltype(std::distance(std::declval<X>(), std::declval<X>()))*);
117 static std::false_type testIterable(...);
120 using type = decltype(testIterable<Iterable>(
nullptr));
121 static constexpr
bool value = type::value;
124 template<
typename Container>
128 static std::true_type testContainer(
129 decltype(std::distance(std::declval<X>().begin(), std::declval<X>().end()))*);
131 static std::false_type testContainer(...);
134 using type = decltype(testContainer<Container>(
nullptr));
135 static constexpr
bool value = type::value;
138 template<
typename T,
typename =
void>
146 typename std::enable_if<std::is_base_of<
147 std::forward_iterator_tag,
148 typename std::iterator_traits<T>::iterator_category>::value>::type> :
public std::true_type
152 template<
typename T,
typename =
void>
160 typename std::enable_if<
161 is_forward_iterable<decltype(std::declval<T>().begin())>::value &&
162 is_forward_iterable<decltype(std::declval<T>().end())>::value>::type> :
public std::true_type
166 template<
typename API,
typename Functor,
typename Input>
170 static std::true_type testVisitable(
171 decltype(std::declval<X>().visit(std::declval<Input>(), std::declval<const Functor&>()))*);
173 static std::false_type testVisitable(...);
176 using type = decltype(testVisitable<API>(
nullptr));
177 static constexpr
bool value = type::value;
180 template<
typename Functor,
typename Input>
184 static std::true_type testAccepts(decltype(std::declval<X>()(std::declval<Input>()))*);
186 static std::false_type testAccepts(...);
189 using type = decltype(testAccepts<Functor>(
nullptr));
190 static constexpr
bool value = type::value;
194 template<
typename Traits,
typename =
void>
201 template<
typename Traits>
204 using type =
typename Traits::NodeContainer;
207 template<
typename Traits>
210 using NodeTypes =
typename Traits::NodeTypes;
211 using ArcTypes =
typename Traits::ArcTypes;