Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/geometry/index/detail/varray.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
comparison
equal
deleted
inserted
replaced
100:793467b5e61c | 101:c530137014c0 |
---|---|
1 // Boost.Container varray | 1 // Boost.Container varray |
2 // | 2 // |
3 // Copyright (c) 2012-2013 Adam Wulkiewicz, Lodz, Poland. | 3 // Copyright (c) 2012-2015 Adam Wulkiewicz, Lodz, Poland. |
4 // Copyright (c) 2011-2013 Andrew Hundt. | 4 // Copyright (c) 2011-2013 Andrew Hundt. |
5 // | 5 // |
6 // Use, modification and distribution is subject to the Boost Software License, | 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 | 7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
8 // http://www.boost.org/LICENSE_1_0.txt) | 8 // http://www.boost.org/LICENSE_1_0.txt) |
11 #define BOOST_GEOMETRY_INDEX_DETAIL_VARRAY_HPP | 11 #define BOOST_GEOMETRY_INDEX_DETAIL_VARRAY_HPP |
12 | 12 |
13 // TODO - REMOVE/CHANGE | 13 // TODO - REMOVE/CHANGE |
14 #include <boost/container/detail/config_begin.hpp> | 14 #include <boost/container/detail/config_begin.hpp> |
15 #include <boost/container/detail/workaround.hpp> | 15 #include <boost/container/detail/workaround.hpp> |
16 #include <boost/container/detail/preprocessor.hpp> | 16 |
17 #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) | |
18 #include <boost/move/detail/fwd_macros.hpp> | |
19 #endif | |
17 | 20 |
18 #include <boost/config.hpp> | 21 #include <boost/config.hpp> |
19 #include <boost/swap.hpp> | 22 #include <boost/swap.hpp> |
20 #include <boost/integer.hpp> | 23 #include <boost/integer.hpp> |
21 | 24 |
30 // or boost/detail/iterator.hpp ? | 33 // or boost/detail/iterator.hpp ? |
31 #include <boost/iterator/reverse_iterator.hpp> | 34 #include <boost/iterator/reverse_iterator.hpp> |
32 #include <boost/iterator/iterator_concepts.hpp> | 35 #include <boost/iterator/iterator_concepts.hpp> |
33 | 36 |
34 #include <boost/geometry/index/detail/assert.hpp> | 37 #include <boost/geometry/index/detail/assert.hpp> |
35 | 38 #include <boost/geometry/index/detail/exception.hpp> |
36 #include <boost/geometry/index/detail/assert.hpp> | 39 |
37 #include <boost/geometry/index/detail/varray_detail.hpp> | 40 #include <boost/geometry/index/detail/varray_detail.hpp> |
38 | 41 |
39 #include <boost/concept_check.hpp> | 42 #include <boost/concept_check.hpp> |
40 #include <boost/throw_exception.hpp> | |
41 | 43 |
42 /*! | 44 /*! |
43 \defgroup varray_non_member varray non-member functions | 45 \defgroup varray_non_member varray non-member functions |
44 */ | 46 */ |
45 | 47 |
77 ::boost::ignore_unused_variable_warning(s); | 79 ::boost::ignore_unused_variable_warning(s); |
78 } | 80 } |
79 | 81 |
80 static inline void throw_out_of_bounds(Varray const& v, size_type i) | 82 static inline void throw_out_of_bounds(Varray const& v, size_type i) |
81 { | 83 { |
82 //#ifndef BOOST_NO_EXCEPTIONS | |
83 if ( v.size() <= i ) | 84 if ( v.size() <= i ) |
84 BOOST_THROW_EXCEPTION(std::out_of_range("index out of bounds")); | 85 throw_out_of_range("index out of bounds"); |
85 //#else // BOOST_NO_EXCEPTIONS | |
86 // BOOST_GEOMETRY_INDEX_ASSERT(i < v.size(), "index out of bounds"); | |
87 //#endif // BOOST_NO_EXCEPTIONS | |
88 | 86 |
89 ::boost::ignore_unused_variable_warning(v); | 87 ::boost::ignore_unused_variable_warning(v); |
90 ::boost::ignore_unused_variable_warning(i); | 88 ::boost::ignore_unused_variable_warning(i); |
91 } | 89 } |
92 | 90 |
176 template <typename V, std::size_t C> | 174 template <typename V, std::size_t C> |
177 friend class varray; | 175 friend class varray; |
178 | 176 |
179 BOOST_COPYABLE_AND_MOVABLE(varray) | 177 BOOST_COPYABLE_AND_MOVABLE(varray) |
180 | 178 |
181 #ifdef BOOST_NO_RVALUE_REFERENCES | 179 #ifdef BOOST_NO_CXX11_RVALUE_REFERENCES |
182 public: | 180 public: |
183 template <std::size_t C> | 181 template <std::size_t C> |
184 varray & operator=(varray<Value, C> & sv) | 182 varray & operator=(varray<Value, C> & sv) |
185 { | 183 { |
186 typedef varray<Value, C> other; | 184 typedef varray<Value, C> other; |
361 //! @endinternal | 359 //! @endinternal |
362 //! | 360 //! |
363 //! @par Complexity | 361 //! @par Complexity |
364 //! Linear O(N). | 362 //! Linear O(N). |
365 template <std::size_t C> | 363 template <std::size_t C> |
366 // TEMPORARY WORKAROUND | 364 varray & operator=(BOOST_COPY_ASSIGN_REF_2_TEMPL_ARGS(varray, value_type, C) other) |
367 #if defined(BOOST_NO_RVALUE_REFERENCES) | |
368 varray & operator=(::boost::rv< varray<value_type, C> > const& other) | |
369 #else | |
370 varray & operator=(varray<value_type, C> const& other) | |
371 #endif | |
372 { | 365 { |
373 this->assign(other.begin(), other.end()); // may throw | 366 this->assign(other.begin(), other.end()); // may throw |
374 | 367 |
375 return *this; | 368 return *this; |
376 } | 369 } |
923 errh::check_iterator_end_eq(*this, last); | 916 errh::check_iterator_end_eq(*this, last); |
924 | 917 |
925 difference_type n = std::distance(first, last); | 918 difference_type n = std::distance(first, last); |
926 | 919 |
927 //TODO - add invalid range check? | 920 //TODO - add invalid range check? |
928 //BOOST_ASSERT_MSG(0 <= n, "invalid range"); | 921 //BOOST_GEOMETRY_INDEX_ASSERT(0 <= n, "invalid range"); |
929 //TODO - add this->size() check? | 922 //TODO - add this->size() check? |
930 //BOOST_ASSERT_MSG(n <= this->size(), "invalid range"); | 923 //BOOST_GEOMETRY_INDEX_ASSERT(n <= this->size(), "invalid range"); |
931 | 924 |
932 sv::move(last, this->end(), first); // may throw | 925 sv::move(last, this->end(), first); // may throw |
933 sv::destroy(this->end() - n, this->end()); | 926 sv::destroy(this->end() - n, this->end()); |
934 m_size -= n; | 927 m_size -= n; |
935 | 928 |
987 } | 980 } |
988 m_size = count; // update end | 981 m_size = count; // update end |
989 } | 982 } |
990 | 983 |
991 #if !defined(BOOST_CONTAINER_VARRAY_DISABLE_EMPLACE) | 984 #if !defined(BOOST_CONTAINER_VARRAY_DISABLE_EMPLACE) |
992 #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) | 985 #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
993 //! @pre <tt>size() < capacity()</tt> | 986 //! @pre <tt>size() < capacity()</tt> |
994 //! | 987 //! |
995 //! @brief Inserts a Value constructed with | 988 //! @brief Inserts a Value constructed with |
996 //! \c std::forward<Args>(args)... in the end of the container. | 989 //! \c std::forward<Args>(args)... in the end of the container. |
997 //! | 990 //! |
1068 } | 1061 } |
1069 | 1062 |
1070 return position; | 1063 return position; |
1071 } | 1064 } |
1072 | 1065 |
1073 #else // BOOST_CONTAINER_PERFECT_FORWARDING || BOOST_CONTAINER_DOXYGEN_INVOKED | 1066 #else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
1074 | 1067 |
1075 #define BOOST_PP_LOCAL_MACRO(n) \ | 1068 #define BOOST_GEOMETRY_INDEX_DETAIL_VARRAY_EMPLACE(N) \ |
1076 BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ | 1069 BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ |
1077 void emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ | 1070 void emplace_back(BOOST_MOVE_UREF##N) \ |
1078 { \ | 1071 { \ |
1079 typedef typename vt::disable_trivial_init dti; \ | 1072 typedef typename vt::disable_trivial_init dti; \ |
1080 \ | 1073 \ |
1081 errh::check_capacity(*this, m_size + 1); /*may throw*/\ | 1074 errh::check_capacity(*this, m_size + 1); /*may throw*/\ |
1082 \ | 1075 \ |
1083 namespace sv = varray_detail; \ | 1076 namespace sv = varray_detail; \ |
1084 sv::construct(dti(), this->end() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); /*may throw*/\ | 1077 sv::construct(dti(), this->end() BOOST_MOVE_I##N BOOST_MOVE_FWD##N ); /*may throw*/\ |
1085 ++m_size; /*update end*/ \ | 1078 ++m_size; /*update end*/ \ |
1086 } \ | 1079 } \ |
1087 // | 1080 \ |
1088 #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) | 1081 BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \ |
1089 #include BOOST_PP_LOCAL_ITERATE() | 1082 iterator emplace(iterator position BOOST_MOVE_I##N BOOST_MOVE_UREF##N) \ |
1090 | |
1091 #define BOOST_PP_LOCAL_MACRO(n) \ | |
1092 BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \ | |
1093 iterator emplace(iterator position BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \ | |
1094 { \ | 1083 { \ |
1095 typedef typename vt::disable_trivial_init dti; \ | 1084 typedef typename vt::disable_trivial_init dti; \ |
1096 namespace sv = varray_detail; \ | 1085 namespace sv = varray_detail; \ |
1097 \ | 1086 \ |
1098 errh::check_iterator_end_eq(*this, position); \ | 1087 errh::check_iterator_end_eq(*this, position); \ |
1099 errh::check_capacity(*this, m_size + 1); /*may throw*/\ | 1088 errh::check_capacity(*this, m_size + 1); /*may throw*/\ |
1100 \ | 1089 \ |
1101 if ( position == this->end() ) \ | 1090 if ( position == this->end() ) \ |
1102 { \ | 1091 { \ |
1103 sv::construct(dti(), position BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); /*may throw*/\ | 1092 sv::construct(dti(), position BOOST_MOVE_I##N BOOST_MOVE_FWD##N ); /*may throw*/\ |
1104 ++m_size; /*update end*/ \ | 1093 ++m_size; /*update end*/ \ |
1105 } \ | 1094 } \ |
1106 else \ | 1095 else \ |
1107 { \ | 1096 { \ |
1108 /* TODO - should following lines check for exception and revert to the old size? */ \ | 1097 /* TODO - should following lines check for exception and revert to the old size? */ \ |
1109 /* TODO - should move be used only if it's nonthrowing? */ \ | 1098 /* TODO - should move be used only if it's nonthrowing? */ \ |
1110 \ | 1099 \ |
1111 value_type & r = *(this->end() - 1); \ | 1100 value_type & r = *(this->end() - 1); \ |
1112 sv::construct(dti(), this->end(), boost::move(r)); /*may throw*/\ | 1101 sv::construct(dti(), this->end(), boost::move(r)); /*may throw*/\ |
1113 ++m_size; /*update end*/ \ | 1102 ++m_size; /*update end*/ \ |
1114 sv::move_backward(position, this->end() - 2, this->end() - 1); /*may throw*/\ | 1103 sv::move_backward(position, this->end() - 2, this->end() - 1); /*may throw*/\ |
1115 \ | 1104 \ |
1116 aligned_storage<sizeof(value_type), alignment_of<value_type>::value> temp_storage; \ | 1105 aligned_storage<sizeof(value_type), alignment_of<value_type>::value> temp_storage; \ |
1117 value_type * val_p = static_cast<value_type *>(temp_storage.address()); \ | 1106 value_type * val_p = static_cast<value_type *>(temp_storage.address()); \ |
1118 sv::construct(dti(), val_p BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) ); /*may throw*/\ | 1107 sv::construct(dti(), val_p BOOST_MOVE_I##N BOOST_MOVE_FWD##N ); /*may throw*/\ |
1119 sv::scoped_destructor<value_type> d(val_p); \ | 1108 sv::scoped_destructor<value_type> d(val_p); \ |
1120 sv::assign(position, ::boost::move(*val_p)); /*may throw*/\ | 1109 sv::assign(position, ::boost::move(*val_p)); /*may throw*/\ |
1121 } \ | 1110 } \ |
1122 \ | 1111 \ |
1123 return position; \ | 1112 return position; \ |
1124 } \ | 1113 } \ |
1125 // | 1114 |
1126 #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS) | 1115 BOOST_MOVE_ITERATE_0TO9(BOOST_GEOMETRY_INDEX_DETAIL_VARRAY_EMPLACE) |
1127 #include BOOST_PP_LOCAL_ITERATE() | 1116 #undef BOOST_GEOMETRY_INDEX_DETAIL_VARRAY_EMPLACE |
1128 | 1117 |
1129 #endif // BOOST_CONTAINER_PERFECT_FORWARDING || BOOST_CONTAINER_DOXYGEN_INVOKED | 1118 #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED) |
1130 #endif // !BOOST_CONTAINER_VARRAY_DISABLE_EMPLACE | 1119 #endif // !BOOST_CONTAINER_VARRAY_DISABLE_EMPLACE |
1131 | 1120 |
1132 //! @brief Removes all elements from the container. | 1121 //! @brief Removes all elements from the container. |
1133 //! | 1122 //! |
1134 //! @par Throws | 1123 //! @par Throws |
1409 //! @par Throws | 1398 //! @par Throws |
1410 //! Nothing. | 1399 //! Nothing. |
1411 //! | 1400 //! |
1412 //! @par Complexity | 1401 //! @par Complexity |
1413 //! Constant O(1). | 1402 //! Constant O(1). |
1414 const_reverse_iterator rbegin() const { return reverse_iterator(this->end()); } | 1403 const_reverse_iterator rbegin() const { return const_reverse_iterator(this->end()); } |
1415 | 1404 |
1416 //! @brief Returns const reverse iterator to the first element of the reversed container. | 1405 //! @brief Returns const reverse iterator to the first element of the reversed container. |
1417 //! | 1406 //! |
1418 //! @return const_reverse_iterator pointing to the beginning | 1407 //! @return const_reverse_iterator pointing to the beginning |
1419 //! of the reversed varray. | 1408 //! of the reversed varray. |
1421 //! @par Throws | 1410 //! @par Throws |
1422 //! Nothing. | 1411 //! Nothing. |
1423 //! | 1412 //! |
1424 //! @par Complexity | 1413 //! @par Complexity |
1425 //! Constant O(1). | 1414 //! Constant O(1). |
1426 const_reverse_iterator crbegin() const { return reverse_iterator(this->end()); } | 1415 const_reverse_iterator crbegin() const { return const_reverse_iterator(this->end()); } |
1427 | 1416 |
1428 //! @brief Returns reverse iterator to the one after the last element of the reversed container. | 1417 //! @brief Returns reverse iterator to the one after the last element of the reversed container. |
1429 //! | 1418 //! |
1430 //! @return reverse_iterator pointing to the one after the last element | 1419 //! @return reverse_iterator pointing to the one after the last element |
1431 //! of the reversed varray. | 1420 //! of the reversed varray. |
1445 //! @par Throws | 1434 //! @par Throws |
1446 //! Nothing. | 1435 //! Nothing. |
1447 //! | 1436 //! |
1448 //! @par Complexity | 1437 //! @par Complexity |
1449 //! Constant O(1). | 1438 //! Constant O(1). |
1450 const_reverse_iterator rend() const { return reverse_iterator(this->begin()); } | 1439 const_reverse_iterator rend() const { return const_reverse_iterator(this->begin()); } |
1451 | 1440 |
1452 //! @brief Returns const reverse iterator to the one after the last element of the reversed container. | 1441 //! @brief Returns const reverse iterator to the one after the last element of the reversed container. |
1453 //! | 1442 //! |
1454 //! @return const_reverse_iterator pointing to the one after the last element | 1443 //! @return const_reverse_iterator pointing to the one after the last element |
1455 //! of the reversed varray. | 1444 //! of the reversed varray. |
1457 //! @par Throws | 1446 //! @par Throws |
1458 //! Nothing. | 1447 //! Nothing. |
1459 //! | 1448 //! |
1460 //! @par Complexity | 1449 //! @par Complexity |
1461 //! Constant O(1). | 1450 //! Constant O(1). |
1462 const_reverse_iterator crend() const { return reverse_iterator(this->begin()); } | 1451 const_reverse_iterator crend() const { return const_reverse_iterator(this->begin()); } |
1463 | 1452 |
1464 //! @brief Returns container's capacity. | 1453 //! @brief Returns container's capacity. |
1465 //! | 1454 //! |
1466 //! @return container's capacity. | 1455 //! @return container's capacity. |
1467 //! | 1456 //! |
1617 // Nothing. | 1606 // Nothing. |
1618 // @par Complexity | 1607 // @par Complexity |
1619 // Linear O(N). | 1608 // Linear O(N). |
1620 void swap_dispatch_impl(iterator first_sm, iterator last_sm, iterator first_la, iterator last_la, boost::true_type const& /*use_memop*/) | 1609 void swap_dispatch_impl(iterator first_sm, iterator last_sm, iterator first_la, iterator last_la, boost::true_type const& /*use_memop*/) |
1621 { | 1610 { |
1622 //BOOST_ASSERT_MSG(std::distance(first_sm, last_sm) <= std::distance(first_la, last_la)); | 1611 //BOOST_GEOMETRY_INDEX_ASSERT(std::distance(first_sm, last_sm) <= std::distance(first_la, last_la), |
1612 // "incompatible ranges"); | |
1623 | 1613 |
1624 namespace sv = varray_detail; | 1614 namespace sv = varray_detail; |
1625 for (; first_sm != last_sm ; ++first_sm, ++first_la) | 1615 for (; first_sm != last_sm ; ++first_sm, ++first_la) |
1626 { | 1616 { |
1627 boost::aligned_storage< | 1617 boost::aligned_storage< |
1642 // If Value's move constructor or move assignment throws. | 1632 // If Value's move constructor or move assignment throws. |
1643 // @par Complexity | 1633 // @par Complexity |
1644 // Linear O(N). | 1634 // Linear O(N). |
1645 void swap_dispatch_impl(iterator first_sm, iterator last_sm, iterator first_la, iterator last_la, boost::false_type const& /*use_memop*/) | 1635 void swap_dispatch_impl(iterator first_sm, iterator last_sm, iterator first_la, iterator last_la, boost::false_type const& /*use_memop*/) |
1646 { | 1636 { |
1647 //BOOST_ASSERT_MSG(std::distance(first_sm, last_sm) <= std::distance(first_la, last_la)); | 1637 //BOOST_GEOMETRY_INDEX_ASSERT(std::distance(first_sm, last_sm) <= std::distance(first_la, last_la), |
1638 // "incompatible ranges"); | |
1648 | 1639 |
1649 namespace sv = varray_detail; | 1640 namespace sv = varray_detail; |
1650 for (; first_sm != last_sm ; ++first_sm, ++first_la) | 1641 for (; first_sm != last_sm ; ++first_sm, ++first_la) |
1651 { | 1642 { |
1652 //boost::swap(*first_sm, *first_la); // may throw | 1643 //boost::swap(*first_sm, *first_la); // may throw |
1949 // basic | 1940 // basic |
1950 template <typename Iterator> | 1941 template <typename Iterator> |
1951 void insert(iterator, Iterator first, Iterator last) | 1942 void insert(iterator, Iterator first, Iterator last) |
1952 { | 1943 { |
1953 // TODO - add MPL_ASSERT, check if Iterator is really an iterator | 1944 // TODO - add MPL_ASSERT, check if Iterator is really an iterator |
1954 typedef typename boost::iterator_traversal<Iterator>::type traversal; | |
1955 errh::check_capacity(*this, std::distance(first, last)); // may throw | 1945 errh::check_capacity(*this, std::distance(first, last)); // may throw |
1956 } | 1946 } |
1957 | 1947 |
1958 // basic | 1948 // basic |
1959 void erase(iterator position) | 1949 void erase(iterator position) |
1965 void erase(iterator first, iterator last) | 1955 void erase(iterator first, iterator last) |
1966 { | 1956 { |
1967 errh::check_iterator_end_eq(*this, first); | 1957 errh::check_iterator_end_eq(*this, first); |
1968 errh::check_iterator_end_eq(*this, last); | 1958 errh::check_iterator_end_eq(*this, last); |
1969 | 1959 |
1970 //BOOST_ASSERT_MSG(0 <= n, "invalid range"); | 1960 //BOOST_GEOMETRY_INDEX_ASSERT(0 <= n, "invalid range"); |
1971 } | 1961 } |
1972 | 1962 |
1973 // basic | 1963 // basic |
1974 template <typename Iterator> | 1964 template <typename Iterator> |
1975 void assign(Iterator first, Iterator last) | 1965 void assign(Iterator first, Iterator last) |
1976 { | 1966 { |
1977 // TODO - add MPL_ASSERT, check if Iterator is really an iterator | 1967 // TODO - add MPL_ASSERT, check if Iterator is really an iterator |
1978 typedef typename boost::iterator_traversal<Iterator>::type traversal; | |
1979 errh::check_capacity(*this, std::distance(first, last)); // may throw | 1968 errh::check_capacity(*this, std::distance(first, last)); // may throw |
1980 } | 1969 } |
1981 | 1970 |
1982 // basic | 1971 // basic |
1983 void assign(size_type count, value_type const&) | 1972 void assign(size_type count, value_type const&) |