add boost on mac

This commit is contained in:
Bassem Girgis
2019-08-10 16:38:17 -05:00
parent 861b918727
commit be945cb63b
14105 changed files with 2714968 additions and 0 deletions

View File

@@ -0,0 +1,85 @@
// Boost.Geometry Index
//
// R-tree node concept
//
// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
//
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_CONCEPT_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_CONCEPT_HPP
namespace boost { namespace geometry { namespace index {
namespace detail { namespace rtree {
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct node
{
BOOST_MPL_ASSERT_MSG(
(false),
NOT_IMPLEMENTED_FOR_THIS_TAG_TYPE,
(node));
};
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct internal_node
{
BOOST_MPL_ASSERT_MSG(
(false),
NOT_IMPLEMENTED_FOR_THIS_TAG_TYPE,
(internal_node));
};
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct leaf
{
BOOST_MPL_ASSERT_MSG(
(false),
NOT_IMPLEMENTED_FOR_THIS_TAG_TYPE,
(leaf));
};
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag, bool IsVisitableConst>
struct visitor
{
BOOST_MPL_ASSERT_MSG(
(false),
NOT_IMPLEMENTED_FOR_THIS_TAG_TYPE,
(visitor));
};
template <typename Allocator, typename Value, typename Parameters, typename Box, typename Tag>
class allocators
{
BOOST_MPL_ASSERT_MSG(
(false),
NOT_IMPLEMENTED_FOR_THIS_TAG_TYPE,
(allocators));
};
template <typename Allocators, typename Node>
struct create_node
{
BOOST_MPL_ASSERT_MSG(
(false),
NOT_IMPLEMENTED_FOR_THIS_NODE_TYPE,
(create_node));
};
template <typename Allocators, typename Node>
struct destroy_node
{
BOOST_MPL_ASSERT_MSG(
(false),
NOT_IMPLEMENTED_FOR_THIS_NODE_TYPE,
(destroy_node));
};
}} // namespace detail::rtree
}}} // namespace boost::geometry::index
#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_CONCEPT_HPP

View File

@@ -0,0 +1,212 @@
// Boost.Geometry Index
//
// R-tree nodes
//
// Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
//
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_NODE_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_NODE_HPP
#include <boost/container/vector.hpp>
#include <boost/geometry/index/detail/varray.hpp>
#include <boost/geometry/index/detail/rtree/node/concept.hpp>
#include <boost/geometry/index/detail/rtree/node/pairs.hpp>
#include <boost/geometry/index/detail/rtree/node/node_elements.hpp>
#include <boost/geometry/index/detail/rtree/node/scoped_deallocator.hpp>
//#include <boost/geometry/index/detail/rtree/node/weak_visitor.hpp>
//#include <boost/geometry/index/detail/rtree/node/weak_dynamic.hpp>
//#include <boost/geometry/index/detail/rtree/node/weak_static.hpp>
#include <boost/geometry/index/detail/rtree/node/variant_visitor.hpp>
#include <boost/geometry/index/detail/rtree/node/variant_dynamic.hpp>
#include <boost/geometry/index/detail/rtree/node/variant_static.hpp>
#include <boost/geometry/index/detail/rtree/node/subtree_destroyer.hpp>
#include <boost/geometry/algorithms/expand.hpp>
#include <boost/geometry/index/detail/rtree/visitors/is_leaf.hpp>
#include <boost/geometry/index/detail/algorithms/bounds.hpp>
#include <boost/geometry/index/detail/is_bounding_geometry.hpp>
namespace boost { namespace geometry { namespace index {
namespace detail { namespace rtree {
// elements box
template <typename Box, typename FwdIter, typename Translator>
inline Box elements_box(FwdIter first, FwdIter last, Translator const& tr)
{
Box result;
// Only here to suppress 'uninitialized local variable used' warning
// until the suggestion below is not implemented
geometry::assign_inverse(result);
//BOOST_GEOMETRY_INDEX_ASSERT(first != last, "non-empty range required");
// NOTE: this is not elegant temporary solution,
// reference to box could be passed as parameter and bool returned
if ( first == last )
return result;
detail::bounds(element_indexable(*first, tr), result);
++first;
for ( ; first != last ; ++first )
geometry::expand(result, element_indexable(*first, tr));
return result;
}
// Enlarge bounds of a leaf node WRT epsilon if needed.
// It's because Points and Segments are compared WRT machine epsilon.
// This ensures that leafs bounds correspond to the stored elements.
// NOTE: this is done only if the Indexable is not a Box
// in the future don't do it also for NSphere
template <typename Box, typename FwdIter, typename Translator>
inline Box values_box(FwdIter first, FwdIter last, Translator const& tr)
{
typedef typename std::iterator_traits<FwdIter>::value_type element_type;
BOOST_MPL_ASSERT_MSG((is_leaf_element<element_type>::value),
SHOULD_BE_CALLED_ONLY_FOR_LEAF_ELEMENTS,
(element_type));
Box result = elements_box<Box>(first, last, tr);
#ifdef BOOST_GEOMETRY_INDEX_EXPERIMENTAL_ENLARGE_BY_EPSILON
if (BOOST_GEOMETRY_CONDITION((
! is_bounding_geometry
<
typename indexable_type<Translator>::type
>::value)))
{
geometry::detail::expand_by_epsilon(result);
}
#endif
return result;
}
// destroys subtree if the element is internal node's element
template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
struct destroy_element
{
typedef typename Options::parameters_type parameters_type;
typedef typename rtree::internal_node<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
typedef typename rtree::leaf<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
typedef rtree::subtree_destroyer<Value, Options, Translator, Box, Allocators> subtree_destroyer;
inline static void apply(typename internal_node::elements_type::value_type & element, Allocators & allocators)
{
subtree_destroyer dummy(element.second, allocators);
element.second = 0;
}
inline static void apply(typename leaf::elements_type::value_type &, Allocators &) {}
};
// destroys stored subtrees if internal node's elements are passed
template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
struct destroy_elements
{
template <typename Range>
inline static void apply(Range & elements, Allocators & allocators)
{
apply(boost::begin(elements), boost::end(elements), allocators);
}
template <typename It>
inline static void apply(It first, It last, Allocators & allocators)
{
typedef boost::mpl::bool_<
boost::is_same<
Value, typename std::iterator_traits<It>::value_type
>::value
> is_range_of_values;
apply_dispatch(first, last, allocators, is_range_of_values());
}
private:
template <typename It>
inline static void apply_dispatch(It first, It last, Allocators & allocators,
boost::mpl::bool_<false> const& /*is_range_of_values*/)
{
typedef rtree::subtree_destroyer<Value, Options, Translator, Box, Allocators> subtree_destroyer;
for ( ; first != last ; ++first )
{
subtree_destroyer dummy(first->second, allocators);
first->second = 0;
}
}
template <typename It>
inline static void apply_dispatch(It /*first*/, It /*last*/, Allocators & /*allocators*/,
boost::mpl::bool_<true> const& /*is_range_of_values*/)
{}
};
// clears node, deletes all subtrees stored in node
template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
struct clear_node
{
typedef typename Options::parameters_type parameters_type;
typedef typename rtree::node<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type node;
typedef typename rtree::internal_node<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
typedef typename rtree::leaf<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
inline static void apply(node & node, Allocators & allocators)
{
rtree::visitors::is_leaf<Value, Options, Box, Allocators> ilv;
rtree::apply_visitor(ilv, node);
if ( ilv.result )
{
apply(rtree::get<leaf>(node), allocators);
}
else
{
apply(rtree::get<internal_node>(node), allocators);
}
}
inline static void apply(internal_node & internal_node, Allocators & allocators)
{
destroy_elements<Value, Options, Translator, Box, Allocators>::apply(rtree::elements(internal_node), allocators);
rtree::elements(internal_node).clear();
}
inline static void apply(leaf & leaf, Allocators &)
{
rtree::elements(leaf).clear();
}
};
template <typename Container, typename Iterator>
void move_from_back(Container & container, Iterator it)
{
BOOST_GEOMETRY_INDEX_ASSERT(!container.empty(), "cannot copy from empty container");
Iterator back_it = container.end();
--back_it;
if ( it != back_it )
{
*it = boost::move(*back_it); // MAY THROW (copy)
}
}
}} // namespace detail::rtree
}}} // namespace boost::geometry::index
#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_NODE_HPP

