[index] Remove Boost.Move and Boost.Preprocessor emulation of move semantics and variadic templates

This commit is contained in:
Adam Wulkiewicz 2023-05-01 17:07:49 +02:00
parent 7071251a4f
commit 2cffbef040
13 changed files with 131 additions and 289 deletions

View File

@ -2,7 +2,7 @@
//
// R-tree nodes
//
// Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2011-2023 Adam Wulkiewicz, Lodz, Poland.
//
// This file was modified by Oracle on 2019-2020.
// Modifications copyright (c) 2019-2020 Oracle and/or its affiliates.
@ -218,7 +218,7 @@ void move_from_back(Container & container, Iterator it)
--back_it;
if ( it != back_it )
{
*it = boost::move(*back_it); // MAY THROW (copy)
*it = std::move(*back_it); // MAY THROW (copy)
}
}

View File

@ -2,7 +2,7 @@
//
// Pairs intended to be used internally in nodes.
//
// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2011-2023 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
@ -11,8 +11,6 @@
#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 {
@ -24,46 +22,17 @@ 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)
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

View File

@ -2,7 +2,7 @@
//
// R-tree nodes based on Boost.Variant, storing dynamic-size containers
//
// Copyright (c) 2011-2018 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2011-2023 Adam Wulkiewicz, Lodz, Poland.
//
// This file was modified by Oracle on 2021.
// Modifications copyright (c) 2021 Oracle and/or its affiliates.
@ -164,23 +164,21 @@ public:
: node_allocator_type(alloc)
{}
inline allocators(BOOST_FWD_REF(allocators) a)
: node_allocator_type(boost::move(a.node_allocator()))
inline allocators(allocators&& a)
: node_allocator_type(std::move(a.node_allocator()))
{}
inline allocators & operator=(BOOST_FWD_REF(allocators) a)
inline allocators & operator=(allocators&& a)
{
node_allocator() = boost::move(a.node_allocator());
node_allocator() = std::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)
{

View File

@ -2,7 +2,7 @@
//
// R-tree nodes based on Boost.Variant, storing static-size containers
//
// Copyright (c) 2011-2018 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2011-2023 Adam Wulkiewicz, Lodz, Poland.
//
// This file was modified by Oracle on 2021.
// Modifications copyright (c) 2021 Oracle and/or its affiliates.
@ -128,23 +128,21 @@ public:
: node_allocator_type(alloc)
{}
inline allocators(BOOST_FWD_REF(allocators) a)
: node_allocator_type(boost::move(a.node_allocator()))
inline allocators(allocators&& a)
: node_allocator_type(std::move(a.node_allocator()))
{}
inline allocators & operator=(BOOST_FWD_REF(allocators) a)
inline allocators & operator=(allocators&& a)
{
node_allocator() = boost::move(a.node_allocator());
node_allocator() = std::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)
{

View File

@ -2,7 +2,7 @@
//
// R-tree nodes based on static conversion, storing dynamic-size containers
//
// Copyright (c) 2011-2018 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2011-2023 Adam Wulkiewicz, Lodz, Poland.
//
// This file was modified by Oracle on 2021.
// Modifications copyright (c) 2021 Oracle and/or its affiliates.
@ -204,26 +204,24 @@ public:
, 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(allocators&& a)
: internal_node_allocator_type(std::move(a.internal_node_allocator()))
, leaf_allocator_type(std::move(a.leaf_allocator()))
{}
inline allocators & operator=(BOOST_FWD_REF(allocators) a)
inline allocators & operator=(allocators&& a)
{
internal_node_allocator() = ::boost::move(a.internal_node_allocator());
leaf_allocator() = ::boost::move(a.leaf_allocator());
internal_node_allocator() = std::move(a.internal_node_allocator());
leaf_allocator() = std::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)
{

View File

@ -2,7 +2,7 @@
//
// R-tree nodes based on static conversion, storing static-size containers
//
// Copyright (c) 2011-2018 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2011-2023 Adam Wulkiewicz, Lodz, Poland.
//
// This file was modified by Oracle on 2021.
// Modifications copyright (c) 2021 Oracle and/or its affiliates.
@ -134,26 +134,24 @@ public:
, 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(allocators&& a)
: internal_node_allocator_type(std::move(a.internal_node_allocator()))
, leaf_allocator_type(std::move(a.leaf_allocator()))
{}
inline allocators & operator=(BOOST_FWD_REF(allocators) a)
inline allocators & operator=(allocators&& a)
{
internal_node_allocator() = ::boost::move(a.internal_node_allocator());
leaf_allocator() = ::boost::move(a.leaf_allocator());
internal_node_allocator() = std::move(a.internal_node_allocator());
leaf_allocator() = std::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)
{

View File

@ -2,7 +2,7 @@
//
// R-tree initial packing
//
// Copyright (c) 2011-2022 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2011-2023 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2020 Caian Benedicto, Campinas, Brazil.
//
// This file was modified by Oracle on 2019-2021.
@ -328,7 +328,7 @@ private:
{
// NOTE: push_back() must be called at the end in order to support move_iterator.
// The iterator is dereferenced 2x (no temporary reference) to support
// non-true reference types and move_iterator without boost::forward<>.
// non-true reference types and move_iterator without std::forward<>.
elements_box.expand(translator(*(first->second)));
rtree::elements(l).push_back(*(first->second)); // MAY THROW (A?,C)
}

View File

@ -2,7 +2,7 @@
//
// R-tree inserting visitor implementation
//
// Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2011-2023 Adam Wulkiewicz, Lodz, Poland.
//
// This file was modified by Oracle on 2019-2021.
// Modifications copyright (c) 2019-2021 Oracle and/or its affiliates.
@ -180,7 +180,7 @@ public:
// in the original node, then, if exception was thrown, the node would always have more than max
// elements.
// The alternative is to use moving semantics in the implementations of redistribute_elements,
// it will be possible to throw from boost::move() in the case of e.g. static size nodes.
// it will be possible to throw from std::move() in the case of e.g. static size nodes.
// redistribute elements
box_type box2;

View File

@ -1,6 +1,6 @@
// Boost.Geometry Index
//
// Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2011-2023 Adam Wulkiewicz, Lodz, Poland.
//
// This file was modified by Oracle on 2021.
// Modifications copyright (c) 2021 Oracle and/or its affiliates.
@ -48,7 +48,7 @@ class rtree;
namespace detail {
// TODO - use boost::move?
// TODO - use std::move?
template<typename T>
class serialization_storage
{

View File

@ -1,6 +1,6 @@
// Boost.Geometry Index
//
// Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2011-2023 Adam Wulkiewicz, Lodz, Poland.
//
// This file was modified by Oracle on 2020.
// Modifications copyright (c) 2020 Oracle and/or its affiliates.
@ -12,7 +12,7 @@
#include <type_traits>
#include <boost/swap.hpp>
#include <boost/core/swap.hpp>
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_UTILITIES_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_UTILITIES_HPP
@ -31,7 +31,7 @@ static inline void assign_cond(T &, T const&, std::false_type) {}
template<class T>
static inline void move_cond(T & l, T & r, std::true_type)
{
l = ::boost::move(r);
l = std::move(r);
}
template<class T>

View File

@ -1,7 +1,7 @@
// Boost.Container varray
//
// Copyright (c) 2011-2013 Andrew Hundt.
// Copyright (c) 2012-2015 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2012-2023 Adam Wulkiewicz, Lodz, Poland.
//
// This file was modified by Oracle on 2020.
// Modifications copyright (c) 2020, Oracle and/or its affiliates.
@ -18,14 +18,10 @@
#include <boost/container/detail/config_begin.hpp>
#include <boost/container/detail/workaround.hpp>
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/move/detail/fwd_macros.hpp>
#endif
#include <boost/concept_check.hpp>
#include <boost/config.hpp>
#include <boost/core/ignore_unused.hpp>
#include <boost/swap.hpp>
#include <boost/core/swap.hpp>
#include <boost/integer.hpp>
// TODO - use std::reverse_iterator and std::iterator_traits
@ -58,10 +54,10 @@ struct varray_traits
typedef Value value_type;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef Value * pointer;
typedef const Value * const_pointer;
typedef Value & reference;
typedef const Value & const_reference;
typedef Value* pointer;
typedef const Value* const_pointer;
typedef Value& reference;
typedef const Value& const_reference;
typedef std::false_type use_memop_in_swap_and_move;
typedef std::false_type use_optimized_swap;
@ -172,19 +168,6 @@ class varray
template <typename V, std::size_t C>
friend class varray;
BOOST_COPYABLE_AND_MOVABLE(varray)
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
public:
template <std::size_t C>
varray & operator=(varray<Value, C> & sv)
{
typedef varray<Value, C> other;
this->operator=(static_cast<const ::boost::rv<other> &>(const_cast<const other &>(sv)));
return *this;
}
#endif
public:
//! @brief The type of elements stored in the container.
typedef typename vt::value_type value_type;
@ -337,7 +320,7 @@ public:
//!
//! @par Complexity
//! Linear O(N).
varray & operator=(BOOST_COPY_ASSIGN_REF(varray) other)
varray& operator=(varray const& other)
{
this->assign(other.begin(), other.end()); // may throw
@ -359,7 +342,7 @@ public:
//! @par Complexity
//! Linear O(N).
template <std::size_t C>
varray & operator=(BOOST_COPY_ASSIGN_REF_2_TEMPL_ARGS(varray, value_type, C) other)
varray& operator=(varray<value_type, C> const& other)
{
this->assign(other.begin(), other.end()); // may throw
@ -371,15 +354,15 @@ public:
//! @param other The varray which content will be moved to this one.
//!
//! @par Throws
//! @li If \c boost::has_nothrow_move<Value>::value is \c true and Value's move constructor throws.
//! @li If \c boost::has_nothrow_move<Value>::value is \c false and Value's copy constructor throws.
//! @li If \c std::is_nothrow_move_constructible<Value>::value is \c true and Value's move constructor throws.
//! @li If \c std::is_nothrow_move_constructible<Value>::value is \c false and Value's copy constructor throws.
//! @internal
//! @li It throws only if \c use_memop_in_swap_and_move is \c false_type - default.
//! @endinternal
//!
//! @par Complexity
//! Linear O(N).
varray(BOOST_RV_REF(varray) other)
varray(varray&& other)
{
typedef typename
vt::use_memop_in_swap_and_move use_memop_in_swap_and_move;
@ -394,8 +377,8 @@ public:
//! @param other The varray which content will be moved to this one.
//!
//! @par Throws
//! @li If \c boost::has_nothrow_move<Value>::value is \c true and Value's move constructor throws.
//! @li If \c boost::has_nothrow_move<Value>::value is \c false and Value's copy constructor throws.
//! @li If \c std::is_nothrow_move_constructible<Value>::value is \c true and Value's move constructor throws.
//! @li If \c std::is_nothrow_move_constructible<Value>::value is \c false and Value's copy constructor throws.
//! @internal
//! @li It throws only if \c use_memop_in_swap_and_move is false_type - default.
//! @endinternal
@ -406,7 +389,7 @@ public:
//! @par Complexity
//! Linear O(N).
template <std::size_t C>
varray(BOOST_RV_REF_2_TEMPL_ARGS(varray, value_type, C) other)
varray(varray<value_type, C>&& other)
: m_size(other.m_size)
{
errh::check_capacity(*this, other.size()); // may throw
@ -422,15 +405,15 @@ public:
//! @param other The varray which content will be moved to this one.
//!
//! @par Throws
//! @li If \c boost::has_nothrow_move<Value>::value is \c true and Value's move constructor or move assignment throws.
//! @li If \c boost::has_nothrow_move<Value>::value is \c false and Value's copy constructor or copy assignment throws.
//! @li If \c std::is_nothrow_move_constructible<Value>::value is \c true and Value's move constructor or move assignment throws.
//! @li If \c std::is_nothrow_move_constructible<Value>::value is \c false and Value's copy constructor or copy assignment throws.
//! @internal
//! @li It throws only if \c use_memop_in_swap_and_move is \c false_type - default.
//! @endinternal
//!
//! @par Complexity
//! Linear O(N).
varray & operator=(BOOST_RV_REF(varray) other)
varray& operator=(varray&& other)
{
if ( &other == this )
return *this;
@ -450,8 +433,8 @@ public:
//! @param other The varray which content will be moved to this one.
//!
//! @par Throws
//! @li If \c boost::has_nothrow_move<Value>::value is \c true and Value's move constructor or move assignment throws.
//! @li If \c boost::has_nothrow_move<Value>::value is \c false and Value's copy constructor or copy assignment throws.
//! @li If \c std::is_nothrow_move_constructible<Value>::value is \c true and Value's move constructor or move assignment throws.
//! @li If \c std::is_nothrow_move_constructible<Value>::value is \c false and Value's copy constructor or copy assignment throws.
//! @internal
//! @li It throws only if \c use_memop_in_swap_and_move is \c false_type - default.
//! @endinternal
@ -462,7 +445,7 @@ public:
//! @par Complexity
//! Linear O(N).
template <std::size_t C>
varray & operator=(BOOST_RV_REF_2_TEMPL_ARGS(varray, value_type, C) other)
varray& operator=(varray<value_type, C>&& other)
{
errh::check_capacity(*this, other.size()); // may throw
@ -492,15 +475,15 @@ public:
//! @param other The varray which content will be swapped with this one's content.
//!
//! @par Throws
//! @li If \c boost::has_nothrow_move<Value>::value is \c true and Value's move constructor or move assignment throws,
//! @li If \c boost::has_nothrow_move<Value>::value is \c false and Value's copy constructor or copy assignment throws,
//! @li If \c std::is_nothrow_move_constructible<Value>::value is \c true and Value's move constructor or move assignment throws,
//! @li If \c std::is_nothrow_move_constructible<Value>::value is \c false and Value's copy constructor or copy assignment throws,
//! @internal
//! @li It throws only if \c use_memop_in_swap_and_move and \c use_optimized_swap are \c false_type - default.
//! @endinternal
//!
//! @par Complexity
//! Linear O(N).
void swap(varray & other)
void swap(varray& other)
{
typedef typename
vt::use_optimized_swap use_optimized_swap;
@ -515,8 +498,8 @@ public:
//! @param other The varray which content will be swapped with this one's content.
//!
//! @par Throws
//! @li If \c boost::has_nothrow_move<Value>::value is \c true and Value's move constructor or move assignment throws,
//! @li If \c boost::has_nothrow_move<Value>::value is \c false and Value's copy constructor or copy assignment throws,
//! @li If \c std::is_nothrow_move_constructible<Value>::value is \c true and Value's move constructor or move assignment throws,
//! @li If \c std::is_nothrow_move_constructible<Value>::value is \c false and Value's copy constructor or copy assignment throws,
//! @internal
//! @li It throws only if \c use_memop_in_swap_and_move and \c use_optimized_swap are \c false_type - default.
//! @endinternal
@ -527,7 +510,7 @@ public:
//! @par Complexity
//! Linear O(N).
template <std::size_t C>
void swap(varray<value_type, C> & other)
void swap(varray<value_type, C>& other)
{
errh::check_capacity(*this, other.size());
errh::check_capacity(other, this->size());
@ -661,14 +644,14 @@ public:
//!
//! @par Complexity
//! Constant O(1).
void push_back(BOOST_RV_REF(value_type) value)
void push_back(value_type&& value)
{
typedef typename vt::disable_trivial_init dti;
errh::check_capacity(*this, m_size + 1); // may throw
namespace sv = varray_detail;
sv::construct(dti(), this->end(), ::boost::move(value)); // may throw
sv::construct(dti(), this->end(), std::move(value)); // may throw
++m_size; // update end
}
@ -724,8 +707,8 @@ public:
else
{
// TODO - should move be used only if it's nonthrowing?
value_type & r = *(this->end() - 1);
sv::construct(dti(), this->end(), boost::move(r)); // may throw
value_type& r = *(this->end() - 1);
sv::construct(dti(), this->end(), std::move(r)); // may throw
++m_size; // update end
sv::move_backward(position, this->end() - 2, this->end() - 1); // may throw
sv::assign(position, value); // may throw
@ -751,7 +734,7 @@ public:
//!
//! @par Complexity
//! Constant or linear.
iterator insert(iterator position, BOOST_RV_REF(value_type) value)
iterator insert(iterator position, value_type&& value)
{
typedef typename vt::disable_trivial_init dti;
namespace sv = varray_detail;
@ -761,17 +744,17 @@ public:
if ( position == this->end() )
{
sv::construct(dti(), position, boost::move(value)); // may throw
sv::construct(dti(), position, std::move(value)); // may throw
++m_size; // update end
}
else
{
// TODO - should move be used only if it's nonthrowing?
value_type & r = *(this->end() - 1);
sv::construct(dti(), this->end(), boost::move(r)); // may throw
value_type& r = *(this->end() - 1);
sv::construct(dti(), this->end(), std::move(r)); // may throw
++m_size; // update end
sv::move_backward(position, this->end() - 2, this->end() - 1); // may throw
sv::assign(position, boost::move(value)); // may throw
sv::assign(position, std::move(value)); // may throw
}
return position;
@ -979,8 +962,6 @@ public:
m_size = count; // update end
}
#if !defined(BOOST_CONTAINER_VARRAY_DISABLE_EMPLACE)
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
//! @pre <tt>size() < capacity()</tt>
//!
//! @brief Inserts a Value constructed with
@ -997,14 +978,14 @@ public:
//! @par Complexity
//! Constant O(1).
template<class ...Args>
void emplace_back(BOOST_FWD_REF(Args) ...args)
void emplace_back(Args&& ...args)
{
typedef typename vt::disable_trivial_init dti;
errh::check_capacity(*this, m_size + 1); // may throw
namespace sv = varray_detail;
sv::construct(dti(), this->end(), ::boost::forward<Args>(args)...); // may throw
sv::construct(dti(), this->end(), std::forward<Args>(args)...); // may throw
++m_size; // update end
}
@ -1027,7 +1008,7 @@ public:
//! @par Complexity
//! Constant or linear.
template<class ...Args>
iterator emplace(iterator position, BOOST_FWD_REF(Args) ...args)
iterator emplace(iterator position, Args&& ...args)
{
typedef typename vt::disable_trivial_init dti;
@ -1038,7 +1019,7 @@ public:
if ( position == this->end() )
{
sv::construct(dti(), position, ::boost::forward<Args>(args)...); // may throw
sv::construct(dti(), position, std::forward<Args>(args)...); // may throw
++m_size; // update end
}
else
@ -1046,76 +1027,21 @@ public:
// TODO - should following lines check for exception and revert to the old size?
// TODO - should move be used only if it's nonthrowing?
value_type & r = *(this->end() - 1);
sv::construct(dti(), this->end(), boost::move(r)); // may throw
value_type& r = *(this->end() - 1);
sv::construct(dti(), this->end(), std::move(r)); // may throw
++m_size; // update end
sv::move_backward(position, this->end() - 2, this->end() - 1); // may throw
aligned_storage<sizeof(value_type), alignment_of<value_type>::value> temp_storage;
value_type * val_p = static_cast<value_type *>(temp_storage.address());
sv::construct(dti(), val_p, ::boost::forward<Args>(args)...); // may throw
value_type* val_p = static_cast<value_type*>(temp_storage.address());
sv::construct(dti(), val_p, std::forward<Args>(args)...); // may throw
sv::scoped_destructor<value_type> d(val_p);
sv::assign(position, ::boost::move(*val_p)); // may throw
sv::assign(position, std::move(*val_p)); // may throw
}
return position;
}
#else // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
#define BOOST_GEOMETRY_INDEX_DETAIL_VARRAY_EMPLACE(N) \
BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
void emplace_back(BOOST_MOVE_UREF##N) \
{ \
typedef typename vt::disable_trivial_init dti; \
\
errh::check_capacity(*this, m_size + 1); /*may throw*/\
\
namespace sv = varray_detail; \
sv::construct(dti(), this->end() BOOST_MOVE_I##N BOOST_MOVE_FWD##N ); /*may throw*/\
++m_size; /*update end*/ \
} \
\
BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
iterator emplace(iterator position BOOST_MOVE_I##N BOOST_MOVE_UREF##N) \
{ \
typedef typename vt::disable_trivial_init dti; \
namespace sv = varray_detail; \
\
errh::check_iterator_end_eq(*this, position); \
errh::check_capacity(*this, m_size + 1); /*may throw*/\
\
if ( position == this->end() ) \
{ \
sv::construct(dti(), position BOOST_MOVE_I##N BOOST_MOVE_FWD##N ); /*may throw*/\
++m_size; /*update end*/ \
} \
else \
{ \
/* TODO - should following lines check for exception and revert to the old size? */ \
/* TODO - should move be used only if it's nonthrowing? */ \
\
value_type & r = *(this->end() - 1); \
sv::construct(dti(), this->end(), boost::move(r)); /*may throw*/\
++m_size; /*update end*/ \
sv::move_backward(position, this->end() - 2, this->end() - 1); /*may throw*/\
\
aligned_storage<sizeof(value_type), alignment_of<value_type>::value> temp_storage; \
value_type * val_p = static_cast<value_type *>(temp_storage.address()); \
sv::construct(dti(), val_p BOOST_MOVE_I##N BOOST_MOVE_FWD##N ); /*may throw*/\
sv::scoped_destructor<value_type> d(val_p); \
sv::assign(position, ::boost::move(*val_p)); /*may throw*/\
} \
\
return position; \
} \
BOOST_MOVE_ITERATE_0TO9(BOOST_GEOMETRY_INDEX_DETAIL_VARRAY_EMPLACE)
#undef BOOST_GEOMETRY_INDEX_DETAIL_VARRAY_EMPLACE
#endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
#endif // !BOOST_CONTAINER_VARRAY_DISABLE_EMPLACE
//! @brief Removes all elements from the container.
//!
//! @par Throws
@ -1500,19 +1426,19 @@ private:
// @par Complexity
// Linear O(N).
template <std::size_t C>
void move_ctor_dispatch(varray<value_type, C> & other, std::true_type /*use_memop*/)
void move_ctor_dispatch(varray<value_type, C>& other, std::true_type /*use_memop*/)
{
::memcpy(this->data(), other.data(), sizeof(Value) * other.m_size);
m_size = other.m_size;
}
// @par Throws
// @li If boost::has_nothrow_move<Value>::value is true and Value's move constructor throws
// @li If boost::has_nothrow_move<Value>::value is false and Value's copy constructor throws.
// @li If std::is_nothrow_move_constructible<Value>::value is true and Value's move constructor throws
// @li If std::is_nothrow_move_constructible<Value>::value is false and Value's copy constructor throws.
// @par Complexity
// Linear O(N).
template <std::size_t C>
void move_ctor_dispatch(varray<value_type, C> & other, std::false_type /*use_memop*/)
void move_ctor_dispatch(varray<value_type, C>& other, std::false_type /*use_memop*/)
{
namespace sv = varray_detail;
sv::uninitialized_move_if_noexcept(other.begin(), other.end(), this->begin()); // may throw
@ -1524,7 +1450,7 @@ private:
// @par Complexity
// Linear O(N).
template <std::size_t C>
void move_assign_dispatch(varray<value_type, C> & other, std::true_type /*use_memop*/)
void move_assign_dispatch(varray<value_type, C>& other, std::true_type /*use_memop*/)
{
this->clear();
@ -1533,12 +1459,12 @@ private:
}
// @par Throws
// @li If boost::has_nothrow_move<Value>::value is true and Value's move constructor or move assignment throws
// @li If boost::has_nothrow_move<Value>::value is false and Value's copy constructor or move assignment throws.
// @li If std::is_nothrow_move_constructible<Value>::value is true and Value's move constructor or move assignment throws
// @li If std::is_nothrow_move_constructible<Value>::value is false and Value's copy constructor or move assignment throws.
// @par Complexity
// Linear O(N).
template <std::size_t C>
void move_assign_dispatch(varray<value_type, C> & other, std::false_type /*use_memop*/)
void move_assign_dispatch(varray<value_type, C>& other, std::false_type /*use_memop*/)
{
namespace sv = varray_detail;
if ( m_size <= static_cast<size_type>(other.size()) )
@ -1560,7 +1486,7 @@ private:
// @par Complexity
// Linear O(N).
template <std::size_t C>
void swap_dispatch(varray<value_type, C> & other, std::true_type /*use_optimized_swap*/)
void swap_dispatch(varray<value_type, C>& other, std::true_type /*use_optimized_swap*/)
{
typedef std::conditional_t
<
@ -1570,7 +1496,7 @@ private:
> storage_type;
storage_type temp;
Value * temp_ptr = reinterpret_cast<Value*>(temp.address());
Value* temp_ptr = reinterpret_cast<Value*>(temp.address());
::memcpy(temp_ptr, this->data(), sizeof(Value) * this->size());
::memcpy(this->data(), other.data(), sizeof(Value) * other.size());
@ -1585,7 +1511,7 @@ private:
// @par Complexity
// Linear O(N).
template <std::size_t C>
void swap_dispatch(varray<value_type, C> & other, std::false_type /*use_optimized_swap*/)
void swap_dispatch(varray<value_type, C>& other, std::false_type /*use_optimized_swap*/)
{
namespace sv = varray_detail;
@ -1615,7 +1541,7 @@ private:
sizeof(value_type),
boost::alignment_of<value_type>::value
> temp_storage;
value_type * temp_ptr = reinterpret_cast<value_type*>(temp_storage.address());
value_type* temp_ptr = reinterpret_cast<value_type*>(temp_storage.address());
::memcpy(temp_ptr, boost::addressof(*first_sm), sizeof(value_type));
::memcpy(boost::addressof(*first_sm), boost::addressof(*first_la), sizeof(value_type));
@ -1635,12 +1561,15 @@ private:
// "incompatible ranges");
namespace sv = varray_detail;
for (; first_sm != last_sm ; ++first_sm, ++first_la)
{
//boost::swap(*first_sm, *first_la); // may throw
value_type temp(boost::move(*first_sm)); // may throw
*first_sm = boost::move(*first_la); // may throw
*first_la = boost::move(temp); // may throw
//std::iter_swap(first_sm, first_la);
//std::swap(*first_sm, *first_la); // may throw
//boost::swap(*first_sm, *first_la);
value_type temp(std::move(*first_sm)); // may throw
*first_sm = std::move(*first_la); // may throw
*first_la = std::move(temp); // may throw
}
sv::uninitialized_move(first_la, last_la, first_sm); // may throw
sv::destroy(first_la, last_la);
@ -1872,7 +1801,7 @@ public:
}
// basic
varray & operator=(varray const& /*other*/)
varray& operator=(varray const& /*other*/)
{
//errh::check_capacity(*this, other.size());
return *this;
@ -1880,7 +1809,7 @@ public:
// basic
template <size_t C>
varray & operator=(varray<value_type, C> const& other)
varray& operator=(varray<value_type, C> const& other)
{
errh::check_capacity(*this, other.size()); // may throw
return *this;
@ -2031,8 +1960,8 @@ public:
}
// nothrow
Value * data() { return boost::addressof(*(this->ptr())); }
const Value * data() const { return boost::addressof(*(this->ptr())); }
Value* data() { return boost::addressof(*(this->ptr())); }
const Value* data() const { return boost::addressof(*(this->ptr())); }
// nothrow
iterator begin() { return this->ptr(); }
@ -2183,7 +2112,7 @@ bool operator>= (varray<V, C1> const& x, varray<V, C2> const& y)
//! @par Complexity
//! Linear O(N).
template<typename V, std::size_t C1, std::size_t C2>
inline void swap(varray<V, C1> & x, varray<V, C2> & y)
inline void swap(varray<V, C1>& x, varray<V, C2>& y)
{
x.swap(y);
}

View File

@ -3,7 +3,7 @@
// varray details
//
// Copyright (c) 2011-2013 Andrew Hundt.
// Copyright (c) 2012-2020 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2012-2023 Adam Wulkiewicz, Lodz, Poland.
//
// This file was modified by Oracle on 2020.
// Modifications copyright (c) 2020, Oracle and/or its affiliates.
@ -25,15 +25,10 @@
#include <boost/config.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <boost/move/move.hpp>
#include <boost/core/addressof.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <boost/iterator/iterator_traits.hpp>
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#include <boost/move/detail/fwd_macros.hpp>
#endif
// TODO - move vectors iterators optimization to the other, optional file instead of checking defines?
#if defined(BOOST_GEOMETRY_INDEX_DETAIL_VARRAY_ENABLE_VECTOR_OPTIMIZATION) && !defined(BOOST_NO_EXCEPTIONS)
@ -284,7 +279,7 @@ O uninitialized_move_dispatch(I first, I last, O dst,
{
typedef typename std::iterator_traits<O>::value_type value_type;
for (; first != last; ++first, ++o )
new (boost::addressof(*o)) value_type(boost::move(*first));
new (boost::addressof(*o)) value_type(std::move(*first));
}
BOOST_CATCH(...)
{
@ -324,7 +319,7 @@ inline
O move_dispatch(I first, I last, O dst,
std::false_type /*use_memmove*/)
{
return boost::move(first, last, dst); // may throw
return std::move(first, last, dst); // may throw
}
template <typename I, typename O>
@ -354,7 +349,7 @@ inline
BDO move_backward_dispatch(BDI first, BDI last, BDO dst,
std::false_type /*use_memmove*/)
{
return boost::move_backward(first, last, dst); // may throw
return std::move_backward(first, last, dst); // may throw
}
template <typename BDI, typename BDO>
@ -364,17 +359,6 @@ BDO move_backward(BDI first, BDI last, BDO dst)
return move_backward_dispatch(first, last, dst, is_memop_safe_for_range<BDI, BDO>()); // may throw
}
template <typename T>
struct has_nothrow_move
: std::integral_constant
<
bool,
::boost::has_nothrow_move<std::remove_const_t<T> >::value
||
::boost::has_nothrow_move<T>::value
>
{};
// uninitialized_move_if_noexcept(I, I, O)
template <typename I, typename O>
@ -397,7 +381,7 @@ template <typename I, typename O>
inline
O uninitialized_move_if_noexcept(I first, I last, O dst)
{
typedef has_nothrow_move<
typedef std::is_nothrow_move_constructible<
typename ::boost::iterator_value<O>::type
> use_move;
@ -426,7 +410,7 @@ template <typename I, typename O>
inline
O move_if_noexcept(I first, I last, O dst)
{
typedef has_nothrow_move<
typedef std::is_nothrow_move_constructible<
typename ::boost::iterator_value<O>::type
> use_move;
@ -495,7 +479,7 @@ inline
void construct_dispatch(std::false_type /*dont_init*/, I pos)
{
typedef typename ::boost::iterator_value<I>::type value_type;
new (static_cast<void*>(::boost::addressof(*pos))) value_type(); // may throw
new (static_cast<void*>(boost::addressof(*pos))) value_type(); // may throw
}
template <typename DisableTrivialInit, typename I>
@ -553,61 +537,32 @@ void construct_move_dispatch(I pos, V const& v,
template <typename I, typename P>
inline
void construct_move_dispatch(I pos, BOOST_RV_REF(P) p,
void construct_move_dispatch(I pos, P&& p,
std::false_type const& /*use_memcpy*/)
{
typedef typename boost::iterator_value<I>::type V;
new (static_cast<void*>(boost::addressof(*pos))) V(::boost::move(p)); // may throw
new (static_cast<void*>(boost::addressof(*pos))) V(std::move(p)); // may throw
}
template <typename DisableTrivialInit, typename I, typename P>
inline
void construct(DisableTrivialInit const&, I pos, BOOST_RV_REF(P) p)
void construct(DisableTrivialInit const&, I pos, P&& p)
{
construct_move_dispatch(pos, ::boost::move(p), is_memop_safe_for_value<I, P>()); // may throw
construct_move_dispatch(pos, std::move(p), is_memop_safe_for_value<I, P>()); // may throw
}
// Needed by emplace_back() and emplace()
#if !defined(BOOST_CONTAINER_VARRAY_DISABLE_EMPLACE)
#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
template <typename DisableTrivialInit, typename I, class ...Args>
inline
void construct(DisableTrivialInit const&,
I pos,
BOOST_FWD_REF(Args) ...args)
Args&& ...args)
{
typedef typename boost::iterator_value<I>::type V;
new (static_cast<void*>(boost::addressof(*pos))) V(::boost::forward<Args>(args)...); // may throw
new (static_cast<void*>(boost::addressof(*pos))) V(std::forward<Args>(args)...); // may throw
}
#else // !BOOST_NO_CXX11_VARIADIC_TEMPLATES
// BOOST_NO_CXX11_RVALUE_REFERENCES -> P0 const& p0
// !BOOST_NO_CXX11_RVALUE_REFERENCES -> P0 && p0
// which means that version with one parameter may take V const& v
#define BOOST_GEOMETRY_INDEX_DETAIL_VARRAY_DETAIL_CONSTRUCT(N) \
template <typename DisableTrivialInit, typename I, typename P BOOST_MOVE_I##N BOOST_MOVE_CLASS##N > \
inline \
void construct(DisableTrivialInit const&, \
I pos, \
BOOST_FWD_REF(P) p \
BOOST_MOVE_I##N BOOST_MOVE_UREF##N) \
{ \
typedef typename boost::iterator_value<I>::type V; \
new \
(static_cast<void*>(boost::addressof(*pos))) \
V(boost::forward<P>(p) BOOST_MOVE_I##N BOOST_MOVE_FWD##N); /*may throw*/ \
} \
BOOST_MOVE_ITERATE_1TO9(BOOST_GEOMETRY_INDEX_DETAIL_VARRAY_DETAIL_CONSTRUCT)
#undef BOOST_GEOMETRY_INDEX_DETAIL_VARRAY_DETAIL_CONSTRUCT
#endif // !BOOST_NO_CXX11_VARIADIC_TEMPLATES
#endif // !BOOST_CONTAINER_VARRAY_DISABLE_EMPLACE
// assign(I, V)
template <typename I, typename V>
@ -645,17 +600,17 @@ void assign_move_dispatch(I pos, V const& v,
template <typename I, typename V>
inline
void assign_move_dispatch(I pos, BOOST_RV_REF(V) v,
void assign_move_dispatch(I pos, V&& v,
std::false_type /*use_memcpy*/)
{
*pos = boost::move(v); // may throw
*pos = std::move(v); // may throw
}
template <typename I, typename V>
inline
void assign(I pos, BOOST_RV_REF(V) v)
void assign(I pos, V&& v)
{
assign_move_dispatch(pos, ::boost::move(v), is_memop_safe_for_value<I, V>());
assign_move_dispatch(pos, std::move(v), is_memop_safe_for_value<I, V>());
}
// uninitialized_copy_s

View File

@ -3,7 +3,7 @@
// R-tree implementation
//
// Copyright (c) 2008 Federico J. Fernandez.
// Copyright (c) 2011-2022 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2011-2023 Adam Wulkiewicz, Lodz, Poland.
// Copyright (c) 2020 Caian Benedicto, Campinas, Brazil.
//
// This file was modified by Oracle on 2019-2021.
@ -23,7 +23,6 @@
// Boost
#include <boost/container/new_allocator.hpp>
#include <boost/move/move.hpp>
#include <boost/tuple/tuple.hpp>
// Boost.Geometry
@ -172,8 +171,6 @@ template
>
class rtree
{
BOOST_COPYABLE_AND_MOVABLE(rtree)
public:
/*! \brief The type of Value stored in the container. */
typedef Value value_type;
@ -271,10 +268,10 @@ private:
members_holder(IndGet const& ind_get,
ValEq const& val_eq,
Parameters const& parameters,
BOOST_FWD_REF(Alloc) alloc)
Alloc&& alloc)
: translator_type(ind_get, val_eq)
, Parameters(parameters)
, allocators_type(boost::forward<Alloc>(alloc))
, allocators_type(std::forward<Alloc>(alloc))
, values_count(0)
, leafs_level(0)
, root(0)
@ -654,11 +651,11 @@ public:
\par Throws
Nothing.
*/
inline rtree(BOOST_RV_REF(rtree) src)
inline rtree(rtree&& src)
: m_members(src.m_members.indexable_getter(),
src.m_members.equal_to(),
src.m_members.parameters(),
boost::move(src.m_members.allocators()))
std::move(src.m_members.allocators()))
{
boost::swap(m_members.values_count, src.m_members.values_count);
boost::swap(m_members.leafs_level, src.m_members.leafs_level);
@ -678,7 +675,7 @@ public:
\li If Value copy constructor throws (only if allocators aren't equal).
\li If allocation throws or returns invalid value (only if allocators aren't equal).
*/
inline rtree(BOOST_RV_REF(rtree) src, allocator_type const& allocator)
inline rtree(rtree&& src, allocator_type const& allocator)
: m_members(src.m_members.indexable_getter(),
src.m_members.equal_to(),
src.m_members.parameters(),
@ -708,7 +705,7 @@ public:
\li If allocation throws.
\li If allocation throws or returns invalid value.
*/
inline rtree & operator=(BOOST_COPY_ASSIGN_REF(rtree) src)
inline rtree & operator=(rtree const& src)
{
if ( &src != this )
{
@ -746,7 +743,7 @@ public:
\li If Value copy constructor throws.
\li If allocation throws or returns invalid value.
*/
inline rtree & operator=(BOOST_RV_REF(rtree) src)
inline rtree & operator=(rtree&& src)
{
if ( &src != this )
{