// Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. // 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 GEOMETRY_TEST_TEST_GEOMETRIES_WRAPPED_BOOST_ARRAY_HPP #define GEOMETRY_TEST_TEST_GEOMETRIES_WRAPPED_BOOST_ARRAY_HPP #include #include #include #include #include #include namespace test { template struct wrapped_boost_array { inline wrapped_boost_array() : size(0) {} boost::array array; std::size_t size; }; } // namespace test // 1a: adapt to Boost.Range namespace boost { using namespace test; template struct range_mutable_iterator > : public range_mutable_iterator > {}; template struct range_const_iterator > : public range_const_iterator > {}; } // namespace 'boost' // 1b) adapt to Boost.Range with ADP namespace test { template inline typename boost::range_iterator < wrapped_boost_array >::type range_begin(wrapped_boost_array& ar) { return ar.array.begin(); } template inline typename boost::range_iterator < wrapped_boost_array const >::type range_begin(wrapped_boost_array const& ar) { return ar.array.begin(); } template inline typename boost::range_iterator < wrapped_boost_array >::type range_end(wrapped_boost_array& ar) { typename boost::range_iterator < wrapped_boost_array >::type it = ar.array.begin(); return it + ar.size; } template inline typename boost::range_iterator < wrapped_boost_array const >::type range_end(wrapped_boost_array const& ar) { typename boost::range_iterator < wrapped_boost_array const >::type it = ar.array.begin(); return it + ar.size; } } // 2: adapt to Boost.Geometry namespace boost { namespace geometry { namespace traits { template struct tag< wrapped_boost_array > { typedef linestring_tag type; }; template struct clear< wrapped_boost_array > { static inline void apply(wrapped_boost_array& ar) { ar.size = 0; } }; template struct push_back< wrapped_boost_array > { static inline void apply(wrapped_boost_array& ar, Point const& point) { // BOOST_ASSERT((ar.size < Count)); ar.array[ar.size++] = point; } }; template struct resize< wrapped_boost_array > { static inline void apply(wrapped_boost_array& ar, std::size_t new_size) { BOOST_ASSERT(new_size < Count); ar.size = new_size; } }; }}} // namespace bg::traits #endif // GEOMETRY_TEST_TEST_GEOMETRIES_WRAPPED_BOOST_ARRAY_HPP