OSSIA
Open Scenario System for Interactive Application
small_graph.hpp
1 #pragma once
2 #include <ossia/detail/config.hpp>
3 
4 #include <ossia/detail/small_vector.hpp>
5 
6 #include <boost/graph/adjacency_list.hpp>
7 
8 #if defined(OSSIA_SMALL_VECTOR)
9 namespace boost
10 {
11 
12 struct smallvecS
13 {
14 };
15 
16 namespace detail
17 {
18 
19 template <class Directed>
20 struct is_random_access;
21 template <>
22 struct is_random_access<smallvecS>
23 {
24  enum
25  {
26  value = true
27  };
28  typedef mpl::true_ type;
29 };
30 }
31 
32 template <class ValueType>
33 struct container_gen<smallvecS, ValueType>
34 {
35  // using Allocator = typename Alloc::template rebind<ValueType>::other Allocator;
36 
37  // Needed because tests allocate graphs on the stack and that's too much
38 #if defined(OSSIA_TESTNG)
39  static constexpr std::size_t small_vec_size = 16;
40 #else
41  static constexpr std::size_t small_vec_size = 1024;
42 #endif
43  typedef ossia::small_vector<ValueType, small_vec_size> type;
44 };
45 
46 template <>
47 struct parallel_edge_traits<smallvecS>
48 {
49  typedef allow_parallel_edge_tag type;
50 };
51 
52 namespace container
53 {
54 template <class T, std::size_t N>
55 graph_detail::vector_tag container_category(const ossia::small_vector<T, N>&)
56 {
57  return graph_detail::vector_tag();
58 }
59 
60 template <class T, std::size_t N>
61 graph_detail::unstable_tag iterator_stability(const ossia::small_vector<T, N>&)
62 {
63  return graph_detail::unstable_tag();
64 }
65 }
66 
67 namespace graph_detail
68 {
69 using container::container_category;
70 using container::iterator_stability;
71 
72 template <class T, std::size_t N>
73 struct container_traits<ossia::small_vector<T, N>>
74 {
75  typedef vector_tag category;
76  typedef unstable_tag iterator_stability;
77 };
78 }
79 
80 using container::container_category;
81 using container::iterator_stability;
82 
83 }
84 #else
85 namespace boost
86 {
87 using smallvecS = vecS;
88 }
89 #endif
Definition: git_info.h:7