1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519 |
- #ifndef BOOST_CONTAINER_LIST_HPP
- #define BOOST_CONTAINER_LIST_HPP
- #ifndef BOOST_CONFIG_HPP
- # include <boost/config.hpp>
- #endif
- #if defined(BOOST_HAS_PRAGMA_ONCE)
- # pragma once
- #endif
- #include <boost/container/detail/config_begin.hpp>
- #include <boost/container/detail/workaround.hpp>
- #include <boost/container/container_fwd.hpp>
- #include <boost/container/new_allocator.hpp> //new_allocator
- #include <boost/container/throw_exception.hpp>
- #include <boost/container/detail/algorithm.hpp>
- #include <boost/container/detail/compare_functors.hpp>
- #include <boost/container/detail/iterator.hpp>
- #include <boost/container/detail/iterators.hpp>
- #include <boost/container/detail/mpl.hpp>
- #include <boost/container/detail/node_alloc_holder.hpp>
- #include <boost/container/detail/version_type.hpp>
- #include <boost/container/detail/value_functors.hpp>
- #include <boost/move/utility_core.hpp>
- #include <boost/move/iterator.hpp>
- #include <boost/move/traits.hpp>
- #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
- # include <boost/move/detail/fwd_macros.hpp>
- #endif
- #include <boost/move/detail/move_helpers.hpp>
- #include <boost/intrusive/pointer_traits.hpp>
- #include <boost/intrusive/list.hpp>
- #include <boost/assert.hpp>
- #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
- #include <initializer_list>
- #endif
- namespace boost {
- namespace container {
- #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
- namespace dtl {
- template<class VoidPointer>
- struct list_hook
- {
- typedef typename dtl::bi::make_list_base_hook
- <dtl::bi::void_pointer<VoidPointer>, dtl::bi::link_mode<dtl::bi::normal_link> >::type type;
- };
- template <class T, class VoidPointer>
- struct iiterator_node_value_type< base_node<T, list_hook<VoidPointer> > >
- {
- typedef T type;
- };
- template<class Allocator>
- struct intrusive_list_type
- {
- typedef boost::container::allocator_traits<Allocator> allocator_traits_type;
- typedef typename allocator_traits_type::value_type value_type;
- typedef typename boost::intrusive::pointer_traits
- <typename allocator_traits_type::pointer>::template
- rebind_pointer<void>::type
- void_pointer;
- typedef base_node<value_type, list_hook<void_pointer> > node_type;
- typedef typename dtl::bi::make_list
- < node_type
- , dtl::bi::base_hook<typename list_hook<void_pointer>::type>
- , dtl::bi::constant_time_size<true>
- , dtl::bi::size_type
- <typename allocator_traits_type::size_type>
- >::type container_type;
- typedef container_type type ;
- };
- }
- #endif
- #ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
- template <class T, class Allocator = void >
- #else
- template <class T, class Allocator>
- #endif
- class list
- : protected dtl::node_alloc_holder
- < typename real_allocator<T, Allocator>::type
- , typename dtl::intrusive_list_type<typename real_allocator<T, Allocator>::type>::type>
- {
- #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
- typedef typename real_allocator<T, Allocator>::type ValueAllocator;
- typedef typename
- dtl::intrusive_list_type<ValueAllocator>::type Icont;
- typedef dtl::node_alloc_holder<ValueAllocator, Icont> AllocHolder;
- typedef typename AllocHolder::NodePtr NodePtr;
- typedef typename AllocHolder::NodeAlloc NodeAlloc;
- typedef typename AllocHolder::ValAlloc ValAlloc;
- typedef typename AllocHolder::Node Node;
- typedef dtl::allocator_node_destroyer<NodeAlloc> Destroyer;
- typedef typename AllocHolder::alloc_version alloc_version;
- typedef boost::container::allocator_traits<ValueAllocator> allocator_traits_type;
- typedef boost::container::equal_to_value
- <typename allocator_traits_type::value_type> equal_to_value_type;
- BOOST_COPYABLE_AND_MOVABLE(list)
- typedef dtl::iterator_from_iiterator<typename Icont::iterator, false> iterator_impl;
- typedef dtl::iterator_from_iiterator<typename Icont::iterator, true> const_iterator_impl;
- #endif
- public:
-
-
-
-
-
- typedef T value_type;
- typedef typename ::boost::container::allocator_traits<ValueAllocator>::pointer pointer;
- typedef typename ::boost::container::allocator_traits<ValueAllocator>::const_pointer const_pointer;
- typedef typename ::boost::container::allocator_traits<ValueAllocator>::reference reference;
- typedef typename ::boost::container::allocator_traits<ValueAllocator>::const_reference const_reference;
- typedef typename ::boost::container::allocator_traits<ValueAllocator>::size_type size_type;
- typedef typename ::boost::container::allocator_traits<ValueAllocator>::difference_type difference_type;
- typedef ValueAllocator allocator_type;
- typedef BOOST_CONTAINER_IMPDEF(NodeAlloc) stored_allocator_type;
- typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator;
- typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) const_iterator;
- typedef BOOST_CONTAINER_IMPDEF(boost::container::reverse_iterator<iterator>) reverse_iterator;
- typedef BOOST_CONTAINER_IMPDEF(boost::container::reverse_iterator<const_iterator>) const_reverse_iterator;
-
-
-
-
-
-
-
-
-
-
- list() BOOST_NOEXCEPT_IF(dtl::is_nothrow_default_constructible<ValueAllocator>::value)
- : AllocHolder()
- {}
-
-
-
-
-
- explicit list(const allocator_type &a) BOOST_NOEXCEPT_OR_NOTHROW
- : AllocHolder(a)
- {}
-
-
-
-
-
-
-
- explicit list(size_type n)
- : AllocHolder(ValueAllocator())
- { this->resize(n); }
-
-
-
-
-
-
-
- list(size_type n, const allocator_type &a)
- : AllocHolder(a)
- { this->resize(n); }
-
-
-
-
-
-
-
- list(size_type n, const T& value, const ValueAllocator& a = ValueAllocator())
- : AllocHolder(a)
- { this->insert(this->cbegin(), n, value); }
-
-
-
-
-
-
-
- list(const list& x)
- : AllocHolder(x)
- { this->insert(this->cbegin(), x.begin(), x.end()); }
-
-
-
-
-
- list(BOOST_RV_REF(list) x) BOOST_NOEXCEPT_OR_NOTHROW
- : AllocHolder(BOOST_MOVE_BASE(AllocHolder, x))
- {}
-
-
-
-
-
-
-
- list(const list& x, const allocator_type &a)
- : AllocHolder(a)
- { this->insert(this->cbegin(), x.begin(), x.end()); }
-
-
-
-
-
-
- list(BOOST_RV_REF(list) x, const allocator_type &a)
- : AllocHolder(a)
- {
- if(this->node_alloc() == x.node_alloc()){
- this->icont().swap(x.icont());
- }
- else{
- this->insert(this->cbegin(), boost::make_move_iterator(x.begin()), boost::make_move_iterator(x.end()));
- }
- }
-
-
-
-
-
-
-
- template <class InpIt>
- list(InpIt first, InpIt last, const ValueAllocator &a = ValueAllocator())
- : AllocHolder(a)
- { this->insert(this->cbegin(), first, last); }
- #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
-
-
-
-
-
-
-
-
- list(std::initializer_list<value_type> il, const ValueAllocator &a = ValueAllocator())
- : AllocHolder(a)
- { this->insert(this->cbegin(), il.begin(), il.end()); }
- #endif
-
-
-
-
-
-
- inline ~list() BOOST_NOEXCEPT_OR_NOTHROW
- {}
-
-
-
-
-
-
-
-
- list& operator=(BOOST_COPY_ASSIGN_REF(list) x)
- {
- if (BOOST_LIKELY(this != &x)) {
- NodeAlloc &this_alloc = this->node_alloc();
- const NodeAlloc &x_alloc = x.node_alloc();
- dtl::bool_<allocator_traits_type::
- propagate_on_container_copy_assignment::value> flag;
- if(flag && this_alloc != x_alloc){
- this->clear();
- }
- this->AllocHolder::copy_assign_alloc(x);
- this->assign(x.begin(), x.end());
- }
- return *this;
- }
-
-
-
-
-
-
-
-
-
-
-
- list& operator=(BOOST_RV_REF(list) x)
- BOOST_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value
- || allocator_traits_type::is_always_equal::value)
- {
- if (BOOST_LIKELY(this != &x)) {
-
-
- const bool can_steal_resources_alloc
- = allocator_traits_type::propagate_on_container_move_assignment::value
- || allocator_traits_type::is_always_equal::value;
- dtl::bool_<can_steal_resources_alloc> flag;
- this->priv_move_assign(boost::move(x), flag);
- }
- return *this;
- }
- #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
-
-
-
-
-
-
-
-
- inline list& operator=(std::initializer_list<value_type> il)
- {
- this->assign(il.begin(), il.end());
- return *this;
- }
- #endif
-
-
-
-
-
- inline void assign(size_type n, const T& val)
- {
- typedef constant_iterator<value_type> cvalue_iterator;
- return this->assign(cvalue_iterator(val, n), cvalue_iterator());
- }
-
-
-
-
-
-
- template <class InpIt>
- void assign(InpIt first, InpIt last
- #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- , typename dtl::disable_if_convertible<InpIt, size_type>::type * = 0
- #endif
- )
- {
- iterator first1 = this->begin();
- const iterator last1 = this->end();
- for ( ; first1 != last1 && first != last; ++first1, ++first)
- *first1 = *first;
- if (first == last)
- this->erase(first1, last1);
- else{
- this->insert(last1, first, last);
- }
- }
- #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
-
-
-
-
-
-
- inline void assign(std::initializer_list<value_type> il)
- { this->assign(il.begin(), il.end()); }
- #endif
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- allocator_type get_allocator() const BOOST_NOEXCEPT_OR_NOTHROW
- { return allocator_type(this->node_alloc()); }
-
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW
- { return this->node_alloc(); }
-
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW
- { return this->node_alloc(); }
-
-
-
-
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- iterator begin() BOOST_NOEXCEPT_OR_NOTHROW
- { return iterator(this->icont().begin()); }
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW
- { return this->cbegin(); }
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- iterator end() BOOST_NOEXCEPT_OR_NOTHROW
- { return iterator(this->icont().end()); }
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW
- { return this->cend(); }
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW
- { return reverse_iterator(end()); }
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW
- { return this->crbegin(); }
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW
- { return reverse_iterator(begin()); }
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW
- { return this->crend(); }
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW
- { return const_iterator(this->non_const_icont().begin()); }
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW
- { return const_iterator(this->non_const_icont().end()); }
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW
- { return const_reverse_iterator(this->cend()); }
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW
- { return const_reverse_iterator(this->cbegin()); }
-
-
-
-
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- bool empty() const BOOST_NOEXCEPT_OR_NOTHROW
- { return !this->size(); }
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- size_type size() const BOOST_NOEXCEPT_OR_NOTHROW
- { return this->icont().size(); }
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW
- { return AllocHolder::max_size(); }
-
-
-
-
-
-
- void resize(size_type new_size)
- {
- if(!priv_try_shrink(new_size)){
- typedef value_init_construct_iterator<value_type> value_init_iterator;
- this->insert(this->cend(), value_init_iterator(new_size - this->size()), value_init_iterator());
- }
- }
-
-
-
-
-
-
- void resize(size_type new_size, const T& x)
- {
- if(!priv_try_shrink(new_size)){
- this->insert(this->cend(), new_size - this->size(), x);
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- reference front() BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(!this->empty());
- return *this->begin();
- }
-
-
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- const_reference front() const BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(!this->empty());
- return *this->begin();
- }
-
-
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- reference back() BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(!this->empty());
- return *(--this->end());
- }
-
-
-
-
-
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- const_reference back() const BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(!this->empty());
- return *(--this->end());
- }
-
-
-
-
-
- #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
-
-
-
-
-
-
-
-
- template <class... Args>
- reference emplace_back(BOOST_FWD_REF(Args)... args)
- { return *this->emplace(this->cend(), boost::forward<Args>(args)...); }
-
-
-
-
-
-
-
-
-
- template <class... Args>
- reference emplace_front(BOOST_FWD_REF(Args)... args)
- { return *this->emplace(this->cbegin(), boost::forward<Args>(args)...); }
-
-
-
-
-
-
-
- template <class... Args>
- iterator emplace(const_iterator position, BOOST_FWD_REF(Args)... args)
- {
- BOOST_ASSERT((priv_is_linked)(position));
- NodePtr pnode(AllocHolder::create_node(boost::forward<Args>(args)...));
- return iterator(this->icont().insert(position.get(), *pnode));
- }
- #else
- #define BOOST_CONTAINER_LIST_EMPLACE_CODE(N) \
- BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
- reference emplace_back(BOOST_MOVE_UREF##N)\
- { return *this->emplace(this->cend() BOOST_MOVE_I##N BOOST_MOVE_FWD##N); }\
- \
- BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
- reference emplace_front(BOOST_MOVE_UREF##N)\
- { return *this->emplace(this->cbegin() BOOST_MOVE_I##N BOOST_MOVE_FWD##N);}\
- \
- BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
- iterator emplace(const_iterator position BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
- {\
- BOOST_ASSERT(position == this->cend() || (--(++position) == position) );\
- NodePtr pnode (AllocHolder::create_node(BOOST_MOVE_FWD##N));\
- return iterator(this->icont().insert(position.get(), *pnode));\
- }\
-
- BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_LIST_EMPLACE_CODE)
- #undef BOOST_CONTAINER_LIST_EMPLACE_CODE
- #endif
- #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
-
-
-
-
-
- void push_front(const T &x);
-
-
-
-
-
-
- void push_front(T &&x);
- #else
- BOOST_MOVE_CONVERSION_AWARE_CATCH(push_front, T, void, priv_push_front)
- #endif
- #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
-
-
-
-
-
- void push_back(const T &x);
-
-
-
-
-
-
- void push_back(T &&x);
- #else
- BOOST_MOVE_CONVERSION_AWARE_CATCH(push_back, T, void, priv_push_back)
- #endif
- #if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
-
-
-
-
-
-
-
-
- iterator insert(const_iterator p, const T &x);
-
-
-
-
-
-
-
-
-
- iterator insert(const_iterator p, T &&x);
- #else
- BOOST_MOVE_CONVERSION_AWARE_CATCH_1ARG(insert, T, iterator, priv_insert, const_iterator, const_iterator)
- #endif
-
-
-
-
-
-
-
-
-
- iterator insert(const_iterator position, size_type n, const T& x)
- {
-
- typedef constant_iterator<value_type> cvalue_iterator;
- return this->insert(position, cvalue_iterator(x, n), cvalue_iterator());
- }
-
-
-
-
-
-
-
-
-
-
- template <class InpIt>
- iterator insert(const_iterator p, InpIt first, InpIt last
- #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- , typename dtl::enable_if_c
- < !dtl::is_convertible<InpIt, size_type>::value
- && (dtl::is_input_iterator<InpIt>::value
- || dtl::is_same<alloc_version, version_1>::value
- )
- >::type * = 0
- #endif
- )
- {
- BOOST_ASSERT((priv_is_linked)(p));
- const typename Icont::iterator ipos(p.get());
- iterator ret_it(ipos);
- if(first != last){
- ret_it = iterator(this->icont().insert(ipos, *this->create_node_from_it(first)));
- ++first;
- }
- for (; first != last; ++first){
- this->icont().insert(ipos, *this->create_node_from_it(first));
- }
- return ret_it;
- }
- #if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
- template <class FwdIt>
- iterator insert(const_iterator position, FwdIt first, FwdIt last
- , typename dtl::enable_if_c
- < !dtl::is_convertible<FwdIt, size_type>::value
- && !(dtl::is_input_iterator<FwdIt>::value
- || dtl::is_same<alloc_version, version_1>::value
- )
- >::type * = 0
- )
- {
- BOOST_ASSERT((priv_is_linked)(position));
-
- insertion_functor func(this->icont(), position.get());
- iterator before_p(position.get());
- --before_p;
- this->allocate_many_and_construct(first, boost::container::iterator_udistance(first, last), func);
- return ++before_p;
- }
- #endif
- #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
-
-
-
-
-
-
-
-
-
-
- iterator insert(const_iterator p, std::initializer_list<value_type> il)
- {
-
- return insert(p, il.begin(), il.end());
- }
- #endif
-
-
-
-
-
- void pop_front() BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(!this->empty());
- this->erase(this->cbegin());
- }
-
-
-
-
-
- void pop_back() BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(!this->empty());
- const_iterator tmp = this->cend();
- this->erase(--tmp);
- }
-
-
-
-
-
-
-
- iterator erase(const_iterator p) BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(p != this->cend() && (priv_is_linked)(p));
- return iterator(this->icont().erase_and_dispose(p.get(), Destroyer(this->node_alloc())));
- }
-
-
-
-
-
-
-
- iterator erase(const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(first == last || (first != this->cend() && (priv_is_linked)(first)));
- BOOST_ASSERT(first == last || (priv_is_linked)(last));
- return iterator(AllocHolder::erase_range(first.get(), last.get(), alloc_version()));
- }
-
-
-
-
-
- void swap(list& x)
- BOOST_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_swap::value
- || allocator_traits_type::is_always_equal::value)
- {
- BOOST_ASSERT(allocator_traits_type::propagate_on_container_swap::value ||
- allocator_traits_type::is_always_equal::value ||
- this->get_stored_allocator() == x.get_stored_allocator());
- AllocHolder::swap(x);
- }
-
-
-
-
-
- void clear() BOOST_NOEXCEPT_OR_NOTHROW
- { AllocHolder::clear(alloc_version()); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator p, list& x) BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT((priv_is_linked)(p));
- BOOST_ASSERT(this != &x);
- BOOST_ASSERT(this->node_alloc() == x.node_alloc());
- this->icont().splice(p.get(), x.icont());
- }
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator p, BOOST_RV_REF(list) x) BOOST_NOEXCEPT_OR_NOTHROW
- {
-
- this->splice(p, static_cast<list&>(x));
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator p, list &x, const_iterator i) BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT((priv_is_linked)(p));
- BOOST_ASSERT(this->node_alloc() == x.node_alloc());
- this->icont().splice(p.get(), x.icont(), i.get());
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator i) BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(this != &x);
-
- this->splice(p, static_cast<list&>(x), i);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator p, list &x, const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT((priv_is_linked)(p));
- BOOST_ASSERT(first == last || (first != x.cend() && x.priv_is_linked(first)));
- BOOST_ASSERT(first == last || x.priv_is_linked(last));
- BOOST_ASSERT(this->node_alloc() == x.node_alloc());
- this->icont().splice(p.get(), x.icont(), first.get(), last.get());
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(this != &x);
-
- this->splice(p, static_cast<list&>(x), first, last);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator p, list &x, const_iterator first, const_iterator last, size_type n) BOOST_NOEXCEPT_OR_NOTHROW
- {
- BOOST_ASSERT(this->node_alloc() == x.node_alloc());
- this->icont().splice(p.get(), x.icont(), first.get(), last.get(), n);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- void splice(const_iterator p, BOOST_RV_REF(list) x, const_iterator first, const_iterator last, size_type n) BOOST_NOEXCEPT_OR_NOTHROW
- { this->splice(p, static_cast<list&>(x), first, last, n); }
-
-
-
-
-
-
-
-
- void remove(const T& value)
- { this->remove_if(equal_to_value_type(value)); }
-
-
-
-
-
-
-
-
-
- template <class Pred>
- void remove_if(Pred pred)
- {
- typedef value_to_node_compare<Node, Pred> value_to_node_compare_type;
- this->icont().remove_and_dispose_if(value_to_node_compare_type(pred), Destroyer(this->node_alloc()));
- }
-
-
-
-
-
-
-
-
-
- void unique()
- { this->unique(value_equal_t()); }
-
-
-
-
-
-
-
-
-
- template <class BinaryPredicate>
- void unique(BinaryPredicate binary_pred)
- {
- typedef value_to_node_compare<Node, BinaryPredicate> value_to_node_compare_type;
- this->icont().unique_and_dispose(value_to_node_compare_type(binary_pred), Destroyer(this->node_alloc()));
- }
-
-
-
-
-
-
-
-
-
-
-
- void merge(list &x)
- { this->merge(x, value_less_t()); }
-
-
-
-
-
-
-
-
-
-
-
- void merge(BOOST_RV_REF(list) x)
- { this->merge(static_cast<list&>(x)); }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template <class StrictWeakOrdering>
- void merge(list &x, const StrictWeakOrdering &comp)
- {
- BOOST_ASSERT(this->node_alloc() == x.node_alloc());
- typedef value_to_node_compare<Node, StrictWeakOrdering> value_to_node_compare_type;
- this->icont().merge(x.icont(), value_to_node_compare_type(comp));
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- template <class StrictWeakOrdering>
- void merge(BOOST_RV_REF(list) x, StrictWeakOrdering comp)
- { this->merge(static_cast<list&>(x), comp); }
-
-
-
-
-
-
-
-
-
- void sort()
- { this->sort(value_less_t()); }
-
-
-
-
-
-
-
-
-
- template <class StrictWeakOrdering>
- void sort(StrictWeakOrdering comp)
- {
-
- if (this->size() < 2)
- return;
- typedef value_to_node_compare<Node, StrictWeakOrdering> value_to_node_compare_type;
- this->icont().sort(value_to_node_compare_type(comp));
- }
-
-
-
-
-
-
-
- void reverse() BOOST_NOEXCEPT_OR_NOTHROW
- { this->icont().reverse(); }
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- friend bool operator==(const list& x, const list& y)
- { return x.size() == y.size() && ::boost::container::algo_equal(x.begin(), x.end(), y.begin()); }
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- friend bool operator!=(const list& x, const list& y)
- { return !(x == y); }
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- friend bool operator<(const list& x, const list& y)
- { return boost::container::algo_lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- friend bool operator>(const list& x, const list& y)
- { return y < x; }
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- friend bool operator<=(const list& x, const list& y)
- { return !(y < x); }
-
-
-
- BOOST_CONTAINER_ATTRIBUTE_NODISCARD inline
- friend bool operator>=(const list& x, const list& y)
- { return !(x < y); }
-
-
-
- inline friend void swap(list& x, list& y)
- BOOST_NOEXCEPT_IF(BOOST_NOEXCEPT(x.swap(y)))
- { x.swap(y); }
- #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
- private:
- void priv_move_assign(BOOST_RV_REF(list) x, dtl::bool_<true> )
- {
-
- this->clear();
-
- this->AllocHolder::move_assign_alloc(x);
-
- this->icont() = boost::move(x.icont());
- }
- void priv_move_assign(BOOST_RV_REF(list) x, dtl::bool_<false> )
- {
-
-
- if (this->node_alloc() == x.node_alloc()) {
- this->priv_move_assign(boost::move(x), dtl::true_());
- }
- else {
- this->assign(boost::make_move_iterator(x.begin()), boost::make_move_iterator(x.end()));
- }
- }
- static bool priv_is_linked(const_iterator const position)
- {
- const_iterator cur(position);
-
- return (--(++cur)) == position && (++(--cur)) == position;
- }
- bool priv_try_shrink(size_type new_size)
- {
- const size_type len = this->size();
- if(len > new_size){
- const const_iterator iend = this->cend();
- size_type to_erase = len - new_size;
- const_iterator ifirst;
- if(to_erase < len/2u){
- ifirst = iend;
- while(to_erase--){
- --ifirst;
- }
- }
- else{
- ifirst = this->cbegin();
- size_type to_skip = len - to_erase;
- while(to_skip--){
- ++ifirst;
- }
- }
- this->erase(ifirst, iend);
- return true;
- }
- else{
- return false;
- }
- }
- iterator priv_insert(const_iterator p, const T &x)
- {
- BOOST_ASSERT((priv_is_linked)(p));
- NodePtr tmp = AllocHolder::create_node(x);
- return iterator(this->icont().insert(p.get(), *tmp));
- }
- iterator priv_insert(const_iterator p, BOOST_RV_REF(T) x)
- {
- BOOST_ASSERT((priv_is_linked)(p));
- NodePtr tmp = AllocHolder::create_node(boost::move(x));
- return iterator(this->icont().insert(p.get(), *tmp));
- }
- template<class U>
- void priv_push_back(BOOST_FWD_REF(U) x)
- { this->icont().push_back(*this->create_node(::boost::forward<U>(x))); }
- template<class U>
- void priv_push_front(BOOST_FWD_REF(U) x)
- { this->icont().push_front(*this->create_node(::boost::forward<U>(x))); }
- class insertion_functor;
- friend class insertion_functor;
- class insertion_functor
- {
- Icont &icont_;
- typedef typename Icont::const_iterator iconst_iterator;
- const iconst_iterator pos_;
- public:
- insertion_functor(Icont &icont, typename Icont::const_iterator pos)
- : icont_(icont), pos_(pos)
- {}
- void operator()(Node &n)
- {
- this->icont_.insert(pos_, n);
- }
- };
- typedef value_less<value_type> value_less_t;
- typedef value_equal<value_type> value_equal_t;
- #endif
- };
- #ifndef BOOST_CONTAINER_NO_CXX17_CTAD
- template <typename InputIterator>
- list(InputIterator, InputIterator) ->
- list<typename iterator_traits<InputIterator>::value_type>;
- template <typename InputIterator, typename ValueAllocator>
- list(InputIterator, InputIterator, ValueAllocator const&) ->
- list<typename iterator_traits<InputIterator>::value_type, ValueAllocator>;
- #endif
- #ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
- }
- template <class T, class Allocator>
- struct has_trivial_destructor_after_move<boost::container::list<T, Allocator> >
- {
- typedef typename boost::container::list<T, Allocator>::allocator_type allocator_type;
- typedef typename ::boost::container::allocator_traits<allocator_type>::pointer pointer;
- BOOST_STATIC_CONSTEXPR bool value = ::boost::has_trivial_destructor_after_move<allocator_type>::value &&
- ::boost::has_trivial_destructor_after_move<pointer>::value;
- };
- namespace container {
- #endif
- }}
- #include <boost/container/detail/config_end.hpp>
- #endif
|