]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/index/test/rtree/rtree_move_pack.cpp
1 // Boost.Geometry Index
4 // Copyright (c) 2015 Adam Wulkiewicz, Lodz, Poland.
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
10 #include <rtree/test_rtree.hpp>
13 #include <boost/container/vector.hpp>
14 #include <boost/move/move.hpp>
15 #include <boost/move/iterator.hpp>
17 #include <boost/geometry/geometries/register/point.hpp>
21 BOOST_COPYABLE_AND_MOVABLE(point_cm
)
24 point_cm(double xx
= 0, double yy
= 0)
29 point_cm(point_cm
const& other
)
34 BOOST_CHECK_MESSAGE(false, "copy not allowed");
36 point_cm
& operator=(BOOST_COPY_ASSIGN_REF(point_cm
) other
)
38 BOOST_CHECK_MESSAGE(false, "copy not allowed");
44 point_cm(BOOST_RV_REF(point_cm
) other
)
49 BOOST_CHECK_MESSAGE(!other
.moved
, "only one move allowed");
52 point_cm
& operator=(BOOST_RV_REF(point_cm
) other
)
54 BOOST_CHECK_MESSAGE(!other
.moved
, "only one move allowed");
66 template <typename Point
>
69 typedef Point
const& result_type
;
70 result_type
operator()(Point
const& p
) const
72 BOOST_CHECK_MESSAGE(!p
.moved
, "can't access indexable of moved Value");
77 BOOST_GEOMETRY_REGISTER_POINT_2D(point_cm
, double, bg::cs::cartesian
, x
, y
)
79 template <typename Vector
>
80 void append(Vector
& vec
, double x
, double y
)
83 BOOST_CHECK(!pt
.moved
);
84 vec
.push_back(boost::move(pt
));
85 BOOST_CHECK(pt
.moved
);
93 template <typename Point
>
94 void operator()(Point
const& p
) const
96 BOOST_CHECK_EQUAL(p
.moved
, expected
);
101 template <typename Point
, typename Params
>
102 void test_rtree(Params
const& params
= Params())
105 boost::container::vector
<Point
> vec
;
106 append(vec
, 0, 0); append(vec
, 0, 1); append(vec
, 0, 2);
107 append(vec
, 1, 0); append(vec
, 1, 1); append(vec
, 1, 2);
108 append(vec
, 2, 0); append(vec
, 2, 1); append(vec
, 2, 2);
110 std::for_each(vec
.begin(), vec
.end(), test_moved(false));
112 bgi::rtree
<Point
, Params
, indexable
<Point
> > rt(
113 boost::make_move_iterator(vec
.begin()),
114 boost::make_move_iterator(vec
.end()),
117 std::for_each(vec
.begin(), vec
.end(), test_moved(true));
119 BOOST_CHECK_EQUAL(rt
.size(), vec
.size());
123 int test_main(int, char* [])
125 test_rtree
< point_cm
, bgi::linear
<4> >();
126 test_rtree
< point_cm
, bgi::quadratic
<4> >();
127 test_rtree
< point_cm
, bgi::rstar
<4> >();
129 test_rtree
<point_cm
>(bgi::dynamic_linear(4));
130 test_rtree
<point_cm
>(bgi::dynamic_quadratic(4));
131 test_rtree
<point_cm
>(bgi::dynamic_rstar(4));