View File

@@ -0,0 +1,110 @@
// Boost.Geometry Index
//
// R-tree node elements access
//
// Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
//
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_NODE_ELEMENTS_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_NODE_ELEMENTS_HPP
#include <boost/container/vector.hpp>
#include <boost/geometry/algorithms/detail/expand_by_epsilon.hpp>
#include <boost/geometry/index/detail/varray.hpp>
#include <boost/geometry/index/detail/rtree/node/pairs.hpp>
namespace boost { namespace geometry { namespace index {
namespace detail { namespace rtree {
// element's indexable type
template <typename Element, typename Translator>
struct element_indexable_type
{
typedef typename indexable_type<Translator>::type type;
};
template <typename First, typename Pointer, typename Translator>
struct element_indexable_type<
rtree::ptr_pair<First, Pointer>,
Translator
>
{
typedef First type;
};
// is leaf element
template <typename Element>
struct is_leaf_element
{
static const bool value = true;
};
template <typename First, typename Pointer>
struct is_leaf_element< rtree::ptr_pair<First, Pointer> >
{
static const bool value = false;
};
// element's indexable getter
template <typename Element, typename Translator>
typename result_type<Translator>::type
element_indexable(Element const& el, Translator const& tr)
{
return tr(el);
}
template <typename First, typename Pointer, typename Translator>
First const&
element_indexable(rtree::ptr_pair<First, Pointer> const& el, Translator const& /*tr*/)
{
return el.first;
}
// nodes elements
template <typename Node>
struct elements_type
{
typedef typename Node::elements_type type;
};
template <typename Node>
inline typename elements_type<Node>::type &
elements(Node & n)
{
return n.elements;
}
template <typename Node>
inline typename elements_type<Node>::type const&
elements(Node const& n)
{
return n.elements;
}
// elements derived type
template <typename Elements, typename NewValue>
struct container_from_elements_type
{
typedef boost::container::vector<NewValue> type;
};
template <typename OldValue, size_t N, typename NewValue>
struct container_from_elements_type<detail::varray<OldValue, N>, NewValue>
{
typedef detail::varray<NewValue, N> type;
};
}} // namespace detail::rtree
}}} // namespace boost::geometry::index
#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_NODE_ELEMENTS_HPP

View File

