updated boost on windows

This commit is contained in:
Bassem Girgis
2019-08-13 21:48:48 -05:00
parent 7d77d485fd
commit b40a3bee82
5162 changed files with 473027 additions and 116452 deletions

View File

@@ -0,0 +1,143 @@
/* 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)
*
* See http://www.boost.org/libs/multi_index for library home page.
*/
#ifndef BOOST_MULTI_INDEX_DETAIL_ALLOCATOR_TRAITS_HPP
#define BOOST_MULTI_INDEX_DETAIL_ALLOCATOR_TRAITS_HPP
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
#include <memory>
#else
#include <boost/detail/workaround.hpp>
#include <boost/move/core.hpp>
#include <boost/move/utility_core.hpp>
#include <boost/multi_index/detail/vartempl_support.hpp>
#include <new>
#endif
namespace boost{
namespace multi_index{
namespace detail{
/* poor man's replacement of std::allocator_traits */
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
template<typename Allocator>
struct allocator_traits:std::allocator_traits<Allocator>
{
/* wrap std::allocator_traits alias templates for use in C++03 codebase */
typedef std::allocator_traits<Allocator> super;
template<typename T>
struct rebind_alloc
{
typedef typename super::template rebind_alloc<T> type;
};
template<typename T>
struct rebind_traits
{
typedef typename super::template rebind_traits<T> type;
};
};
#else
/* not a full std::allocator_traits rewrite (not needed) */
template<typename Allocator>
struct allocator_traits
{
typedef Allocator allocator_type;
typedef typename Allocator::value_type value_type;
typedef typename Allocator::pointer pointer;
typedef typename Allocator::const_pointer const_pointer;
/* [const_]void_pointer not provided as boost::pointer_traits's
* rebind_to has been seen to fail with things like
* boost::interprocess::offset_ptr in relatively old environments.
*/
typedef typename Allocator::difference_type difference_type;
typedef typename Allocator::size_type size_type;
template<typename T>
struct rebind_alloc
{
typedef typename Allocator::template rebind<T>::other type;
};
template<typename T>
struct rebind_traits
{
typedef allocator_traits<typename rebind_alloc<T>::type> type;
};
static pointer allocate(Allocator& a,size_type n){return a.allocate(n);}
static pointer allocate(Allocator& a,size_type n,const_pointer p)
/* should've been const_void_pointer p */
{return a.allocate(n,p);}
static void deallocate(Allocator& a,pointer p,size_type n)
{a.deallocate(p,n);}
template<typename T>
static void construct(Allocator&,T* p,const T& x)
{::new (static_cast<void*>(p)) T(x);}
template<typename T>
static void construct(Allocator&,T* p,BOOST_RV_REF(T) x)
{::new (static_cast<void*>(p)) T(boost::move(x));}
template<typename T,BOOST_MULTI_INDEX_TEMPLATE_PARAM_PACK>
static void construct(Allocator&,T* p,BOOST_MULTI_INDEX_FUNCTION_PARAM_PACK)
{
vartempl_placement_new(p,BOOST_MULTI_INDEX_FORWARD_PARAM_PACK);
}
#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1500))
/* MSVC issues spurious warnings about unreferencend formal parameters in
* destroy<T> when T is a class with trivial dtor.
*/
#pragma warning(push)
#pragma warning(disable:4100)
#endif
template<typename T>
static void destroy(Allocator&,T* p){p->~T();}
#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1500))
#pragma warning(pop)
#endif
static size_type max_size(Allocator& a)BOOST_NOEXCEPT{return a.max_size();}
};
#endif
template<typename Allocator,typename T>
struct rebind_alloc_for
{
typedef typename allocator_traits<Allocator>::
template rebind_alloc<T>::type type;
};
} /* namespace multi_index::detail */
} /* namespace multi_index */
} /* namespace boost */
#endif

View File

