/* Multiply indexed container.
*
- * Copyright 2003-2017 Joaquin M Lopez Munoz.
+ * Copyright 2003-2018 Joaquin M Lopez Munoz.
* Distributed under 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)
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <algorithm>
+#include <memory>
+#include <boost/core/addressof.hpp>
#include <boost/detail/allocator_utilities.hpp>
#include <boost/detail/no_exceptions_support.hpp>
#include <boost/detail/workaround.hpp>
Value,IndexSpecifierList,Allocator>::type
>::type>,
BOOST_MULTI_INDEX_PRIVATE_IF_MEMBER_TEMPLATE_FRIENDS detail::header_holder<
- typename boost::detail::allocator::rebind_to<
- Allocator,
- typename detail::multi_index_node_type<
- Value,IndexSpecifierList,Allocator>::type
- >::type::pointer,
+#ifndef BOOST_NO_CXX11_ALLOCATOR
+ typename std::allocator_traits<
+#endif
+ typename boost::detail::allocator::rebind_to<
+ Allocator,
+ typename detail::multi_index_node_type<
+ Value,IndexSpecifierList,Allocator>::type
+ >::type
+#ifdef BOOST_NO_CXX11_ALLOCATOR
+ ::pointer,
+#else
+ >::pointer,
+#endif
multi_index_container<Value,IndexSpecifierList,Allocator> >,
public detail::multi_index_base_type<
Value,IndexSpecifierList,Allocator>::type
Allocator,
typename super::node_type
>::type node_allocator;
+#ifdef BOOST_NO_CXX11_ALLOCATOR
+ typedef typename node_allocator::pointer node_pointer;
+#else
+ typedef std::allocator_traits<node_allocator> node_allocator_traits;
+ typedef typename node_allocator_traits::pointer node_pointer;
+#endif
typedef ::boost::base_from_member<
node_allocator> bfm_allocator;
typedef detail::header_holder<
- typename node_allocator::pointer,
+ node_pointer,
multi_index_container> bfm_header;
-
public:
/* All types are inherited from super, a few are explicitly
* brought forward here to save us some typename's.
node_type* allocate_node()
{
+#ifdef BOOST_NO_CXX11_ALLOCATOR
return &*bfm_allocator::member.allocate(1);
+#else
+ return &*node_allocator_traits::allocate(bfm_allocator::member,1);
+#endif
}
void deallocate_node(node_type* x)
{
- typedef typename node_allocator::pointer node_pointer;
+#ifdef BOOST_NO_CXX11_ALLOCATOR
bfm_allocator::member.deallocate(static_cast<node_pointer>(x),1);
+#else
+ node_allocator_traits::deallocate(bfm_allocator::member,static_cast<node_pointer>(x),1);
+#endif
}
bool empty_()const
{
node_type* x=allocate_node();
BOOST_TRY{
- new(&x->value()) value_type(t);
+ new(boost::addressof(x->value())) value_type(t);
BOOST_TRY{
node_type* res=super::insert_(x->value(),x,detail::emplaced_tag());
if(res==x){
return std::pair<node_type*,bool>(res,true);
}
else{
- boost::detail::allocator::destroy(&x->value());
+ boost::detail::allocator::destroy(boost::addressof(x->value()));
deallocate_node(x);
return std::pair<node_type*,bool>(res,false);
}
}
BOOST_CATCH(...){
- boost::detail::allocator::destroy(&x->value());
+ boost::detail::allocator::destroy(boost::addressof(x->value()));
BOOST_RETHROW;
}
BOOST_CATCH_END
node_type* x=allocate_node();
BOOST_TRY{
detail::vartempl_placement_new(
- &x->value(),BOOST_MULTI_INDEX_FORWARD_PARAM_PACK);
+ boost::addressof(x->value()),BOOST_MULTI_INDEX_FORWARD_PARAM_PACK);
BOOST_TRY{
node_type* res=super::insert_(x->value(),x,detail::emplaced_tag());
if(res==x){
return std::pair<node_type*,bool>(res,true);
}
else{
- boost::detail::allocator::destroy(&x->value());
+ boost::detail::allocator::destroy(boost::addressof(x->value()));
deallocate_node(x);
return std::pair<node_type*,bool>(res,false);
}
}
BOOST_CATCH(...){
- boost::detail::allocator::destroy(&x->value());
+ boost::detail::allocator::destroy(boost::addressof(x->value()));
BOOST_RETHROW;
}
BOOST_CATCH_END
{
node_type* x=allocate_node();
BOOST_TRY{
- new(&x->value()) value_type(t);
+ new(boost::addressof(x->value())) value_type(t);
BOOST_TRY{
node_type* res=super::insert_(
x->value(),position,x,detail::emplaced_tag());
return std::pair<node_type*,bool>(res,true);
}
else{
- boost::detail::allocator::destroy(&x->value());
+ boost::detail::allocator::destroy(boost::addressof(x->value()));
deallocate_node(x);
return std::pair<node_type*,bool>(res,false);
}
}
BOOST_CATCH(...){
- boost::detail::allocator::destroy(&x->value());
+ boost::detail::allocator::destroy(boost::addressof(x->value()));
BOOST_RETHROW;
}
BOOST_CATCH_END
node_type* x=allocate_node();
BOOST_TRY{
detail::vartempl_placement_new(
- &x->value(),BOOST_MULTI_INDEX_FORWARD_PARAM_PACK);
+ boost::addressof(x->value()),BOOST_MULTI_INDEX_FORWARD_PARAM_PACK);
BOOST_TRY{
node_type* res=super::insert_(
x->value(),position,x,detail::emplaced_tag());
return std::pair<node_type*,bool>(res,true);
}
else{
- boost::detail::allocator::destroy(&x->value());
+ boost::detail::allocator::destroy(boost::addressof(x->value()));
deallocate_node(x);
return std::pair<node_type*,bool>(res,false);
}
}
BOOST_CATCH(...){
- boost::detail::allocator::destroy(&x->value());
+ boost::detail::allocator::destroy(boost::addressof(x->value()));
BOOST_RETHROW;
}
BOOST_CATCH_END
index_saver_type sm(bfm_allocator::member,s);
for(iterator it=super::begin(),it_end=super::end();it!=it_end;++it){
- serialization::save_construct_data_adl(ar,&*it,value_version);
+ serialization::save_construct_data_adl(
+ ar,boost::addressof(*it),value_version);
ar<<serialization::make_nvp("item",*it);
sm.add(it.get_node(),ar,version);
}
if(!p.second)throw_exception(
archive::archive_exception(
archive::archive_exception::other_exception));
- ar.reset_object_address(&p.first->value(),&value.get());
+ ar.reset_object_address(
+ boost::addressof(p.first->value()),boost::addressof(value.get()));
lm.add(p.first,ar,version);
}
lm.add_track(header(),ar,version);