@@ -0,0 +1,71 @@
// Boost.Geometry Index
//
// Pairs intended to be used internally in nodes.
//
// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
//
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_PAIRS_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_PAIRS_HPP
#include <boost/move/move.hpp>
namespace boost { namespace geometry { namespace index {
namespace detail { namespace rtree {
template <typename First, typename Pointer>
class ptr_pair
{
public:
typedef First first_type;
typedef Pointer second_type;
ptr_pair(First const& f, Pointer s) : first(f), second(s) {}
//ptr_pair(ptr_pair const& p) : first(p.first), second(p.second) {}
//ptr_pair & operator=(ptr_pair const& p) { first = p.first; second = p.second; return *this; }
first_type first;
second_type second;
};
template <typename First, typename Pointer> inline
ptr_pair<First, Pointer>
make_ptr_pair(First const& f, Pointer s)
{
return ptr_pair<First, Pointer>(f, s);
}
// TODO: It this will be used, rename it to unique_ptr_pair and possibly use unique_ptr.
template <typename First, typename Pointer>
class exclusive_ptr_pair
{
BOOST_MOVABLE_BUT_NOT_COPYABLE(exclusive_ptr_pair)
public:
typedef First first_type;
typedef Pointer second_type;
exclusive_ptr_pair(First const& f, Pointer s) : first(f), second(s) {}
// INFO - members aren't really moved!
exclusive_ptr_pair(BOOST_RV_REF(exclusive_ptr_pair) p) : first(p.first), second(p.second) { p.second = 0; }
exclusive_ptr_pair & operator=(BOOST_RV_REF(exclusive_ptr_pair) p) { first = p.first; second = p.second; p.second = 0; return *this; }
first_type first;
second_type second;
};
template <typename First, typename Pointer> inline
exclusive_ptr_pair<First, Pointer>
make_exclusive_ptr_pair(First const& f, Pointer s)
{
return exclusive_ptr_pair<First, Pointer>(f, s);
}
}} // namespace detail::rtree
}}} // namespace boost::geometry::index
#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_PAIRS_HPP

View File

@@ -0,0 +1,51 @@
// Boost.Geometry Index
//
// R-tree scoped deallocator
//
// Copyright (c) 2011-2018 Adam Wulkiewicz, Lodz, Poland.
//
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SCOPED_DEALLOCATOR_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SCOPED_DEALLOCATOR_HPP
namespace boost { namespace geometry { namespace index {
namespace detail { namespace rtree {
template <typename Alloc>
class scoped_deallocator
{
typedef boost::container::allocator_traits<Alloc> alloc_traits;
scoped_deallocator(scoped_deallocator const&);
scoped_deallocator & operator=(scoped_deallocator const&);
public:
typedef typename alloc_traits::pointer pointer;
inline scoped_deallocator(pointer p, Alloc & a)
: m_ptr(p), m_alloc(a)
{}
inline ~scoped_deallocator()
{
if ( m_ptr )
{
alloc_traits::deallocate(m_alloc, m_ptr, 1);
}
}
inline void release()
{
m_ptr = 0;
}
private:
pointer m_ptr;
Alloc & m_alloc;
};
}} // namespace detail::rtree
}}} // namespace boost::geometry::index
#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SCOPED_DEALLOCATOR_HPP

View File

@@ -0,0 +1,79 @@
// Boost.Geometry Index
//
// R-tree subtree scoped destroyer
//
// Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
//
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SUBTREE_DESTROYED_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SUBTREE_DESTROYED_HPP
#include <boost/geometry/index/detail/rtree/visitors/destroy.hpp>
namespace boost { namespace geometry { namespace index {
namespace detail { namespace rtree {
template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
class subtree_destroyer
{
typedef typename rtree::node<Value, typename Options::parameters_type, Box, Allocators, typename Options::node_tag>::type node;
typedef typename Allocators::node_pointer pointer;
subtree_destroyer(subtree_destroyer const&);
subtree_destroyer & operator=(subtree_destroyer const&);
public:
subtree_destroyer(pointer ptr, Allocators & allocators)
: m_ptr(ptr)
, m_allocators(allocators)
{}
~subtree_destroyer()
{
reset();
}
void reset(pointer ptr = 0)
{
if ( m_ptr && m_ptr != ptr )
{
detail::rtree::visitors::destroy<Value, Options, Translator, Box, Allocators> del_v(m_ptr, m_allocators);
detail::rtree::apply_visitor(del_v, *m_ptr);
}
m_ptr = ptr;
}
void release()
{
m_ptr = 0;
}
pointer get() const
{
return m_ptr;
}
node & operator*() const
{
return *m_ptr;
}
pointer operator->() const
{
return m_ptr;
}
private:
pointer m_ptr;
Allocators & m_allocators;
};
}} // namespace detail::rtree
}}} // namespace boost::geometry::index
#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SUBTREE_DESTROYED_HPP

View File