@@ -1,4 +1,4 @@
/* Copyright 2003-2013 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)
@@ -15,8 +15,8 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <algorithm>
#include <boost/detail/allocator_utilities.hpp>
#include <boost/multi_index/detail/adl_swap.hpp>
#include <boost/multi_index/detail/allocator_traits.hpp>
#include <boost/noncopyable.hpp>
#include <memory>
@@ -45,18 +45,18 @@ namespace detail{
template<typename T,typename Allocator=std::allocator<T> >
struct auto_space:private noncopyable
{
typedef typename boost::detail::allocator::rebind_to<
Allocator,T
>::type::pointer pointer;
typedef typename rebind_alloc_for<
Allocator,T>
::type allocator;
typedef allocator_traits<allocator> alloc_traits;
typedef typename alloc_traits::pointer pointer;
typedef typename alloc_traits::size_type size_type;
explicit auto_space(const Allocator& al=Allocator(),std::size_t n=1):
al_(al),n_(n),data_(n_?al_.allocate(n_):pointer(0))
explicit auto_space(const Allocator& al=Allocator(),size_type n=1):
al_(al),n_(n),data_(n_?alloc_traits::allocate(al_,n_):pointer(0))
{}
~auto_space()
{
if(n_)al_.deallocate(data_,n_);
}
~auto_space(){if(n_)alloc_traits::deallocate(al_,data_,n_);}
Allocator get_allocator()const{return al_;}
@@ -70,10 +70,9 @@ struct auto_space:private noncopyable
}
private:
typename boost::detail::allocator::rebind_to<
Allocator,T>::type al_;
std::size_t n_;
pointer data_;
allocator al_;
size_type n_;
pointer data_;
};
template<typename T,typename Allocator>

View File

@@ -1,4 +1,4 @@
/* Copyright 2003-2014 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)
@@ -36,7 +36,7 @@ class bidir_node_iterator:
public bidirectional_iterator_helper<
bidir_node_iterator<Node>,
typename Node::value_type,
std::ptrdiff_t,
typename Node::difference_type,
const typename Node::value_type*,
const typename Node::value_type&>
{

View File

@@ -1,4 +1,4 @@
/* Copyright 2003-2015 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)
@@ -15,6 +15,7 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <algorithm>
#include <boost/multi_index/detail/allocator_traits.hpp>
#include <boost/multi_index/detail/auto_space.hpp>
#include <boost/multi_index/detail/hash_index_node.hpp>
#include <boost/noncopyable.hpp>
@@ -128,7 +129,7 @@ class bucket_array:bucket_array_base<>
{
typedef bucket_array_base<> super;
typedef hashed_index_base_node_impl<
typename boost::detail::allocator::rebind_to<
typename rebind_alloc_for<
Allocator,
char
>::type
@@ -140,7 +141,7 @@ public:
bucket_array(const Allocator& al,pointer end_,std::size_t size_):
size_index_(super::size_index(size_)),
spc(al,super::sizes[size_index_]+1)
spc(al,static_cast<auto_space_size_type>(super::sizes[size_index_]+1))
{
clear(end_);
}
@@ -173,8 +174,11 @@ public:
}
private:
std::size_t size_index_;
auto_space<base_node_impl_type,Allocator> spc;
typedef auto_space<base_node_impl_type,Allocator> auto_space_type;
typedef typename auto_space_type::size_type auto_space_size_type;
std::size_t size_index_;
auto_space_type spc;
base_pointer buckets()const
{

View File

@@ -1,4 +1,4 @@
/* Copyright 2003-2015 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)
@@ -15,11 +15,12 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <algorithm>
#include <boost/core/addressof.hpp>
#include <boost/detail/no_exceptions_support.hpp>
#include <boost/multi_index/detail/allocator_traits.hpp>
#include <boost/multi_index/detail/auto_space.hpp>
#include <boost/multi_index/detail/raw_ptr.hpp>
#include <boost/noncopyable.hpp>
#include <cstddef>
#include <functional>
namespace boost{
@@ -57,11 +58,18 @@ struct copy_map_entry
template <typename Node,typename Allocator>
class copy_map:private noncopyable
{
typedef typename rebind_alloc_for<
Allocator,Node
>::type allocator_type;
typedef allocator_traits<allocator_type> alloc_traits;
typedef typename alloc_traits::pointer pointer;
public:
typedef const copy_map_entry<Node>* const_iterator;
typedef const copy_map_entry<Node>* const_iterator;
typedef typename alloc_traits::size_type size_type;
copy_map(
const Allocator& al,std::size_t size,Node* header_org,Node* header_cpy):
const Allocator& al,size_type size,Node* header_org,Node* header_cpy):
al_(al),size_(size),spc(al_,size_),n(0),
header_org_(header_org),header_cpy_(header_cpy),released(false)
{}
@@ -69,8 +77,9 @@ public:
~copy_map()
{
if(!released){
for(std::size_t i=0;i<n;++i){
boost::detail::allocator::destroy(&(spc.data()+i)->second->value());
for(size_type i=0;i<n;++i){
alloc_traits::destroy(
al_,boost::addressof((spc.data()+i)->second->value()));
deallocate((spc.data()+i)->second);
}
}
@@ -82,10 +91,10 @@ public:
void clone(Node* node)
{
(spc.data()+n)->first=node;
(spc.data()+n)->second=raw_ptr<Node*>(al_.allocate(1));
(spc.data()+n)->second=raw_ptr<Node*>(allocate());
BOOST_TRY{
boost::detail::allocator::construct(
&(spc.data()+n)->second->value(),node->value());
alloc_traits::construct(
al_,boost::addressof((spc.data()+n)->second->value()),node->value());
}
BOOST_CATCH(...){
deallocate((spc.data()+n)->second);
@@ -114,22 +123,22 @@ public:
}
private:
typedef typename boost::detail::allocator::rebind_to<
Allocator,Node
>::type allocator_type;
typedef typename allocator_type::pointer allocator_pointer;
allocator_type al_;
size_type size_;
auto_space<copy_map_entry<Node>,Allocator> spc;
size_type n;
Node* header_org_;
Node* header_cpy_;
bool released;
allocator_type al_;
std::size_t size_;
auto_space<copy_map_entry<Node>,Allocator> spc;
std::size_t n;
Node* header_org_;
Node* header_cpy_;
bool released;
pointer allocate()
{
return alloc_traits::allocate(al_,1);
}
void deallocate(Node* node)
{
al_.deallocate(static_cast<allocator_pointer>(node),1);
alloc_traits::deallocate(al_,static_cast<pointer>(node),1);
}
};

View File

@@ -1,4 +1,4 @@
/* Copyright 2003-2013 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)
@@ -14,7 +14,6 @@
#endif
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <cstddef>
#include <iterator>
namespace boost{
@@ -32,7 +31,7 @@ class duplicates_iterator
{
public:
typedef typename Node::value_type value_type;
typedef std::ptrdiff_t difference_type;
typedef typename Node::difference_type difference_type;
typedef const typename Node::value_type* pointer;
typedef const typename Node::value_type& reference;
typedef std::forward_iterator_tag iterator_category;

View File

@@ -1,4 +1,4 @@
/* Copyright 2003-2014 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)
@@ -39,7 +39,7 @@ class hashed_index_iterator:
public forward_iterator_helper<
hashed_index_iterator<Node,BucketArray,Category>,
typename Node::value_type,
std::ptrdiff_t,
typename Node::difference_type,
const typename Node::value_type*,
const typename Node::value_type&>
{

View File

@@ -1,4 +1,4 @@
/* Copyright 2003-2015 Joaquin M Lopez Munoz.
/* Copyright 2003-2019 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)
@@ -14,7 +14,7 @@
#endif
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/detail/allocator_utilities.hpp>
#include <boost/multi_index/detail/allocator_traits.hpp>
#include <boost/multi_index/detail/raw_ptr.hpp>
#include <utility>
@@ -99,24 +99,19 @@ struct hashed_index_node_impl;
template<typename Allocator>
struct hashed_index_base_node_impl
{
typedef typename
boost::detail::allocator::rebind_to<
Allocator,hashed_index_base_node_impl
>::type::pointer base_pointer;
typedef typename
boost::detail::allocator::rebind_to<
typedef typename rebind_alloc_for<
Allocator,hashed_index_base_node_impl
>::type::const_pointer const_base_pointer;
typedef typename
boost::detail::allocator::rebind_to<
Allocator,
hashed_index_node_impl<Allocator>
>::type::pointer pointer;
typedef typename
boost::detail::allocator::rebind_to<
Allocator,
hashed_index_node_impl<Allocator>
>::type::const_pointer const_pointer;
>::type base_allocator;
typedef typename rebind_alloc_for<
Allocator,hashed_index_node_impl<Allocator>
>::type node_allocator;
typedef allocator_traits<base_allocator> base_alloc_traits;
typedef allocator_traits<node_allocator> node_alloc_traits;
typedef typename base_alloc_traits::pointer base_pointer;
typedef typename base_alloc_traits::const_pointer const_base_pointer;
typedef typename node_alloc_traits::pointer pointer;
typedef typename node_alloc_traits::const_pointer const_pointer;
typedef typename node_alloc_traits::difference_type difference_type;
pointer& prior(){return prior_;}
pointer prior()const{return prior_;}
@@ -413,7 +408,7 @@ struct hashed_index_node_alg<Node,hashed_non_unique_tag>
buc->prior()=x;
x->next()->prior()=x;
}
};
}
static void link(pointer x,pointer first,pointer last)
{
@@ -694,17 +689,15 @@ private:
template<typename Super>
struct hashed_index_node_trampoline:
hashed_index_node_impl<
typename boost::detail::allocator::rebind_to<
typename Super::allocator_type,
char
typename rebind_alloc_for<
typename Super::allocator_type,char
>::type
>
{
typedef typename boost::detail::allocator::rebind_to<
typename Super::allocator_type,
char
>::type impl_allocator_type;
typedef hashed_index_node_impl<impl_allocator_type> impl_type;
typedef typename rebind_alloc_for<
typename Super::allocator_type,char
>::type impl_allocator_type;
typedef hashed_index_node_impl<impl_allocator_type> impl_type;
};
template<typename Super,typename Category>
@@ -722,6 +715,7 @@ public:
typedef typename trampoline::const_base_pointer const_impl_base_pointer;
typedef typename trampoline::pointer impl_pointer;
typedef typename trampoline::const_pointer const_impl_pointer;
typedef typename trampoline::difference_type difference_type;
impl_pointer& prior(){return trampoline::prior();}
impl_pointer prior()const{return trampoline::prior();}

View File

@@ -1,4 +1,4 @@
/* Copyright 2003-2014 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)
@@ -14,12 +14,13 @@
#endif
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/detail/allocator_utilities.hpp>
#include <boost/core/addressof.hpp>
#include <boost/detail/no_exceptions_support.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/move/core.hpp>
#include <boost/move/utility.hpp>
#include <boost/move/utility_core.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/multi_index/detail/allocator_traits.hpp>
#include <boost/multi_index/detail/copy_map.hpp>
#include <boost/multi_index/detail/do_not_copy_elements_tag.hpp>
#include <boost/multi_index/detail/node_type.hpp>
@@ -61,10 +62,8 @@ protected:
typedef multi_index_container<
Value,IndexSpecifierList,Allocator> final_type;
typedef tuples::null_type ctor_args_list;
typedef typename
boost::detail::allocator::rebind_to<
Allocator,
typename Allocator::value_type
typedef typename rebind_alloc_for<
Allocator,typename Allocator::value_type
>::type final_allocator_type;
typedef mpl::vector0<> index_type_list;
typedef mpl::vector0<> iterator_type_list;
@@ -85,6 +84,8 @@ protected:
private:
typedef Value value_type;
typedef allocator_traits<Allocator> alloc_traits;
typedef typename alloc_traits::size_type size_type;
protected:
explicit index_base(const ctor_args_list&,const Allocator&){}
@@ -102,7 +103,7 @@ protected:
{
x=final().allocate_node();
BOOST_TRY{
boost::detail::allocator::construct(&x->value(),v);
final().construct_value(x,v);
}
BOOST_CATCH(...){
final().deallocate_node(x);
@@ -116,14 +117,7 @@ protected:
{
x=final().allocate_node();
BOOST_TRY{
/* This shoud have used a modified, T&&-compatible version of
* boost::detail::allocator::construct, but
* <boost/detail/allocator_utilities.hpp> is too old and venerable to
* mess with; besides, it is a general internal utility and the imperfect
* perfect forwarding emulation of Boost.Move might break other libs.
*/
new (&x->value()) value_type(boost::move(const_cast<value_type&>(v)));
final().construct_value(x,boost::move(const_cast<value_type&>(v)));
}
BOOST_CATCH(...){
final().deallocate_node(x);
@@ -158,12 +152,12 @@ protected:
void erase_(node_type* x)
{
boost::detail::allocator::destroy(&x->value());
final().destroy_value(static_cast<final_node_type*>(x));
}
void delete_node_(node_type* x)
{
boost::detail::allocator::destroy(&x->value());
final().destroy_value(static_cast<final_node_type*>(x));
}
void clear_(){}
@@ -188,6 +182,8 @@ protected:
bool modify_rollback_(node_type*){return true;}
bool check_rollback_(node_type*)const{return true;}
#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
/* serialization */
@@ -211,9 +207,9 @@ protected:
final_node_type* final_header()const{return final().header();}
bool final_empty_()const{return final().empty_();}
std::size_t final_size_()const{return final().size_();}
std::size_t final_max_size_()const{return final().max_size_();}
bool final_empty_()const{return final().empty_();}
size_type final_size_()const{return final().size_();}
size_type final_max_size_()const{return final().max_size_();}
std::pair<final_node_type*,bool> final_insert_(const value_type& x)
{return final().insert_(x);}

View File

@@ -1,4 +1,4 @@
/* Copyright 2003-2015 Joaquin M Lopez Munoz.
/* Copyright 2003-2019 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)
@@ -43,6 +43,7 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <algorithm>
#include <boost/call_traits.hpp>
#include <boost/core/addressof.hpp>
#include <boost/detail/no_exceptions_support.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/foreach_fwd.hpp>
@@ -52,6 +53,7 @@
#include <boost/mpl/if.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/multi_index/detail/access_specifier.hpp>
#include <boost/multi_index/detail/allocator_traits.hpp>
#include <boost/multi_index/detail/bidir_node_iterator.hpp>
#include <boost/multi_index/detail/do_not_copy_elements_tag.hpp>
#include <boost/multi_index/detail/index_node_base.hpp>
@@ -161,8 +163,8 @@ public:
value_type,KeyFromValue,Compare> value_compare;
typedef tuple<key_from_value,key_compare> ctor_args;
typedef typename super::final_allocator_type allocator_type;
typedef typename allocator_type::reference reference;
typedef typename allocator_type::const_reference const_reference;
typedef value_type& reference;
typedef const value_type& const_reference;
#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
typedef safe_mode::safe_iterator<
@@ -174,10 +176,14 @@ public:
typedef iterator const_iterator;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef typename allocator_type::pointer pointer;
typedef typename allocator_type::const_pointer const_pointer;
private:
typedef allocator_traits<allocator_type> alloc_traits;
public:
typedef typename alloc_traits::size_type size_type;
typedef typename alloc_traits::difference_type difference_type;
typedef typename alloc_traits::pointer pointer;
typedef typename alloc_traits::const_pointer const_pointer;
typedef typename
boost::reverse_iterator<iterator> reverse_iterator;
typedef typename
@@ -267,12 +273,12 @@ public:
iterator iterator_to(const value_type& x)
{
return make_iterator(node_from_value<node_type>(&x));
return make_iterator(node_from_value<node_type>(boost::addressof(x)));
}
const_iterator iterator_to(const value_type& x)const
{
return make_iterator(node_from_value<node_type>(&x));
return make_iterator(node_from_value<node_type>(boost::addressof(x)));
}
/* capacity */
@@ -514,7 +520,7 @@ public:
size_type count(const CompatibleKey& x,const CompatibleCompare& comp)const
{
std::pair<iterator,iterator> p=equal_range(x,comp);
size_type n=std::distance(p.first,p.second);
size_type n=static_cast<size_type>(std::distance(p.first,p.second));
return n;
}
@@ -911,6 +917,11 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
BOOST_CATCH_END
}
bool check_rollback_(node_type* x)const
{
return in_place(x->value(),x,Category())&&super::check_rollback_(x);
}
#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
/* serialization */
@@ -1153,7 +1164,7 @@ private:
this->final_delete_node_(static_cast<final_node_type*>(x));
}
bool in_place(value_param_type v,node_type* x,ordered_unique_tag)
bool in_place(value_param_type v,node_type* x,ordered_unique_tag)const
{
node_type* y;
if(x!=leftmost()){
@@ -1167,7 +1178,7 @@ private:
return y==header()||comp_(key(v),key(y->value()));
}
bool in_place(value_param_type v,node_type* x,ordered_non_unique_tag)
bool in_place(value_param_type v,node_type* x,ordered_non_unique_tag)const
{
node_type* y;
if(x!=leftmost()){
@@ -1416,10 +1427,10 @@ protected:
const ctor_args_list& args_list,const allocator_type& al):
super(args_list,al){}
ordered_index(const ordered_index& x):super(x){};
ordered_index(const ordered_index& x):super(x){}
ordered_index(const ordered_index& x,do_not_copy_elements_tag):
super(x,do_not_copy_elements_tag()){};
super(x,do_not_copy_elements_tag()){}
};
/* comparison */

View File

@@ -1,4 +1,4 @@
/* Copyright 2003-2015 Joaquin M Lopez Munoz.
/* Copyright 2003-2019 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)
@@ -42,7 +42,7 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <cstddef>
#include <boost/detail/allocator_utilities.hpp>
#include <boost/multi_index/detail/allocator_traits.hpp>
#include <boost/multi_index/detail/raw_ptr.hpp>
#if !defined(BOOST_MULTI_INDEX_DISABLE_COMPRESSED_ORDERED_INDEX_NODES)
@@ -67,21 +67,32 @@ enum ordered_index_side{to_left=false,to_right=true};
template<typename AugmentPolicy,typename Allocator>
struct ordered_index_node_impl; /* fwd decl. */
template<typename AugmentPolicy,typename Allocator>
struct ordered_index_node_traits
{
typedef typename rebind_alloc_for<
Allocator,
ordered_index_node_impl<AugmentPolicy,Allocator>
>::type allocator;
typedef allocator_traits<allocator> alloc_traits;
typedef typename alloc_traits::pointer pointer;
typedef typename alloc_traits::const_pointer const_pointer;
typedef typename alloc_traits::difference_type difference_type;
typedef typename alloc_traits::size_type size_type;
};
template<typename AugmentPolicy,typename Allocator>
struct ordered_index_node_std_base
{
typedef typename
boost::detail::allocator::rebind_to<
Allocator,
ordered_index_node_impl<AugmentPolicy,Allocator>
>::type::pointer pointer;
typedef typename
boost::detail::allocator::rebind_to<
Allocator,
ordered_index_node_impl<AugmentPolicy,Allocator>
>::type::const_pointer const_pointer;
typedef ordered_index_color& color_ref;
typedef pointer& parent_ref;
typedef ordered_index_node_traits<
AugmentPolicy,Allocator> node_traits;
typedef typename node_traits::allocator node_allocator;
typedef typename node_traits::pointer pointer;
typedef typename node_traits::const_pointer const_pointer;
typedef typename node_traits::difference_type difference_type;
typedef typename node_traits::size_type size_type;
typedef ordered_index_color& color_ref;
typedef pointer& parent_ref;
ordered_index_color& color(){return color_;}
ordered_index_color color()const{return color_;}
@@ -120,14 +131,19 @@ private:
template<typename AugmentPolicy,typename Allocator>
struct ordered_index_node_compressed_base
{
typedef ordered_index_node_traits<
AugmentPolicy,Allocator> node_traits;
typedef ordered_index_node_impl<
AugmentPolicy,Allocator>* pointer;
AugmentPolicy,Allocator>* pointer;
typedef const ordered_index_node_impl<
AugmentPolicy,Allocator>* const_pointer;
AugmentPolicy,Allocator>* const_pointer;
typedef typename node_traits::difference_type difference_type;
typedef typename node_traits::size_type size_type;
struct color_ref
{
color_ref(uintptr_type* r_):r(r_){}
color_ref(const color_ref& x):r(x.r){}
operator ordered_index_color()const
{
@@ -153,6 +169,7 @@ struct ordered_index_node_compressed_base
struct parent_ref
{
parent_ref(uintptr_type* r_):r(r_){}
parent_ref(const parent_ref& x):r(x.r){}
operator pointer()const
{
@@ -217,10 +234,7 @@ struct ordered_index_node_impl_base:
ordered_index_node_compressed_base<AugmentPolicy,Allocator>
>::value%2)||
!(is_same<
typename boost::detail::allocator::rebind_to<
Allocator,
ordered_index_node_impl<AugmentPolicy,Allocator>
>::type::pointer,
typename ordered_index_node_traits<AugmentPolicy,Allocator>::pointer,
ordered_index_node_impl<AugmentPolicy,Allocator>*>::value),
ordered_index_node_std_base<AugmentPolicy,Allocator>,
ordered_index_node_compressed_base<AugmentPolicy,Allocator>
@@ -566,7 +580,7 @@ template<typename AugmentPolicy,typename Super>
struct ordered_index_node_trampoline:
ordered_index_node_impl<
AugmentPolicy,
typename boost::detail::allocator::rebind_to<
typename rebind_alloc_for<
typename Super::allocator_type,
char
>::type
@@ -574,7 +588,7 @@ struct ordered_index_node_trampoline:
{
typedef ordered_index_node_impl<
AugmentPolicy,
typename boost::detail::allocator::rebind_to<
typename rebind_alloc_for<
typename Super::allocator_type,
char
>::type
@@ -589,11 +603,13 @@ private:
typedef ordered_index_node_trampoline<AugmentPolicy,Super> trampoline;
public:
typedef typename trampoline::impl_type impl_type;
typedef typename trampoline::color_ref impl_color_ref;
typedef typename trampoline::parent_ref impl_parent_ref;
typedef typename trampoline::pointer impl_pointer;
typedef typename trampoline::const_pointer const_impl_pointer;
typedef typename trampoline::impl_type impl_type;
typedef typename trampoline::color_ref impl_color_ref;
typedef typename trampoline::parent_ref impl_parent_ref;
typedef typename trampoline::pointer impl_pointer;
typedef typename trampoline::const_pointer const_impl_pointer;
typedef typename trampoline::difference_type difference_type;
typedef typename trampoline::size_type size_type;
impl_color_ref color(){return trampoline::color();}
ordered_index_color color()const{return trampoline::color();}

View File

@@ -1,4 +1,4 @@
/* Copyright 2003-2013 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)
@@ -15,11 +15,10 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <algorithm>
#include <boost/detail/allocator_utilities.hpp>
#include <boost/multi_index/detail/allocator_traits.hpp>
#include <boost/multi_index/detail/auto_space.hpp>
#include <boost/multi_index/detail/rnd_index_ptr_array.hpp>
#include <boost/noncopyable.hpp>
#include <cstddef>
namespace boost{
@@ -45,7 +44,7 @@ class random_access_index_loader_base:private noncopyable
{
protected:
typedef random_access_index_node_impl<
typename boost::detail::allocator::rebind_to<
typename rebind_alloc_for<
Allocator,
char
>::type
@@ -68,9 +67,9 @@ protected:
node_impl_pointer n=header;
next(n)=n;
for(std::size_t i=ptrs.size();i--;){
for(size_type i=ptrs.size();i--;){
n=prev(n);
std::size_t d=position(n);
size_type d=position(n);
if(d!=i){
node_impl_pointer m=prev(next_at(i));
std::swap(m->up(),n->up());
@@ -94,6 +93,9 @@ protected:
}
private:
typedef allocator_traits<Allocator> alloc_traits;
typedef typename alloc_traits::size_type size_type;
void preprocess()
{
if(!preprocessed){
@@ -112,17 +114,17 @@ private:
}
}
std::size_t position(node_impl_pointer x)const
size_type position(node_impl_pointer x)const
{
return (std::size_t)(x->up()-ptrs.begin());
return (size_type)(x->up()-ptrs.begin());
}
node_impl_pointer& next_at(std::size_t n)const
node_impl_pointer& next_at(size_type n)const
{
return *ptrs.at(n);
}
node_impl_pointer& prev_at(std::size_t n)const
node_impl_pointer& prev_at(size_type n)const
{
return *(prev_spc.data()+n);
}

View File

@@ -1,4 +1,4 @@
/* Copyright 2003-2015 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)
@@ -15,8 +15,8 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <algorithm>
#include <boost/detail/allocator_utilities.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multi_index/detail/allocator_traits.hpp>
#include <boost/multi_index/detail/raw_ptr.hpp>
#include <cstddef>
#include <functional>
@@ -30,18 +30,18 @@ namespace detail{
template<typename Allocator>
struct random_access_index_node_impl
{
typedef typename
boost::detail::allocator::rebind_to<
typedef typename rebind_alloc_for<
Allocator,random_access_index_node_impl
>::type::pointer pointer;
typedef typename
boost::detail::allocator::rebind_to<
Allocator,random_access_index_node_impl
>::type::const_pointer const_pointer;
typedef typename
boost::detail::allocator::rebind_to<
>::type node_allocator;
typedef allocator_traits<node_allocator> node_alloc_traits;
typedef typename node_alloc_traits::pointer pointer;
typedef typename node_alloc_traits::const_pointer const_pointer;
typedef typename node_alloc_traits::difference_type difference_type;
typedef typename rebind_alloc_for<
Allocator,pointer
>::type::pointer ptr_pointer;
>::type ptr_allocator;
typedef allocator_traits<ptr_allocator> ptr_alloc_traits;
typedef typename ptr_alloc_traits::pointer ptr_pointer;
ptr_pointer& up(){return up_;}
ptr_pointer up()const{return up_;}
@@ -58,14 +58,14 @@ struct random_access_index_node_impl
x=*(x->up()-1);
}
static void advance(pointer& x,std::ptrdiff_t n)
static void advance(pointer& x,difference_type n)
{
x=*(x->up()+n);
}
static std::ptrdiff_t distance(pointer x,pointer y)
static difference_type distance(pointer x,pointer y)
{
return y->up()-x->up();
return static_cast<difference_type>(y->up()-x->up());
}
/* algorithmic stuff */
@@ -176,14 +176,14 @@ private:
template<typename Super>
struct random_access_index_node_trampoline:
random_access_index_node_impl<
typename boost::detail::allocator::rebind_to<
typename rebind_alloc_for<
typename Super::allocator_type,
char
>::type
>
{
typedef random_access_index_node_impl<
typename boost::detail::allocator::rebind_to<
typename rebind_alloc_for<
typename Super::allocator_type,
char
>::type
@@ -198,10 +198,11 @@ private:
typedef random_access_index_node_trampoline<Super> trampoline;
public:
typedef typename trampoline::impl_type impl_type;
typedef typename trampoline::pointer impl_pointer;
typedef typename trampoline::const_pointer const_impl_pointer;
typedef typename trampoline::ptr_pointer impl_ptr_pointer;
typedef typename trampoline::impl_type impl_type;
typedef typename trampoline::pointer impl_pointer;
typedef typename trampoline::const_pointer const_impl_pointer;
typedef typename trampoline::difference_type difference_type;
typedef typename trampoline::ptr_pointer impl_ptr_pointer;
impl_ptr_pointer& up(){return trampoline::up();}
impl_ptr_pointer up()const{return trampoline::up();}
@@ -250,14 +251,14 @@ public:
x=from_impl(xi);
}
static void advance(random_access_index_node*& x,std::ptrdiff_t n)
static void advance(random_access_index_node*& x,difference_type n)
{
impl_pointer xi=x->impl();
trampoline::advance(xi,n);
x=from_impl(xi);
}
static std::ptrdiff_t distance(
static difference_type distance(
random_access_index_node* x,random_access_index_node* y)
{
return trampoline::distance(x->impl(),y->impl());

View File

@@ -1,4 +1,4 @@
/* Copyright 2003-2013 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)
@@ -15,11 +15,10 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <algorithm>
#include <boost/detail/allocator_utilities.hpp>
#include <boost/multi_index/detail/allocator_traits.hpp>
#include <boost/multi_index/detail/auto_space.hpp>
#include <boost/multi_index/detail/rnd_index_node.hpp>
#include <boost/noncopyable.hpp>
#include <cstddef>
namespace boost{
@@ -33,20 +32,23 @@ template<typename Allocator>
class random_access_index_ptr_array:private noncopyable
{
typedef random_access_index_node_impl<
typename boost::detail::allocator::rebind_to<
typename rebind_alloc_for<
Allocator,
char
>::type
> node_impl_type;
> node_impl_type;
public:
typedef typename node_impl_type::pointer value_type;
typedef typename boost::detail::allocator::rebind_to<
typedef typename node_impl_type::pointer value_type;
typedef typename rebind_alloc_for<
Allocator,value_type
>::type::pointer pointer;
>::type value_allocator;
typedef allocator_traits<value_allocator> alloc_traits;
typedef typename alloc_traits::pointer pointer;
typedef typename alloc_traits::size_type size_type;
random_access_index_ptr_array(
const Allocator& al,value_type end_,std::size_t sz):
const Allocator& al,value_type end_,size_type sz):
size_(sz),
capacity_(sz),
spc(al,capacity_+1)
@@ -55,8 +57,8 @@ public:
end_->up()=end();
}
std::size_t size()const{return size_;}
std::size_t capacity()const{return capacity_;}
size_type size()const{return size_;}
size_type capacity()const{return capacity_;}
void room_for_one()
{
@@ -65,7 +67,7 @@ public:
}
}
void reserve(std::size_t c)
void reserve(size_type c)
{
if(c>capacity_)set_capacity(c);
}
@@ -77,7 +79,7 @@ public:
pointer begin()const{return ptrs();}
pointer end()const{return ptrs()+size_;}
pointer at(std::size_t n)const{return ptrs()+n;}
pointer at(size_type n)const{return ptrs()+n;}
void push_back(value_type x)
{
@@ -109,8 +111,8 @@ public:
}
private:
std::size_t size_;
std::size_t capacity_;
size_type size_;
size_type capacity_;
auto_space<value_type,Allocator> spc;
pointer ptrs()const
@@ -118,7 +120,7 @@ private:
return spc.data();
}
void set_capacity(std::size_t c)
void set_capacity(size_type c)
{
auto_space<value_type,Allocator> spc1(spc.get_allocator(),c+1);
node_impl_type::transfer(begin(),end()+1,spc1.data());

View File

@@ -1,4 +1,4 @@
/* Copyright 2003-2014 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)
@@ -34,7 +34,7 @@ class rnd_node_iterator:
public random_access_iterator_helper<
rnd_node_iterator<Node>,
typename Node::value_type,
std::ptrdiff_t,
typename Node::difference_type,
const typename Node::value_type*,
const typename Node::value_type&>
{
@@ -60,13 +60,13 @@ public:
return *this;
}
rnd_node_iterator& operator+=(std::ptrdiff_t n)
rnd_node_iterator& operator+=(typename Node::difference_type n)
{
Node::advance(node,n);
return *this;
}
rnd_node_iterator& operator-=(std::ptrdiff_t n)
rnd_node_iterator& operator-=(typename Node::difference_type n)
{
Node::advance(node,-n);
return *this;
@@ -124,7 +124,7 @@ bool operator<(
}
template<typename Node>
std::ptrdiff_t operator-(
typename Node::difference_type operator-(
const rnd_node_iterator<Node>& x,
const rnd_node_iterator<Node>& y)
{

View File

@@ -1,4 +1,4 @@
/* 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)
@@ -14,9 +14,9 @@
#endif
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/core/pointer_traits.hpp>
#include <boost/mpl/and.hpp>
#include <boost/multi_index/detail/promotes_arg.hpp>
#include <cstddef>
#include <utility>
namespace boost{
@@ -30,19 +30,30 @@ namespace detail{
*/
template<typename Pointer>
inline std::size_t ranked_node_size(Pointer x)
struct ranked_node_size_type
{
typedef typename boost::pointer_traits<Pointer>::
element_type::size_type type;
};
template<typename Pointer>
inline typename ranked_node_size_type<Pointer>::type
ranked_node_size(Pointer x)
{
return x!=Pointer(0)?x->size:0;
}
template<typename Pointer>
inline Pointer ranked_index_nth(std::size_t n,Pointer end_)
inline Pointer ranked_index_nth(
BOOST_DEDUCED_TYPENAME ranked_node_size_type<Pointer>::type n,Pointer end_)
{
typedef typename ranked_node_size_type<Pointer>::type size_type;
Pointer top=end_->parent();
if(top==Pointer(0)||n>=top->size)return end_;
for(;;){
std::size_t s=ranked_node_size(top->left());
size_type s=ranked_node_size(top->left());
if(n==s)return top;
if(n<s)top=top->left();
else{
@@ -53,13 +64,16 @@ inline Pointer ranked_index_nth(std::size_t n,Pointer end_)
}
template<typename Pointer>
inline std::size_t ranked_index_rank(Pointer x,Pointer end_)
inline typename ranked_node_size_type<Pointer>::type
ranked_index_rank(Pointer x,Pointer end_)
{
typedef typename ranked_node_size_type<Pointer>::type size_type;
Pointer top=end_->parent();
if(top==Pointer(0))return 0;
if(x==end_)return top->size;
std::size_t s=ranked_node_size(x->left());
size_type s=ranked_node_size(x->left());
while(x!=top){
Pointer z=x->parent();
if(x==z->right()){
@@ -74,7 +88,7 @@ template<
typename Node,typename KeyFromValue,
typename CompatibleKey,typename CompatibleCompare
>
inline std::size_t ranked_index_find_rank(
inline typename Node::size_type ranked_index_find_rank(
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
const CompatibleCompare& comp)
{
@@ -91,7 +105,7 @@ template<
typename Node,typename KeyFromValue,
typename CompatibleCompare
>
inline std::size_t ranked_index_find_rank(
inline typename Node::size_type ranked_index_find_rank(
Node* top,Node* y,const KeyFromValue& key,
const BOOST_DEDUCED_TYPENAME KeyFromValue::result_type& x,
const CompatibleCompare& comp,mpl::true_)
@@ -103,15 +117,17 @@ template<
typename Node,typename KeyFromValue,
typename CompatibleKey,typename CompatibleCompare
>
inline std::size_t ranked_index_find_rank(
inline typename Node::size_type ranked_index_find_rank(
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
const CompatibleCompare& comp,mpl::false_)
{
typedef typename Node::size_type size_type;
if(!top)return 0;
std::size_t s=top->impl()->size,
s0=s;
Node* y0=y;
size_type s=top->impl()->size,
s0=s;
Node* y0=y;
do{
if(!comp(key(top->value()),x)){
@@ -129,7 +145,7 @@ template<
typename Node,typename KeyFromValue,
typename CompatibleKey,typename CompatibleCompare
>
inline std::size_t ranked_index_lower_bound_rank(
inline typename Node::size_type ranked_index_lower_bound_rank(
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
const CompatibleCompare& comp)
{
@@ -144,7 +160,7 @@ template<
typename Node,typename KeyFromValue,
typename CompatibleCompare
>
inline std::size_t ranked_index_lower_bound_rank(
inline typename Node::size_type ranked_index_lower_bound_rank(
Node* top,Node* y,const KeyFromValue& key,
const BOOST_DEDUCED_TYPENAME KeyFromValue::result_type& x,
const CompatibleCompare& comp,mpl::true_)
@@ -156,13 +172,15 @@ template<
typename Node,typename KeyFromValue,
typename CompatibleKey,typename CompatibleCompare
>
inline std::size_t ranked_index_lower_bound_rank(
inline typename Node::size_type ranked_index_lower_bound_rank(
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
const CompatibleCompare& comp,mpl::false_)
{
typedef typename Node::size_type size_type;
if(!top)return 0;
std::size_t s=top->impl()->size;
size_type s=top->impl()->size;
do{
if(!comp(key(top->value()),x)){
@@ -180,7 +198,7 @@ template<
typename Node,typename KeyFromValue,
typename CompatibleKey,typename CompatibleCompare
>
inline std::size_t ranked_index_upper_bound_rank(
inline typename Node::size_type ranked_index_upper_bound_rank(
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
const CompatibleCompare& comp)
{
@@ -195,7 +213,7 @@ template<
typename Node,typename KeyFromValue,
typename CompatibleCompare
>
inline std::size_t ranked_index_upper_bound_rank(
inline typename Node::size_type ranked_index_upper_bound_rank(
Node* top,Node* y,const KeyFromValue& key,
const BOOST_DEDUCED_TYPENAME KeyFromValue::result_type& x,
const CompatibleCompare& comp,mpl::true_)
@@ -207,13 +225,15 @@ template<
typename Node,typename KeyFromValue,
typename CompatibleKey,typename CompatibleCompare
>
inline std::size_t ranked_index_upper_bound_rank(
inline typename Node::size_type ranked_index_upper_bound_rank(
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
const CompatibleCompare& comp,mpl::false_)
{
typedef typename Node::size_type size_type;
if(!top)return 0;
std::size_t s=top->impl()->size;
size_type s=top->impl()->size;
do{
if(comp(x,key(top->value()))){
@@ -231,7 +251,8 @@ template<
typename Node,typename KeyFromValue,
typename CompatibleKey,typename CompatibleCompare
>
inline std::pair<std::size_t,std::size_t> ranked_index_equal_range_rank(
inline std::pair<typename Node::size_type,typename Node::size_type>
ranked_index_equal_range_rank(
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
const CompatibleCompare& comp)
{
@@ -248,7 +269,8 @@ template<
typename Node,typename KeyFromValue,
typename CompatibleCompare
>
inline std::pair<std::size_t,std::size_t> ranked_index_equal_range_rank(
inline std::pair<typename Node::size_type,typename Node::size_type>
ranked_index_equal_range_rank(
Node* top,Node* y,const KeyFromValue& key,
const BOOST_DEDUCED_TYPENAME KeyFromValue::result_type& x,
const CompatibleCompare& comp,mpl::true_)
@@ -260,13 +282,16 @@ template<
typename Node,typename KeyFromValue,
typename CompatibleKey,typename CompatibleCompare
>
inline std::pair<std::size_t,std::size_t> ranked_index_equal_range_rank(
inline std::pair<typename Node::size_type,typename Node::size_type>
ranked_index_equal_range_rank(
Node* top,Node* y,const KeyFromValue& key,const CompatibleKey& x,
const CompatibleCompare& comp,mpl::false_)
{
if(!top)return std::pair<std::size_t,std::size_t>(0,0);
typedef typename Node::size_type size_type;
std::size_t s=top->impl()->size;
if(!top)return std::pair<size_type,size_type>(0,0);
size_type s=top->impl()->size;
do{
if(comp(key(top->value()),x)){
@@ -278,7 +303,7 @@ inline std::pair<std::size_t,std::size_t> ranked_index_equal_range_rank(
top=Node::from_impl(top->left());
}
else{
return std::pair<std::size_t,std::size_t>(
return std::pair<size_type,size_type>(
s-top->impl()->size+
ranked_index_lower_bound_rank(
Node::from_impl(top->left()),top,key,x,comp,mpl::false_()),
@@ -288,7 +313,7 @@ inline std::pair<std::size_t,std::size_t> ranked_index_equal_range_rank(
}
}while(top);
return std::pair<std::size_t,std::size_t>(s,s);
return std::pair<size_type,size_type>(s,s);
}
} /* namespace multi_index::detail */

View File

@@ -1,4 +1,4 @@
/* Copyright 2003-2015 Joaquin M Lopez Munoz.
/* Copyright 2003-2019 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)
@@ -15,7 +15,7 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <algorithm>
#include <boost/detail/allocator_utilities.hpp>
#include <boost/multi_index/detail/allocator_traits.hpp>
#include <boost/multi_index/detail/raw_ptr.hpp>
namespace boost{
@@ -29,14 +29,13 @@ namespace detail{
template<typename Allocator>
struct sequenced_index_node_impl
{
typedef typename
boost::detail::allocator::rebind_to<
typedef typename rebind_alloc_for<
Allocator,sequenced_index_node_impl
>::type::pointer pointer;
typedef typename
boost::detail::allocator::rebind_to<
Allocator,sequenced_index_node_impl
>::type::const_pointer const_pointer;
>::type node_allocator;
typedef allocator_traits<node_allocator> alloc_traits;
typedef typename alloc_traits::pointer pointer;
typedef typename alloc_traits::const_pointer const_pointer;
typedef typename alloc_traits::difference_type difference_type;
pointer& prior(){return prior_;}
pointer prior()const{return prior_;}
@@ -55,7 +54,7 @@ struct sequenced_index_node_impl
x->prior()=header->prior();
x->next()=header;
x->prior()->next()=x->next()->prior()=x;
};
}
static void unlink(pointer x)
{
@@ -133,14 +132,14 @@ private:
template<typename Super>
struct sequenced_index_node_trampoline:
sequenced_index_node_impl<
typename boost::detail::allocator::rebind_to<
typename rebind_alloc_for<
typename Super::allocator_type,
char
>::type
>
{
typedef sequenced_index_node_impl<
typename boost::detail::allocator::rebind_to<
typename rebind_alloc_for<
typename Super::allocator_type,
char
>::type
@@ -154,9 +153,10 @@ private:
typedef sequenced_index_node_trampoline<Super> trampoline;
public:
typedef typename trampoline::impl_type impl_type;
typedef typename trampoline::pointer impl_pointer;
typedef typename trampoline::const_pointer const_impl_pointer;
typedef typename trampoline::impl_type impl_type;
typedef typename trampoline::pointer impl_pointer;
typedef typename trampoline::const_pointer const_impl_pointer;
typedef typename trampoline::difference_type difference_type;
impl_pointer& prior(){return trampoline::prior();}
impl_pointer prior()const{return trampoline::prior();}

View File

@@ -1,4 +1,4 @@
/* Copyright 2003-2015 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)
@@ -16,7 +16,7 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <algorithm>
#include <boost/call_traits.hpp>
#include <boost/detail/allocator_utilities.hpp>
#include <boost/core/addressof.hpp>
#include <boost/detail/no_exceptions_support.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/foreach_fwd.hpp>
@@ -26,6 +26,7 @@
#include <boost/mpl/if.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/multi_index/detail/access_specifier.hpp>
#include <boost/multi_index/detail/allocator_traits.hpp>
#include <boost/multi_index/detail/auto_space.hpp>
#include <boost/multi_index/detail/bucket_array.hpp>
#include <boost/multi_index/detail/do_not_copy_elements_tag.hpp>
@@ -101,58 +102,63 @@ class hashed_index:
#pragma parse_mfunc_templ off
#endif
typedef typename SuperMeta::type super;
typedef typename SuperMeta::type super;
protected:
typedef hashed_index_node<
typename super::node_type,Category> node_type;
typename super::node_type,Category> node_type;
private:
typedef typename node_type::node_alg node_alg;
typedef typename node_type::impl_type node_impl_type;
typedef typename node_impl_type::pointer node_impl_pointer;
typedef typename node_impl_type::base_pointer node_impl_base_pointer;
typedef typename node_type::node_alg node_alg;
typedef typename node_type::impl_type node_impl_type;
typedef typename node_impl_type::pointer node_impl_pointer;
typedef typename node_impl_type::base_pointer node_impl_base_pointer;
typedef bucket_array<
typename super::final_allocator_type> bucket_array_type;
typename super::final_allocator_type> bucket_array_type;
public:
/* types */
typedef typename KeyFromValue::result_type key_type;
typedef typename node_type::value_type value_type;
typedef KeyFromValue key_from_value;
typedef Hash hasher;
typedef Pred key_equal;
typedef tuple<std::size_t,
key_from_value,hasher,key_equal> ctor_args;
typedef typename super::final_allocator_type allocator_type;
typedef typename allocator_type::pointer pointer;
typedef typename allocator_type::const_pointer const_pointer;
typedef typename allocator_type::reference reference;
typedef typename allocator_type::const_reference const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef typename KeyFromValue::result_type key_type;
typedef typename node_type::value_type value_type;
typedef KeyFromValue key_from_value;
typedef Hash hasher;
typedef Pred key_equal;
typedef typename super::final_allocator_type allocator_type;
private:
typedef allocator_traits<allocator_type> alloc_traits;
public:
typedef typename alloc_traits::pointer pointer;
typedef typename alloc_traits::const_pointer const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef typename alloc_traits::size_type size_type;
typedef typename alloc_traits::difference_type difference_type;
typedef tuple<size_type,
key_from_value,hasher,key_equal> ctor_args;
#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
typedef safe_mode::safe_iterator<
hashed_index_iterator<
node_type,bucket_array_type,
hashed_index_global_iterator_tag>,
hashed_index> iterator;
hashed_index> iterator;
#else
typedef hashed_index_iterator<
node_type,bucket_array_type,
hashed_index_global_iterator_tag> iterator;
hashed_index_global_iterator_tag> iterator;
#endif
typedef iterator const_iterator;
typedef iterator const_iterator;
typedef hashed_index_iterator<
node_type,bucket_array_type,
hashed_index_local_iterator_tag> local_iterator;
typedef local_iterator const_local_iterator;
hashed_index_local_iterator_tag> local_iterator;
typedef local_iterator const_local_iterator;
typedef TagList tag_list;
typedef TagList tag_list;
protected:
typedef typename super::final_node_type final_node_type;
@@ -238,12 +244,12 @@ public:
iterator iterator_to(const value_type& x)
{
return make_iterator(node_from_value<node_type>(&x));
return make_iterator(node_from_value<node_type>(boost::addressof(x)));
}
const_iterator iterator_to(const value_type& x)const
{
return make_iterator(node_from_value<node_type>(&x));
return make_iterator(node_from_value<node_type>(boost::addressof(x)));
}
/* modifiers */
@@ -518,7 +524,11 @@ public:
/* bucket interface */
size_type bucket_count()const BOOST_NOEXCEPT{return buckets.size();}
size_type bucket_count()const BOOST_NOEXCEPT
{
return static_cast<size_type>(buckets.size());
}
size_type max_bucket_count()const BOOST_NOEXCEPT{return static_cast<size_type>(-1);}
size_type bucket_size(size_type n)const
@@ -533,7 +543,7 @@ public:
size_type bucket(key_param_type k)const
{
return buckets.position(hash_(k));
return static_cast<size_type>(buckets.position(hash_(k)));
}
local_iterator begin(size_type n)
@@ -563,12 +573,14 @@ public:
local_iterator local_iterator_to(const value_type& x)
{
return make_local_iterator(node_from_value<node_type>(&x));
return make_local_iterator(
node_from_value<node_type>(boost::addressof(x)));
}
const_local_iterator local_iterator_to(const value_type& x)const
{
return make_local_iterator(node_from_value<node_type>(&x));
return make_local_iterator(
node_from_value<node_type>(boost::addressof(x)));
}
/* hash policy */
@@ -584,7 +596,7 @@ public:
if(size()<=max_load&&n<=bucket_count())return;
size_type bc =(std::numeric_limits<size_type>::max)();
float fbc=static_cast<float>(1+size()/mlf);
float fbc=1.0f+static_cast<float>(size())/mlf;
if(bc>fbc){
bc=static_cast<size_type>(fbc);
if(bc<n)bc=n;
@@ -594,7 +606,7 @@ public:
void reserve(size_type n)
{
rehash(static_cast<size_type>(std::ceil(static_cast<double>(n)/mlf)));
rehash(static_cast<size_type>(std::ceil(static_cast<float>(n)/mlf)));
}
BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
@@ -1009,6 +1021,12 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
BOOST_CATCH_END
}
bool check_rollback_(node_type* x)const
{
std::size_t buc=find_bucket(x->value());
return in_place(x->impl(),key(x->value()),buc)&&super::check_rollback_(x);
}
/* comparison */
#if !defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS)
@@ -1054,7 +1072,7 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
if(it!=it_last){
for(const_iterator scan=it;scan!=it_last;++scan){
if(std::find(it,scan,*scan)!=scan)continue;
std::ptrdiff_t matches=std::count(it2,it2_last,*scan);
difference_type matches=std::count(it2,it2_last,*scan);
if(matches==0||matches!=std::count(scan,it_last,*scan))return false;
}
it=it_last;
@@ -1271,7 +1289,7 @@ private:
void calculate_max_load()
{
float fml=static_cast<float>(mlf*static_cast<float>(bucket_count()));
float fml=mlf*static_cast<float>(bucket_count());
max_load=(std::numeric_limits<size_type>::max)();
if(max_load>fml)max_load=static_cast<size_type>(fml);
}
@@ -1280,7 +1298,7 @@ private:
{
if(n>max_load){
size_type bc =(std::numeric_limits<size_type>::max)();
float fbc=static_cast<float>(1+static_cast<double>(n)/mlf);
float fbc=1.0f+static_cast<float>(n)/mlf;
if(bc>fbc)bc =static_cast<size_type>(fbc);
unchecked_rehash(bc);
}

View File

@@ -0,0 +1,147 @@
/* 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)
*
* See http://www.boost.org/libs/multi_index for library home page.
*/
#ifndef BOOST_MULTI_INDEX_KEY_HPP
#define BOOST_MULTI_INDEX_KEY_HPP
#if defined(_MSC_VER)
#pragma once
#endif
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/multi_index/composite_key.hpp>
#include <boost/multi_index/global_fun.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/mem_fun.hpp>
#if __cplusplus>=201703L||\
defined(BOOST_MSVC)&&defined(__cpp_nontype_template_parameter_auto)
#define BOOST_MULTI_INDEX_KEY_SUPPORTED
#include <type_traits>
namespace boost{
namespace multi_index{
/* C++17 terse key specification syntax */
namespace detail{
template<typename T,T,typename=void>
struct typed_key_impl;
template<typename Class,typename Type,Type Class::*PtrToMember>
struct typed_key_impl<
Type Class::*,PtrToMember,
typename std::enable_if<!std::is_function<Type>::value>::type
>
{
using value_type=Class;
using type=member<Class,Type,PtrToMember>;
};
template<
typename Class,typename Type,Type (Class::*PtrToMemberFunction)()const
>
struct typed_key_impl<Type (Class::*)()const,PtrToMemberFunction>
{
using value_type=Class;
using type=const_mem_fun<Class,Type,PtrToMemberFunction>;
};
template<typename Class,typename Type,Type (Class::*PtrToMemberFunction)()>
struct typed_key_impl<Type (Class::*)(),PtrToMemberFunction>
{
using value_type=Class;
using type=mem_fun<Class,Type,PtrToMemberFunction>;
};
template<class Value,typename Type,Type (*PtrToFunction)(Value)>
struct typed_key_impl<Type (*)(Value),PtrToFunction>
{
using value_type=Value;
using type=global_fun<Value,Type,PtrToFunction>;
};
template<auto... Keys>
struct key_impl;
template<auto Key>
struct key_impl<Key>:typed_key_impl<decltype(Key),Key>{};
template<typename... Ts>
struct least_generic;
template<typename T0,typename... Ts>
struct least_generic<T0,Ts...>
{
using type=T0;
};
template<typename T0,typename T1,typename... Ts>
struct least_generic<T0,T1,Ts...>
{
static_assert(
std::is_convertible<const T0&,const T1&>::value||
std::is_convertible<const T1&,const T0&>::value,
"one type should be convertible to the other");
using type=typename least_generic<
typename std::conditional<
std::is_convertible<const T0&,const T1&>::value,T0,T1
>::type,
Ts...
>::type;
};
template<auto Key0,auto... Keys>
struct key_impl<Key0,Keys...>
{
using value_type=typename least_generic<
typename std::decay<typename key_impl<Key0>::value_type>::type,
typename std::decay<typename key_impl<Keys>::value_type>::type...
>::type;
using type=composite_key<
value_type,
typename key_impl<Key0>::type,
typename key_impl<Keys>::type...
>;
};
template<typename=composite_key<void,void>>
struct composite_key_size;
template<typename... Args>
struct composite_key_size<composite_key<Args...>>
{
static constexpr auto value=sizeof...(Args)-1;
};
template<auto... Keys>
struct limited_size_key_impl
{
static_assert(
sizeof...(Keys)<=composite_key_size<>::value,
"specified number of keys must meet the limits of "
"boost::multi_index::composite_key");
using type=typename key_impl<Keys...>::type;
};
} /* namespace multi_index::detail */
template<auto... Keys>
using key=typename detail::limited_size_key_impl<Keys...>::type;
} /* namespace multi_index */
} /* namespace boost */
#endif
#endif

View File

@@ -1,4 +1,4 @@
/* Copyright 2003-2015 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)
@@ -17,16 +17,18 @@
#include <algorithm>
#include <boost/bind.hpp>
#include <boost/call_traits.hpp>
#include <boost/core/addressof.hpp>
#include <boost/detail/no_exceptions_support.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/foreach_fwd.hpp>
#include <boost/iterator/reverse_iterator.hpp>
#include <boost/move/core.hpp>
#include <boost/move/utility.hpp>
#include <boost/move/utility_core.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/multi_index/detail/access_specifier.hpp>
#include <boost/multi_index/detail/allocator_traits.hpp>
#include <boost/multi_index/detail/do_not_copy_elements_tag.hpp>
#include <boost/multi_index/detail/index_node_base.hpp>
#include <boost/multi_index/detail/rnd_node_iterator.hpp>
@@ -40,7 +42,6 @@
#include <boost/throw_exception.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <cstddef>
#include <functional>
#include <stdexcept>
#include <utility>
@@ -95,46 +96,50 @@ class random_access_index:
#pragma parse_mfunc_templ off
#endif
typedef typename SuperMeta::type super;
typedef typename SuperMeta::type super;
protected:
typedef random_access_index_node<
typename super::node_type> node_type;
typename super::node_type> node_type;
private:
typedef typename node_type::impl_type node_impl_type;
typedef typename node_type::impl_type node_impl_type;
typedef random_access_index_ptr_array<
typename super::final_allocator_type> ptr_array;
typedef typename ptr_array::pointer node_impl_ptr_pointer;
typename super::final_allocator_type> ptr_array;
typedef typename ptr_array::pointer node_impl_ptr_pointer;
public:
/* types */
typedef typename node_type::value_type value_type;
typedef tuples::null_type ctor_args;
typedef typename super::final_allocator_type allocator_type;
typedef typename allocator_type::reference reference;
typedef typename allocator_type::const_reference const_reference;
typedef typename node_type::value_type value_type;
typedef tuples::null_type ctor_args;
typedef typename super::final_allocator_type allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
typedef safe_mode::safe_iterator<
rnd_node_iterator<node_type>,
random_access_index> iterator;
random_access_index> iterator;
#else
typedef rnd_node_iterator<node_type> iterator;
typedef rnd_node_iterator<node_type> iterator;
#endif
typedef iterator const_iterator;
typedef iterator const_iterator;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef typename allocator_type::pointer pointer;
typedef typename allocator_type::const_pointer const_pointer;
private:
typedef allocator_traits<allocator_type> alloc_traits;
public:
typedef typename alloc_traits::pointer pointer;
typedef typename alloc_traits::const_pointer const_pointer;
typedef typename alloc_traits::size_type size_type;
typedef typename alloc_traits::difference_type difference_type;
typedef typename
boost::reverse_iterator<iterator> reverse_iterator;
boost::reverse_iterator<iterator> reverse_iterator;
typedef typename
boost::reverse_iterator<const_iterator> const_reverse_iterator;
typedef TagList tag_list;
boost::reverse_iterator<const_iterator> const_reverse_iterator;
typedef TagList tag_list;
protected:
typedef typename super::final_node_type final_node_type;
@@ -249,12 +254,12 @@ public:
iterator iterator_to(const value_type& x)
{
return make_iterator(node_from_value<node_type>(&x));
return make_iterator(node_from_value<node_type>(boost::addressof(x)));
}
const_iterator iterator_to(const value_type& x)const
{
return make_iterator(node_from_value<node_type>(&x));
return make_iterator(node_from_value<node_type>(boost::addressof(x)));
}
/* capacity */
@@ -408,7 +413,7 @@ public:
BOOST_MULTI_INDEX_CHECK_IS_OWNER(last,*this);
BOOST_MULTI_INDEX_CHECK_VALID_RANGE(first,last);
BOOST_MULTI_INDEX_RND_INDEX_CHECK_INVARIANT;
difference_type n=last-first;
difference_type n=static_cast<difference_type>(last-first);
relocate(end(),first,last);
while(n--)pop_back();
return last;
@@ -877,6 +882,11 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
return super::modify_rollback_(x);
}
bool check_rollback_(node_type* x)const
{
return super::check_rollback_(x);
}
#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
/* serialization */

View File

@@ -1,4 +1,4 @@
/* 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)
@@ -29,7 +29,9 @@ namespace detail{
template<typename OrderedIndexNodeImpl>
struct ranked_node:OrderedIndexNodeImpl
{
std::size_t size;
typedef typename OrderedIndexNodeImpl::size_type size_type;
size_type size;
};
template<typename OrderedIndexImpl>
@@ -45,16 +47,17 @@ public:
typedef typename super::ctor_args_list ctor_args_list;
typedef typename super::allocator_type allocator_type;
typedef typename super::iterator iterator;
typedef typename super::size_type size_type;
/* rank operations */
iterator nth(std::size_t n)const
iterator nth(size_type n)const
{
return this->make_iterator(node_type::from_impl(
ranked_index_nth(n,this->header()->impl())));
}
std::size_t rank(iterator position)const
size_type rank(iterator position)const
{
BOOST_MULTI_INDEX_CHECK_VALID_ITERATOR(position);
BOOST_MULTI_INDEX_CHECK_IS_OWNER(position,*this);
@@ -64,14 +67,14 @@ public:
}
template<typename CompatibleKey>
std::size_t find_rank(const CompatibleKey& x)const
size_type find_rank(const CompatibleKey& x)const
{
return ranked_index_find_rank(
this->root(),this->header(),this->key,x,this->comp_);
}
template<typename CompatibleKey,typename CompatibleCompare>
std::size_t find_rank(
size_type find_rank(
const CompatibleKey& x,const CompatibleCompare& comp)const
{
return ranked_index_find_rank(
@@ -79,14 +82,14 @@ public:
}
template<typename CompatibleKey>
std::size_t lower_bound_rank(const CompatibleKey& x)const
size_type lower_bound_rank(const CompatibleKey& x)const
{
return ranked_index_lower_bound_rank(
this->root(),this->header(),this->key,x,this->comp_);
}
template<typename CompatibleKey,typename CompatibleCompare>
std::size_t lower_bound_rank(
size_type lower_bound_rank(
const CompatibleKey& x,const CompatibleCompare& comp)const
{
return ranked_index_lower_bound_rank(
@@ -94,14 +97,14 @@ public:
}
template<typename CompatibleKey>
std::size_t upper_bound_rank(const CompatibleKey& x)const
size_type upper_bound_rank(const CompatibleKey& x)const
{
return ranked_index_upper_bound_rank(
this->root(),this->header(),this->key,x,this->comp_);
}
template<typename CompatibleKey,typename CompatibleCompare>
std::size_t upper_bound_rank(
size_type upper_bound_rank(
const CompatibleKey& x,const CompatibleCompare& comp)const
{
return ranked_index_upper_bound_rank(
@@ -109,7 +112,7 @@ public:
}
template<typename CompatibleKey>
std::pair<std::size_t,std::size_t> equal_range_rank(
std::pair<size_type,size_type> equal_range_rank(
const CompatibleKey& x)const
{
return ranked_index_equal_range_rank(
@@ -117,7 +120,7 @@ public:
}
template<typename CompatibleKey,typename CompatibleCompare>
std::pair<std::size_t,std::size_t> equal_range_rank(
std::pair<size_type,size_type> equal_range_rank(
const CompatibleKey& x,const CompatibleCompare& comp)const
{
return ranked_index_equal_range_rank(
@@ -125,7 +128,7 @@ public:
}
template<typename LowerBounder,typename UpperBounder>
std::pair<std::size_t,std::size_t>
std::pair<size_type,size_type>
range_rank(LowerBounder lower,UpperBounder upper)const
{
typedef typename mpl::if_<
@@ -157,15 +160,15 @@ protected:
private:
template<typename LowerBounder,typename UpperBounder>
std::pair<std::size_t,std::size_t>
std::pair<size_type,size_type>
range_rank(LowerBounder lower,UpperBounder upper,none_unbounded_tag)const
{
node_type* y=this->header();
node_type* z=this->root();
if(!z)return std::pair<std::size_t,std::size_t>(0,0);
if(!z)return std::pair<size_type,size_type>(0,0);
std::size_t s=z->impl()->size;
size_type s=z->impl()->size;
do{
if(!lower(this->key(z->value()))){
@@ -177,7 +180,7 @@ private:
z=node_type::from_impl(z->left());
}
else{
return std::pair<std::size_t,std::size_t>(
return std::pair<size_type,size_type>(
s-z->impl()->size+
lower_range_rank(node_type::from_impl(z->left()),z,lower),
s-ranked_node_size(z->right())+
@@ -185,41 +188,41 @@ private:
}
}while(z);
return std::pair<std::size_t,std::size_t>(s,s);
return std::pair<size_type,size_type>(s,s);
}
template<typename LowerBounder,typename UpperBounder>
std::pair<std::size_t,std::size_t>
std::pair<size_type,size_type>
range_rank(LowerBounder,UpperBounder upper,lower_unbounded_tag)const
{
return std::pair<std::size_t,std::size_t>(
return std::pair<size_type,size_type>(
0,
upper_range_rank(this->root(),this->header(),upper));
}
template<typename LowerBounder,typename UpperBounder>
std::pair<std::size_t,std::size_t>
std::pair<size_type,size_type>
range_rank(LowerBounder lower,UpperBounder,upper_unbounded_tag)const
{
return std::pair<std::size_t,std::size_t>(
return std::pair<size_type,size_type>(
lower_range_rank(this->root(),this->header(),lower),
this->size());
}
template<typename LowerBounder,typename UpperBounder>
std::pair<std::size_t,std::size_t>
std::pair<size_type,size_type>
range_rank(LowerBounder,UpperBounder,both_unbounded_tag)const
{
return std::pair<std::size_t,std::size_t>(0,this->size());
return std::pair<size_type,size_type>(0,this->size());
}
template<typename LowerBounder>
std::size_t
size_type
lower_range_rank(node_type* top,node_type* y,LowerBounder lower)const
{
if(!top)return 0;
std::size_t s=top->impl()->size;
size_type s=top->impl()->size;
do{
if(lower(this->key(top->value()))){
@@ -234,12 +237,12 @@ private:
}
template<typename UpperBounder>
std::size_t
size_type
upper_range_rank(node_type* top,node_type* y,UpperBounder upper)const
{
if(!top)return 0;
std::size_t s=top->impl()->size;
size_type s=top->impl()->size;
do{
if(!upper(this->key(top->value()))){

View File

@@ -1,4 +1,4 @@
/* Copyright 2003-2015 Joaquin M Lopez Munoz.
/* Copyright 2003-2019 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)
@@ -16,17 +16,18 @@
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include <boost/bind.hpp>
#include <boost/call_traits.hpp>
#include <boost/detail/allocator_utilities.hpp>
#include <boost/core/addressof.hpp>
#include <boost/detail/no_exceptions_support.hpp>
#include <boost/detail/workaround.hpp>
#include <boost/foreach_fwd.hpp>
#include <boost/iterator/reverse_iterator.hpp>
#include <boost/move/core.hpp>
#include <boost/move/utility.hpp>
#include <boost/move/utility_core.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/not.hpp>
#include <boost/mpl/push_front.hpp>
#include <boost/multi_index/detail/access_specifier.hpp>
#include <boost/multi_index/detail/allocator_traits.hpp>
#include <boost/multi_index/detail/bidir_node_iterator.hpp>
#include <boost/multi_index/detail/do_not_copy_elements_tag.hpp>
#include <boost/multi_index/detail/index_node_base.hpp>
@@ -38,7 +39,6 @@
#include <boost/multi_index/sequenced_index_fwd.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <cstddef>
#include <functional>
#include <utility>
@@ -90,43 +90,47 @@ class sequenced_index:
#pragma parse_mfunc_templ off
#endif
typedef typename SuperMeta::type super;
typedef typename SuperMeta::type super;
protected:
typedef sequenced_index_node<
typename super::node_type> node_type;
typename super::node_type> node_type;
private:
typedef typename node_type::impl_type node_impl_type;
typedef typename node_type::impl_type node_impl_type;
public:
/* types */
typedef typename node_type::value_type value_type;
typedef tuples::null_type ctor_args;
typedef typename super::final_allocator_type allocator_type;
typedef typename allocator_type::reference reference;
typedef typename allocator_type::const_reference const_reference;
typedef typename node_type::value_type value_type;
typedef tuples::null_type ctor_args;
typedef typename super::final_allocator_type allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
#if defined(BOOST_MULTI_INDEX_ENABLE_SAFE_MODE)
typedef safe_mode::safe_iterator<
bidir_node_iterator<node_type>,
sequenced_index> iterator;
sequenced_index> iterator;
#else
typedef bidir_node_iterator<node_type> iterator;
typedef bidir_node_iterator<node_type> iterator;
#endif
typedef iterator const_iterator;
typedef iterator const_iterator;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef typename allocator_type::pointer pointer;
typedef typename allocator_type::const_pointer const_pointer;
private:
typedef allocator_traits<allocator_type> alloc_traits;
public:
typedef typename alloc_traits::pointer pointer;
typedef typename alloc_traits::const_pointer const_pointer;
typedef typename alloc_traits::size_type size_type;
typedef typename alloc_traits::difference_type difference_type;
typedef typename
boost::reverse_iterator<iterator> reverse_iterator;
boost::reverse_iterator<iterator> reverse_iterator;
typedef typename
boost::reverse_iterator<const_iterator> const_reverse_iterator;
typedef TagList tag_list;
boost::reverse_iterator<const_iterator> const_reverse_iterator;
typedef TagList tag_list;
protected:
typedef typename super::final_node_type final_node_type;
@@ -240,12 +244,12 @@ public:
iterator iterator_to(const value_type& x)
{
return make_iterator(node_from_value<node_type>(&x));
return make_iterator(node_from_value<node_type>(boost::addressof(x)));
}
const_iterator iterator_to(const value_type& x)const
{
return make_iterator(node_from_value<node_type>(&x));
return make_iterator(node_from_value<node_type>(boost::addressof(x)));
}
/* capacity */
@@ -267,7 +271,7 @@ public:
void resize(size_type n,value_param_type x)
{
BOOST_MULTI_INDEX_SEQ_INDEX_CHECK_INVARIANT;
if(n>size())insert(end(),n-size(),x);
if(n>size())insert(end(),static_cast<size_type>(n-size()),x);
else if(n<size())for(size_type m=size()-n;m--;)pop_back();
}
@@ -771,6 +775,11 @@ BOOST_MULTI_INDEX_PROTECTED_IF_MEMBER_TEMPLATE_FRIENDS:
return super::modify_rollback_(x);
}
bool check_rollback_(node_type* x)const
{
return super::check_rollback_(x);
}
#if !defined(BOOST_MULTI_INDEX_DISABLE_SERIALIZATION)
/* serialization */
@@ -834,7 +843,7 @@ private:
void link(node_type* x)
{
node_impl_type::link(x->impl(),header()->impl());
};
}
static void unlink(node_type* x)
{