1 // Boost.Geometry Index
2 //
3 // R-tree nodes static visitor related code
4 //
5 // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
6 //
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10
11 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_VISITOR_HPP
12 #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_VISITOR_HPP
13
14 #include <boost/variant/apply_visitor.hpp>
15 #include <boost/variant/get.hpp>
16 #include <boost/variant/variant.hpp>
17
18 namespace boost { namespace geometry { namespace index {
19
20 namespace detail { namespace rtree {
21
22 // nodes variants forward declarations
23
24 template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
25 struct variant_internal_node;
26
27 template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
28 struct variant_leaf;
29
30 // nodes conversion
31
32 template <typename V, typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
get(boost::variant<variant_leaf<Value,Parameters,Box,Allocators,Tag>,variant_internal_node<Value,Parameters,Box,Allocators,Tag>> & v)33 inline V & get(
34 boost::variant<
35 variant_leaf<Value, Parameters, Box, Allocators, Tag>,
36 variant_internal_node<Value, Parameters, Box, Allocators, Tag>
37 > & v)
38 {
39 return boost::get<V>(v);
40 }
41
42 // apply visitor
43
44 template <typename Visitor, typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
apply_visitor(Visitor & v,boost::variant<variant_leaf<Value,Parameters,Box,Allocators,Tag>,variant_internal_node<Value,Parameters,Box,Allocators,Tag>> & n)45 inline void apply_visitor(Visitor & v,
46 boost::variant<
47 variant_leaf<Value, Parameters, Box, Allocators, Tag>,
48 variant_internal_node<Value, Parameters, Box, Allocators, Tag>
49 > & n)
50 {
51 boost::apply_visitor(v, n);
52 }
53
54 template <typename Visitor, typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
apply_visitor(Visitor & v,boost::variant<variant_leaf<Value,Parameters,Box,Allocators,Tag>,variant_internal_node<Value,Parameters,Box,Allocators,Tag>> const & n)55 inline void apply_visitor(Visitor & v,
56 boost::variant<
57 variant_leaf<Value, Parameters, Box, Allocators, Tag>,
58 variant_internal_node<Value, Parameters, Box, Allocators, Tag>
59 > const& n)
60 {
61 boost::apply_visitor(v, n);
62 }
63
64 }} // namespace detail::rtree
65
66 }}} // namespace boost::geometry::index
67
68 #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_VISITOR_HPP
69