@@ -0,0 +1,296 @@
// Boost.Geometry Index
//
// R-tree nodes based on Boost.Variant, storing dynamic-size containers
//
// Copyright (c) 2011-2018 Adam Wulkiewicz, Lodz, Poland.
//
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_DYNAMIC_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_DYNAMIC_HPP
#include <boost/core/pointer_traits.hpp>
namespace boost { namespace geometry { namespace index {
namespace detail { namespace rtree {
// nodes default types
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct variant_internal_node
{
typedef rtree::ptr_pair<Box, typename Allocators::node_pointer> element_type;
typedef typename boost::container::allocator_traits
<
typename Allocators::node_allocator_type
>::template rebind_alloc<element_type> allocator_type;
typedef boost::container::vector<element_type, allocator_type> elements_type;
template <typename Al>
inline variant_internal_node(Al const& al)
: elements(allocator_type(al))
{}
elements_type elements;
};
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct variant_leaf
{
typedef typename boost::container::allocator_traits
<
typename Allocators::node_allocator_type
>::template rebind_alloc<Value> allocator_type;
typedef boost::container::vector<Value, allocator_type> elements_type;
template <typename Al>
inline variant_leaf(Al const& al)
: elements(allocator_type(al))
{}
elements_type elements;
};
// nodes traits
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct node<Value, Parameters, Box, Allocators, node_variant_dynamic_tag>
{
typedef boost::variant<
variant_leaf<Value, Parameters, Box, Allocators, node_variant_dynamic_tag>,
variant_internal_node<Value, Parameters, Box, Allocators, node_variant_dynamic_tag>
> type;
};
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct internal_node<Value, Parameters, Box, Allocators, node_variant_dynamic_tag>
{
typedef variant_internal_node<Value, Parameters, Box, Allocators, node_variant_dynamic_tag> type;
};
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct leaf<Value, Parameters, Box, Allocators, node_variant_dynamic_tag>
{
typedef variant_leaf<Value, Parameters, Box, Allocators, node_variant_dynamic_tag> type;
};
// visitor traits
template <typename Value, typename Parameters, typename Box, typename Allocators, bool IsVisitableConst>
struct visitor<Value, Parameters, Box, Allocators, node_variant_dynamic_tag, IsVisitableConst>
{
typedef static_visitor<> type;
};
// allocators
template <typename Allocator, typename Value, typename Parameters, typename Box, typename Tag>
struct node_alloc
{
typedef typename node
<
Value, Parameters, Box,
allocators<Allocator, Value, Parameters, Box, Tag>,
Tag
>::type node_type;
typedef typename boost::container::allocator_traits
<
Allocator
>::template rebind_alloc<node_type> type;
typedef boost::container::allocator_traits<type> traits;
};
template <typename Allocator, typename Value, typename Parameters, typename Box>
class allocators<Allocator, Value, Parameters, Box, node_variant_dynamic_tag>
: public detail::rtree::node_alloc
<
Allocator, Value, Parameters, Box, node_variant_dynamic_tag
>::type
{
typedef detail::rtree::node_alloc
<
Allocator, Value, Parameters, Box, node_variant_dynamic_tag
> node_alloc;
public:
typedef typename node_alloc::type node_allocator_type;
typedef typename node_alloc::traits::pointer node_pointer;
private:
typedef typename boost::container::allocator_traits
<
node_allocator_type // node_allocator_type for consistency with variant_leaf
>::template rebind_alloc<Value> value_allocator_type;
typedef boost::container::allocator_traits<value_allocator_type> value_allocator_traits;
public:
typedef Allocator allocator_type;
typedef Value value_type;
typedef typename value_allocator_traits::reference reference;
typedef typename value_allocator_traits::const_reference const_reference;
typedef typename value_allocator_traits::size_type size_type;
typedef typename value_allocator_traits::difference_type difference_type;
typedef typename value_allocator_traits::pointer pointer;
typedef typename value_allocator_traits::const_pointer const_pointer;
inline allocators()
: node_allocator_type()
{}
template <typename Alloc>
inline explicit allocators(Alloc const& alloc)
: node_allocator_type(alloc)
{}
inline allocators(BOOST_FWD_REF(allocators) a)
: node_allocator_type(boost::move(a.node_allocator()))
{}
inline allocators & operator=(BOOST_FWD_REF(allocators) a)
{
node_allocator() = boost::move(a.node_allocator());
return *this;
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
inline allocators & operator=(allocators const& a)
{
node_allocator() = a.node_allocator();
return *this;
}
#endif
void swap(allocators & a)
{
boost::swap(node_allocator(), a.node_allocator());
}
bool operator==(allocators const& a) const { return node_allocator() == a.node_allocator(); }
template <typename Alloc>
bool operator==(Alloc const& a) const { return node_allocator() == node_allocator_type(a); }
Allocator allocator() const { return Allocator(node_allocator()); }
node_allocator_type & node_allocator() { return *this; }
node_allocator_type const& node_allocator() const { return *this; }
};
// create_node_variant
template <typename VariantPtr, typename Node>
struct create_variant_node
{
template <typename AllocNode>
static inline VariantPtr apply(AllocNode & alloc_node)
{
typedef boost::container::allocator_traits<AllocNode> Al;
typedef typename Al::pointer P;
P p = Al::allocate(alloc_node, 1);
if ( 0 == p )
throw_runtime_error("boost::geometry::index::rtree node creation failed");
scoped_deallocator<AllocNode> deallocator(p, alloc_node);
Al::construct(alloc_node, boost::to_address(p), Node(alloc_node)); // implicit cast to Variant
deallocator.release();
return p;
}
};
// destroy_node_variant
template <typename Node>
struct destroy_variant_node
{
template <typename AllocNode, typename VariantPtr>
static inline void apply(AllocNode & alloc_node, VariantPtr n)
{
typedef boost::container::allocator_traits<AllocNode> Al;
Al::destroy(alloc_node, boost::addressof(*n));
Al::deallocate(alloc_node, n, 1);
}
};
// create_node
template <typename Allocators, typename Value, typename Parameters, typename Box, typename Tag>
struct create_node<
Allocators,
variant_internal_node<Value, Parameters, Box, Allocators, Tag>
>
{
static inline typename Allocators::node_pointer
apply(Allocators & allocators)
{
return create_variant_node<
typename Allocators::node_pointer,
variant_internal_node<Value, Parameters, Box, Allocators, Tag>
>::apply(allocators.node_allocator());
}
};
template <typename Allocators, typename Value, typename Parameters, typename Box, typename Tag>
struct create_node<
Allocators,
variant_leaf<Value, Parameters, Box, Allocators, Tag>
>
{
static inline typename Allocators::node_pointer
apply(Allocators & allocators)
{
return create_variant_node<
typename Allocators::node_pointer,
variant_leaf<Value, Parameters, Box, Allocators, Tag>
>::apply(allocators.node_allocator());
}
};
// destroy_node
template <typename Allocators, typename Value, typename Parameters, typename Box, typename Tag>
struct destroy_node<
Allocators,
variant_internal_node<Value, Parameters, Box, Allocators, Tag>
>
{
static inline void apply(Allocators & allocators, typename Allocators::node_pointer n)
{
destroy_variant_node<
variant_internal_node<Value, Parameters, Box, Allocators, Tag>
>::apply(allocators.node_allocator(), n);
}
};
template <typename Allocators, typename Value, typename Parameters, typename Box, typename Tag>
struct destroy_node<
Allocators,
variant_leaf<Value, Parameters, Box, Allocators, Tag>
>
{
static inline void apply(Allocators & allocators, typename Allocators::node_pointer n)
{
destroy_variant_node<
variant_leaf<Value, Parameters, Box, Allocators, Tag>
>::apply(allocators.node_allocator(), n);
}
};
}} // namespace detail::rtree
}}} // namespace boost::geometry::index
#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_DYNAMIC_HPP

View File

@@ -0,0 +1,161 @@
// Boost.Geometry Index
//
// R-tree nodes based on Boost.Variant, storing static-size containers
//
// Copyright (c) 2011-2018 Adam Wulkiewicz, Lodz, Poland.
//
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_STATIC_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_STATIC_HPP
namespace boost { namespace geometry { namespace index {
namespace detail { namespace rtree {
// nodes default types
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct variant_internal_node<Value, Parameters, Box, Allocators, node_variant_static_tag>
{
typedef detail::varray<
rtree::ptr_pair<Box, typename Allocators::node_pointer>,
Parameters::max_elements + 1
> elements_type;
template <typename Alloc>
inline variant_internal_node(Alloc const&) {}
elements_type elements;
};
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct variant_leaf<Value, Parameters, Box, Allocators, node_variant_static_tag>
{
typedef detail::varray<
Value,
Parameters::max_elements + 1
> elements_type;
template <typename Alloc>
inline variant_leaf(Alloc const&) {}
elements_type elements;
};
// nodes traits
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct node<Value, Parameters, Box, Allocators, node_variant_static_tag>
{
typedef boost::variant<
variant_leaf<Value, Parameters, Box, Allocators, node_variant_static_tag>,
variant_internal_node<Value, Parameters, Box, Allocators, node_variant_static_tag>
> type;
};
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct internal_node<Value, Parameters, Box, Allocators, node_variant_static_tag>
{
typedef variant_internal_node<Value, Parameters, Box, Allocators, node_variant_static_tag> type;
};
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct leaf<Value, Parameters, Box, Allocators, node_variant_static_tag>
{
typedef variant_leaf<Value, Parameters, Box, Allocators, node_variant_static_tag> type;
};
// visitor traits
template <typename Value, typename Parameters, typename Box, typename Allocators, bool IsVisitableConst>
struct visitor<Value, Parameters, Box, Allocators, node_variant_static_tag, IsVisitableConst>
{
typedef static_visitor<> type;
};
// allocators
template <typename Allocator, typename Value, typename Parameters, typename Box>
class allocators<Allocator, Value, Parameters, Box, node_variant_static_tag>
: public detail::rtree::node_alloc
<
Allocator, Value, Parameters, Box, node_variant_static_tag
>::type
{
typedef detail::rtree::node_alloc
<
Allocator, Value, Parameters, Box, node_variant_static_tag
> node_alloc;
public:
typedef typename node_alloc::type node_allocator_type;
typedef typename node_alloc::traits::pointer node_pointer;
private:
typedef typename boost::container::allocator_traits
<
node_allocator_type
>::template rebind_alloc<Value> value_allocator_type;
typedef boost::container::allocator_traits<value_allocator_type> value_allocator_traits;
public:
typedef Allocator allocator_type;
typedef Value value_type;
typedef typename value_allocator_traits::reference reference;
typedef typename value_allocator_traits::const_reference const_reference;
typedef typename value_allocator_traits::size_type size_type;
typedef typename value_allocator_traits::difference_type difference_type;
typedef typename value_allocator_traits::pointer pointer;
typedef typename value_allocator_traits::const_pointer const_pointer;
inline allocators()
: node_allocator_type()
{}
template <typename Alloc>
inline explicit allocators(Alloc const& alloc)
: node_allocator_type(alloc)
{}
inline allocators(BOOST_FWD_REF(allocators) a)
: node_allocator_type(boost::move(a.node_allocator()))
{}
inline allocators & operator=(BOOST_FWD_REF(allocators) a)
{
node_allocator() = boost::move(a.node_allocator());
return *this;
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
inline allocators & operator=(allocators const& a)
{
node_allocator() = a.node_allocator();
return *this;
}
#endif
void swap(allocators & a)
{
boost::swap(node_allocator(), a.node_allocator());
}
bool operator==(allocators const& a) const { return node_allocator() == a.node_allocator(); }
template <typename Alloc>
bool operator==(Alloc const& a) const { return node_allocator() == node_allocator_type(a); }
Allocator allocator() const { return Allocator(node_allocator()); }
node_allocator_type & node_allocator() { return *this; }
node_allocator_type const& node_allocator() const { return *this; }
};
}} // namespace detail::rtree
}}} // namespace boost::geometry::index
#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_STATIC_HPP

View File

@@ -0,0 +1,68 @@
// Boost.Geometry Index
//
// R-tree nodes static visitor related code
//
// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
//
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_VISITOR_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_VISITOR_HPP
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/get.hpp>
#include <boost/variant/variant.hpp>
namespace boost { namespace geometry { namespace index {
namespace detail { namespace rtree {
// nodes variants forward declarations
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct variant_internal_node;
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct variant_leaf;
// nodes conversion
template <typename V, typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
inline V & get(
boost::variant<
variant_leaf<Value, Parameters, Box, Allocators, Tag>,
variant_internal_node<Value, Parameters, Box, Allocators, Tag>
> & v)
{
return boost::get<V>(v);
}
// apply visitor
template <typename Visitor, typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
inline void apply_visitor(Visitor & v,
boost::variant<
variant_leaf<Value, Parameters, Box, Allocators, Tag>,
variant_internal_node<Value, Parameters, Box, Allocators, Tag>
> & n)
{
boost::apply_visitor(v, n);
}
template <typename Visitor, typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
inline void apply_visitor(Visitor & v,
boost::variant<
variant_leaf<Value, Parameters, Box, Allocators, Tag>,
variant_internal_node<Value, Parameters, Box, Allocators, Tag>
> const& n)
{
boost::apply_visitor(v, n);
}
}} // namespace detail::rtree
}}} // namespace boost::geometry::index
#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_VISITOR_HPP

View File

@@ -0,0 +1,322 @@
// Boost.Geometry Index
//
// R-tree nodes based on static conversion, storing dynamic-size containers
//
// Copyright (c) 2011-2018 Adam Wulkiewicz, Lodz, Poland.
//
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_DYNAMIC_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_DYNAMIC_HPP
namespace boost { namespace geometry { namespace index {
namespace detail { namespace rtree {
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct weak_internal_node
: public weak_node<Value, Parameters, Box, Allocators, Tag>
{
typedef rtree::ptr_pair<Box, typename Allocators::node_pointer> element_type;
typedef typename boost::container::allocator_traits
<
typename Allocators::internal_node_allocator_type
>::template rebind_alloc<element_type> allocator_type;
typedef boost::container::vector<element_type, allocator_type> elements_type;
template <typename Al>
inline weak_internal_node(Al const& al)
: elements(allocator_type(al))
{}
elements_type elements;
};
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct weak_leaf
: public weak_node<Value, Parameters, Box, Allocators, Tag>
{
typedef typename boost::container::allocator_traits
<
typename Allocators::leaf_allocator_type
>::template rebind_alloc<Value> allocator_type;
typedef boost::container::vector<Value, allocator_type> elements_type;
template <typename Al>
inline weak_leaf(Al const& al)
: elements(allocator_type(al))
{}
elements_type elements;
};
// nodes traits
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct node<Value, Parameters, Box, Allocators, node_weak_dynamic_tag>
{
typedef weak_node<Value, Parameters, Box, Allocators, node_weak_dynamic_tag> type;
};
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct internal_node<Value, Parameters, Box, Allocators, node_weak_dynamic_tag>
{
typedef weak_internal_node<Value, Parameters, Box, Allocators, node_weak_dynamic_tag> type;
};
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct leaf<Value, Parameters, Box, Allocators, node_weak_dynamic_tag>
{
typedef weak_leaf<Value, Parameters, Box, Allocators, node_weak_dynamic_tag> type;
};
// visitor traits
template <typename Value, typename Parameters, typename Box, typename Allocators, bool IsVisitableConst>
struct visitor<Value, Parameters, Box, Allocators, node_weak_dynamic_tag, IsVisitableConst>
{
typedef weak_visitor<Value, Parameters, Box, Allocators, node_weak_dynamic_tag, IsVisitableConst> type;
};
// allocators
template <typename Allocator, typename Value, typename Parameters, typename Box, typename Tag>
struct internal_node_alloc
{
typedef typename internal_nod
<
Value, Parameters, Box,
allocators<Allocator, Value, Parameters, Box, Tag>,
Tag
>::type node_type;
typedef typename boost::container::allocator_traits
<
Allocator
>::template rebind_alloc<node_type> type;
};
template <typename Allocator, typename Value, typename Parameters, typename Box, typename Tag>
struct leaf_alloc
{
typedef typename leaf
<
Value, Parameters, Box,
allocators<Allocator, Value, Parameters, Box, Tag>,
Tag
>::type node_type;
typedef typename ::boost::container::allocator_traits
<
Allocator
>::template rebind_alloc<node_type> type;
};
template <typename Allocator, typename Value, typename Parameters, typename Box>
class allocators<Allocator, Value, Parameters, Box, node_weak_dynamic_tag>
: public internal_node_alloc<Allocator, Value, Parameters, Box, node_weak_dynamic_tag>::type
, public leaf_alloc<Allocator, Value, Parameters, Box, node_weak_dynamic_tag>::type
{
typedef detail::rtree::internal_node_alloc
<
Allocator, Value, Parameters, Box, node_weak_dynamic_tag
> internal_node_alloc;
typedef detail::rtree::leaf_alloc
<
Allocator, Value, Parameters, Box, node_weak_dynamic_tag
> leaf_alloc;
typedef detail::rtree::node_alloc
<
Allocator, Value, Parameters, Box, node_weak_dynamic_tag
> node_alloc;
public:
typedef typename internal_node_alloc::type internal_node_allocator_type;
typedef typename leaf_alloc::type leaf_allocator_type;
typedef typename node_alloc::traits::pointer node_pointer;
private:
typedef typename boost::container::allocator_traits
<
leaf_allocator_type // leaf_allocator_type for consistency with weak_leaf
>::template rebind_alloc<Value> value_allocator_type;
typedef boost::container::allocator_traits<value_allocator_type> value_allocator_traits;
public:
typedef Allocator allocator_type;
typedef Value value_type;
typedef typename value_allocator_traits::reference reference;
typedef typename value_allocator_traits::const_reference const_reference;
typedef typename value_allocator_traits::size_type size_type;
typedef typename value_allocator_traits::difference_type difference_type;
typedef typename value_allocator_traits::pointer pointer;
typedef typename value_allocator_traits::const_pointer const_pointer;
inline allocators()
: internal_node_allocator_type()
, leaf_allocator_type()
{}
template <typename Alloc>
inline explicit allocators(Alloc const& alloc)
: internal_node_allocator_type(alloc)
, leaf_allocator_type(alloc)
{}
inline allocators(BOOST_FWD_REF(allocators) a)
: internal_node_allocator_type(boost::move(a.internal_node_allocator()))
, leaf_allocator_type(boost::move(a.leaf_allocator()))
{}
inline allocators & operator=(BOOST_FWD_REF(allocators) a)
{
internal_node_allocator() = ::boost::move(a.internal_node_allocator());
leaf_allocator() = ::boost::move(a.leaf_allocator());
return *this;
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
inline allocators & operator=(allocators const& a)
{
internal_node_allocator() = a.internal_node_allocator();
leaf_allocator() = a.leaf_allocator();
return *this;
}
#endif
void swap(allocators & a)
{
boost::swap(internal_node_allocator(), a.internal_node_allocator());
boost::swap(leaf_allocator(), a.leaf_allocator());
}
bool operator==(allocators const& a) const { return leaf_allocator() == a.leaf_allocator(); }
template <typename Alloc>
bool operator==(Alloc const& a) const { return leaf_allocator() == leaf_allocator_type(a); }
Allocator allocator() const { return Allocator(leaf_allocator()); }
internal_node_allocator_type & internal_node_allocator() { return *this; }
internal_node_allocator_type const& internal_node_allocator() const { return *this; }
leaf_allocator_type & leaf_allocator() { return *this; }
leaf_allocator_type const& leaf_allocator() const { return *this; }
};
// create_node_impl
template <typename BaseNodePtr, typename Node>
struct create_weak_node
{
template <typename AllocNode>
static inline BaseNodePtr apply(AllocNode & alloc_node)
{
typedef boost::container::allocator_traits<AllocNode> Al;
typedef typename Al::pointer P;
P p = Al::allocate(alloc_node, 1);
if ( 0 == p )
throw_runtime_error("boost::geometry::index::rtree node creation failed");
scoped_deallocator<AllocNode> deallocator(p, alloc_node);
Al::construct(alloc_node, boost::to_address(p), alloc_node);
deallocator.release();
return p;
}
};
// destroy_node_impl
template <typename Node>
struct destroy_weak_node
{
template <typename AllocNode, typename BaseNodePtr>
static inline void apply(AllocNode & alloc_node, BaseNodePtr n)
{
typedef boost::container::allocator_traits<AllocNode> Al;
typedef typename Al::pointer P;
P p(&static_cast<Node&>(rtree::get<Node>(*n)));
Al::destroy(alloc_node, boost::addressof(*p));
Al::deallocate(alloc_node, p, 1);
}
};
// create_node
template <typename Allocators, typename Value, typename Parameters, typename Box, typename Tag>
struct create_node<
Allocators,
weak_internal_node<Value, Parameters, Box, Allocators, Tag>
>
{
static inline typename Allocators::node_pointer
apply(Allocators & allocators)
{
return create_weak_node<
typename Allocators::node_pointer,
weak_internal_node<Value, Parameters, Box, Allocators, Tag>
>::apply(allocators.internal_node_allocator());
}
};
template <typename Allocators, typename Value, typename Parameters, typename Box, typename Tag>
struct create_node<
Allocators,
weak_leaf<Value, Parameters, Box, Allocators, Tag>
>
{
static inline typename Allocators::node_pointer
apply(Allocators & allocators)
{
return create_weak_node<
typename Allocators::node_pointer,
weak_leaf<Value, Parameters, Box, Allocators, Tag>
>::apply(allocators.leaf_allocator());
}
};
// destroy_node
template <typename Allocators, typename Value, typename Parameters, typename Box, typename Tag>
struct destroy_node<
Allocators,
weak_internal_node<Value, Parameters, Box, Allocators, Tag>
>
{
static inline void apply(Allocators & allocators, typename Allocators::node_pointer n)
{
destroy_weak_node<
weak_internal_node<Value, Parameters, Box, Allocators, Tag>
>::apply(allocators.internal_node_allocator(), n);
}
};
template <typename Allocators, typename Value, typename Parameters, typename Box, typename Tag>
struct destroy_node<
Allocators,
weak_leaf<Value, Parameters, Box, Allocators, Tag>
>
{
static inline void apply(Allocators & allocators, typename Allocators::node_pointer n)
{
destroy_weak_node<
weak_leaf<Value, Parameters, Box, Allocators, Tag>
>::apply(allocators.leaf_allocator(), n);
}
};
}} // namespace detail::rtree
}}} // namespace boost::geometry::index
#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_DYNAMIC_HPP

View File

@@ -0,0 +1,173 @@
// Boost.Geometry Index
//
// R-tree nodes based on static conversion, storing static-size containers
//
// Copyright (c) 2011-2018 Adam Wulkiewicz, Lodz, Poland.
//
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_STATIC_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_STATIC_HPP
namespace boost { namespace geometry { namespace index {
namespace detail { namespace rtree {
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct weak_internal_node<Value, Parameters, Box, Allocators, node_weak_static_tag>
: public weak_node<Value, Parameters, Box, Allocators, node_weak_static_tag>
{
typedef detail::varray<
rtree::ptr_pair<Box, typename Allocators::node_pointer>,
Parameters::max_elements + 1
> elements_type;
template <typename Alloc>
inline weak_internal_node(Alloc const&) {}
elements_type elements;
};
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct weak_leaf<Value, Parameters, Box, Allocators, node_weak_static_tag>
: public weak_node<Value, Parameters, Box, Allocators, node_weak_static_tag>
{
typedef detail::varray<
Value,
Parameters::max_elements + 1
> elements_type;
template <typename Alloc>
inline weak_leaf(Alloc const&) {}
elements_type elements;
};
// nodes traits
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct node<Value, Parameters, Box, Allocators, node_weak_static_tag>
{
typedef weak_node<Value, Parameters, Box, Allocators, node_weak_static_tag> type;
};
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct internal_node<Value, Parameters, Box, Allocators, node_weak_static_tag>
{
typedef weak_internal_node<Value, Parameters, Box, Allocators, node_weak_static_tag> type;
};
template <typename Value, typename Parameters, typename Box, typename Allocators>
struct leaf<Value, Parameters, Box, Allocators, node_weak_static_tag>
{
typedef weak_leaf<Value, Parameters, Box, Allocators, node_weak_static_tag> type;
};
template <typename Value, typename Parameters, typename Box, typename Allocators, bool IsVisitableConst>
struct visitor<Value, Parameters, Box, Allocators, node_weak_static_tag, IsVisitableConst>
{
typedef weak_visitor<Value, Parameters, Box, Allocators, node_weak_static_tag, IsVisitableConst> type;
};
// allocators
template <typename Allocator, typename Value, typename Parameters, typename Box>
class allocators<Allocator, Value, Parameters, Box, node_weak_static_tag>
: public detail::rtree::internal_node_alloc<Allocator, Value, Parameters, Box, node_weak_static_tag>::type
, public detail::rtree::leaf_alloc<Allocator, Value, Parameters, Box, node_weak_static_tag>::type
{
typedef detail::rtree::internal_node_alloc
<
Allocator, Value, Parameters, Box, node_weak_static_tag
> internal_node_alloc;
typedef detail::rtree::leaf_alloc
<
Allocator, Value, Parameters, Box, node_weak_static_tag
> leaf_alloc;
typedef detail::rtree::node_alloc
<
Allocator, Value, Parameters, Box, node_weak_static_tag
> node_alloc;
public:
typedef typename internal_node_alloc::type internal_node_allocator_type;
typedef typename leaf_alloc::type leaf_allocator_type;
typedef typename node_alloc::traits::pointer node_pointer;
private:
typedef typename boost::container::allocator_traits
<
leaf_allocator_type
>::template rebind_alloc<Value> value_allocator_type;
typedef boost::container::allocator_traits<value_allocator_type> value_allocator_traits;
public:
typedef Allocator allocator_type;
typedef Value value_type;
typedef typename value_allocator_traits::reference reference;
typedef typename value_allocator_traits::const_reference const_reference;
typedef typename value_allocator_traits::size_type size_type;
typedef typename value_allocator_traits::difference_type difference_type;
typedef typename value_allocator_traits::pointer pointer;
typedef typename value_allocator_traits::const_pointer const_pointer;
inline allocators()
: internal_node_allocator_type()
, leaf_allocator_type()
{}
template <typename Alloc>
inline explicit allocators(Alloc const& alloc)
: internal_node_allocator_type(alloc)
, leaf_allocator_type(alloc)
{}
inline allocators(BOOST_FWD_REF(allocators) a)
: internal_node_allocator_type(boost::move(a.internal_node_allocator()))
, leaf_allocator_type(boost::move(a.leaf_allocator()))
{}
inline allocators & operator=(BOOST_FWD_REF(allocators) a)
{
internal_node_allocator() = ::boost::move(a.internal_node_allocator());
leaf_allocator() = ::boost::move(a.leaf_allocator());
return *this;
}
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
inline allocators & operator=(allocators const& a)
{
internal_node_allocator() = a.internal_node_allocator();
leaf_allocator() = a.leaf_allocator();
return *this;
}
#endif
void swap(allocators & a)
{
boost::swap(internal_node_allocator(), a.internal_node_allocator());
boost::swap(leaf_allocator(), a.leaf_allocator());
}
bool operator==(allocators const& a) const { return leaf_allocator() == a.leaf_allocator(); }
template <typename Alloc>
bool operator==(Alloc const& a) const { return leaf_allocator() == leaf_allocator_type(a); }
Allocator allocator() const { return Allocator(leaf_allocator()); }
internal_node_allocator_type & internal_node_allocator() { return *this; }
internal_node_allocator_type const& internal_node_allocator() const { return *this; }
leaf_allocator_type & leaf_allocator() { return *this; }
leaf_allocator_type const& leaf_allocator() const{ return *this; }
};
}} // namespace detail::rtree
}}} // namespace boost::geometry::index
#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_STATIC_HPP

View File

@@ -0,0 +1,67 @@
// Boost.Geometry Index
//
// R-tree nodes weak visitor and nodes base type
//
// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
//
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_VISITOR_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_VISITOR_HPP
namespace boost { namespace geometry { namespace index {
namespace detail { namespace rtree {
// empty visitor
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag, bool IsVisitableConst>
struct weak_visitor {};
// node
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct weak_node {};
// nodes variants forward declarations
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct weak_internal_node;
template <typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
struct weak_leaf;
// nodes conversion
template <typename Derived, typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
inline Derived & get(weak_node<Value, Parameters, Box, Allocators, Tag> & n)
{
return static_cast<Derived&>(n);
}
// apply visitor
template <typename Visitor, typename Value, typename Parameters, typename Box, typename Allocators, typename Tag>
inline void apply_visitor(Visitor & v,
weak_node<Value, Parameters, Box, Allocators, Tag> & n,
bool is_internal_node)
{
BOOST_GEOMETRY_INDEX_ASSERT(&n, "null ptr");
if ( is_internal_node )
{
typedef weak_internal_node<Value, Parameters, Box, Allocators, Tag> internal_node;
v(get<internal_node>(n));
}
else
{
typedef weak_leaf<Value, Parameters, Box, Allocators, Tag> leaf;
v(get<leaf>(n));
}
}
}} // namespace detail::rtree
}}} // namespace boost::geometry::index
#endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_DYNAMIC_VISITOR_HPP