8#ifndef INCLUDED_BSLSTL_LIST
9#define INCLUDED_BSLSTL_LIST
646#include <bslscm_version.h>
688#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
689#include <initializer_list>
694#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS) \
695 && defined(BSLS_LIBRARYFEATURES_HAS_CPP20_RANGES)
696# define BSLSTL_LIST_REQUIRES_CONTAINER_COMPATIBLE_RANGE(R, T) \
697 requires ::BloombergLP::bslmf::ContainerCompatibleRange<R, T>
699# define BSLSTL_LIST_REQUIRES_CONTAINER_COMPATIBLE_RANGE(R, T)
702#if BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
708# define COMPILING_BSLSTL_LIST_H
710# undef COMPILING_BSLSTL_LIST_H
729template <
class VALUE>
738 template <
class LIST_VALUE,
class LIST_ALLOCATOR>
741 template <
class ITER_VALUE>
760#if defined(BSLS_LIBRARYFEATURES_STDCPP_LIBCSTD)
764template <
class VALUE>
766 public std::iterator<std::bidirectional_iterator_tag, VALUE> {
768template <
class VALUE>
782 template <
class LIST_VALUE,
class LIST_ALLOCATOR>
785 template <
class ITER_VALUE>
788 template <
class T1,
class T2>
837#if defined(BSLS_COMPILERFEATURES_SUPPORT_DEFAULTED_FUNCTIONS)
907template <
class T1,
class T2>
910#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
921template <
class T1,
class T2>
936template <
class VALUE>
943 bool operator()(
const VALUE&
lhs,
const VALUE&
rhs)
const;
957template <
class VALUE,
class ALLOCATOR>
959 template rebind_traits<List_Node<VALUE> >::allocator_type {
969 typedef typename AllocTraits::allocator_type NodeAlloc;
971 typedef typename AllocTraits::size_type size_type;
1006template <
class VALUE,
class ALLOCATOR>
1017template <
class VALUE,
class ALLOCATOR>
1077template <
class VALUE,
class ALLOCATOR = bsl::allocator<VALUE> >
1096 typedef BloombergLP::bslmf::MovableRefUtil MoveUtil;
1101 AllocAndSizeWrapper;
1104 typedef typename AllocTraits::allocator_type NodeAlloc;
1109 typedef typename AllocTraits::pointer NodePtr;
1132 AllocAndSizeWrapper d_alloc_and_size;
1141 NodeAlloc& allocatorImp();
1146 NodePtr allocateNode();
1152 void createSentinel();
1159 void deleteNode(NodePtr node);
1172 void freeNode(NodePtr node);
1186 void linkNodes(NodePtr prev, NodePtr next);
1201 template <
class COMPARE>
1202 NodePtr mergeImp(NodePtr node1,
1205 COMPARE comparator);
1208 template <
class t_ITERATOR,
class t_SENTINEL>
1209 void privateAppendRange(t_ITERATOR first, t_SENTINEL last);
1216 void quickSwap(
list *other);
1232 template <class COMPARE>
1233 NodePtr sortImp(NodePtr *nodePtrPtr,
1235 const COMPARE& comparator);
1241 const NodeAlloc& allocatorImp() const;
1245 NodePtr headNode() const;
1249 const typename AllocTraits::
size_type& sizeRef() const
1263 explicit
list(const ALLOCATOR& basicAllocator);
1284 const ALLOCATOR& basicAllocator);
1300 const ALLOCATOR& basicAllocator = ALLOCATOR());
1324 template <class INPUT_ITERATOR>
1326 INPUT_ITERATOR last,
1327 const ALLOCATOR& basicAllocator = ALLOCATOR(),
1330 !
is_enum<INPUT_ITERATOR>::value
1332 : d_alloc_and_size(basicAllocator,
size_type(-1))
1343 list tmp(this->allocatorImp());
1355 template <
class t_RANGE>
1359 const ALLOCATOR& basicAllocator =
1380 const typename type_identity<ALLOCATOR>::type& basicAllocator);
1401 const typename type_identity<ALLOCATOR>::type& basicAllocator);
1403#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1415 list(std::initializer_list<value_type> values,
1416 const ALLOCATOR& basicAllocator = ALLOCATOR());
1456 AllocTraits::is_always_equal::value);
1458#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1487 template <
class INPUT_ITERATOR>
1489 INPUT_ITERATOR last,
1501 for (; first != last && dstEnd != dstIt; ++first, ++dstIt) {
1505 erase(dstIt, dstEnd);
1507 for (; first != last; ++first) {
1508 emplace(dstEnd, *first);
1519#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1528 void assign(std::initializer_list<value_type> values);
1536 template <
class t_RANGE>
1631 template <class t_RANGE>
1635#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1646 template <
class... ARGS>
1650#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1661 template <
class... ARGS>
1670 template <
class t_RANGE>
1704#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
1719 template <
class... ARGS>
1747 BloombergLP::bslmf::MovableRef<value_type> value);
1778 template <
class INPUT_ITERATOR>
1780 INPUT_ITERATOR first,
1781 INPUT_ITERATOR last,
1790 if (first == last) {
1791 return dstPosition.unconst();
1797 iterator ret = insert(dstPosition, *first);
1798 for (++first; first != last; ++first) {
1799 insert(dstPosition, *first);
1805#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
1815 iterator insert(const_iterator dstPosition,
1816 std::initializer_list<value_type> values);
1824 template <
class t_RANGE>
1850 template <class COMPARE>
1851 void merge(
list& other, COMPARE comparator);
1852 template <class COMPARE>
1853 void merge(BloombergLP::
bslmf::MovableRef<
list> other, COMPARE comparator);
1861 template <class PREDICATE>
1880 template <class COMPARE>
1881 void sort(COMPARE comparator);
1892 BloombergLP::
bslmf::MovableRef<
list> src);
1908 BloombergLP::
bslmf::MovableRef<
list> src,
1928 BloombergLP::
bslmf::MovableRef<
list> src,
1939 template <class EQ_PREDICATE>
1940 void unique(EQ_PREDICATE binaryPredicate);
1959 AllocTraits::is_always_equal::value);
2026#ifdef BSLS_COMPILERFEATURES_SUPPORT_CTAD
2038 class = bsl::enable_if_t<
2039 bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>,
2040 class = bsl::enable_if_t<
2041 bsl::is_convertible_v<
2050 class INPUT_ITERATOR,
2051 class VALUE =
typename
2052 BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>
2062 class INPUT_ITERATOR,
2064 class VALUE =
typename
2065 BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
2066 class = bsl::enable_if_t<bsl::IsStdAllocator_v<ALLOCATOR>>>
2074 class INPUT_ITERATOR,
2076 class VALUE =
typename
2077 BloombergLP::bslstl::IteratorUtil::IterVal_t<INPUT_ITERATOR>,
2079 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
2081list(INPUT_ITERATOR, INPUT_ITERATOR, ALLOC *)
2092 class = bsl::enable_if_t<bsl::is_convertible_v<ALLOC *, DEFAULT_ALLOCATOR>>
2094list(std::initializer_list<VALUE>, ALLOC *)
2097#if defined(BSLS_LIBRARYFEATURES_HAS_CPP20_CONCEPTS) \
2098 && defined(BSLS_LIBRARYFEATURES_HAS_CPP20_RANGES)
2101template <ranges::input_range t_RANGE,
2118template <
class VALUE,
class ALLOCATOR>
2122#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
2132template <
class VALUE,
class ALLOCATOR>
2138#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
2143template <
class VALUE,
class ALLOCATOR>
2144BloombergLP::bslalg::SynthThreeWayUtil::Result<VALUE> operator<=>(
2160template <
class VALUE,
class ALLOCATOR>
2171template <
class VALUE,
class ALLOCATOR>
2183template <
class VALUE,
class ALLOCATOR>
2195template <
class VALUE,
class ALLOCATOR>
2205template <
class VALUE,
class ALLOCATOR,
class BDE_OTHER_TYPE>
2211template <
class VALUE,
class ALLOCATOR,
class PREDICATE>
2228template <
class VALUE,
class ALLOCATOR>
2242template <
class VALUE>
2246 return NcIter(d_node_p);
2250template <
class VALUE>
2257template <
class VALUE>
2264template <
class VALUE>
2267: d_node_p(other.d_node_p)
2272template <
class VALUE>
2276 this->d_node_p = this->d_node_p->d_next_p;
2280template <
class VALUE>
2284 this->d_node_p = this->d_node_p->d_prev_p;
2288template <
class VALUE>
2297template <
class VALUE>
2307template <
class VALUE>
2312 return this->d_node_p->d_value;
2315template <
class VALUE>
2320 return BloombergLP::bsls::Util::addressOf(this->d_node_p->d_value);
2324template <
class T1,
class T2>
2334 return lhs.d_node_p ==
rhs.d_node_p;
2337#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
2338template <
class T1,
class T2>
2357template <
class VALUE,
class ALLOCATOR>
2360 const NodeAlloc& basicAllocator,
2362: NodeAlloc(basicAllocator)
2368template <
class VALUE,
class ALLOCATOR>
2370typename List_AllocAndSizeWrapper<VALUE, ALLOCATOR>::size_type&
2377template <
class VALUE,
class ALLOCATOR>
2379const typename List_AllocAndSizeWrapper<VALUE, ALLOCATOR>::size_type&
2390template <
class VALUE,
class ALLOCATOR>
2402template <
class VALUE,
class ALLOCATOR>
2407 d_list_p->freeNode(d_node_p);
2412template <
class VALUE,
class ALLOCATOR>
2424template <
class VALUE>
2427 const VALUE&
lhs,
const VALUE&
rhs)
const
2437template <
class VALUE,
class ALLOCATOR>
2439typename list<VALUE, ALLOCATOR>::NodeAlloc&
2442 return d_alloc_and_size;
2445template <
class VALUE,
class ALLOCATOR>
2447typename list<VALUE, ALLOCATOR>::NodePtr list<VALUE, ALLOCATOR>::allocateNode()
2449 NodePtr ret = AllocTraits::allocate(allocatorImp(), 1);
2455template <
class VALUE,
class ALLOCATOR>
2457void list<VALUE, ALLOCATOR>::createSentinel()
2461 d_sentinel = allocateNode();
2462 linkNodes(d_sentinel, d_sentinel);
2466template <
class VALUE,
class ALLOCATOR>
2468void list<VALUE, ALLOCATOR>::deleteNode(NodePtr node)
2472 AllocTraits::destroy(allocatorImp(),
2473 BloombergLP::bsls::Util::addressOf(node->d_value));
2474 AllocTraits::deallocate(allocatorImp(), node, 1);
2477template <
class VALUE,
class ALLOCATOR>
2479void list<VALUE, ALLOCATOR>::destroyAll()
2482 freeNode(d_sentinel);
2483 sizeRef() = size_type(-1);
2486template <
class VALUE,
class ALLOCATOR>
2488void list<VALUE, ALLOCATOR>::freeNode(NodePtr node)
2490 AllocTraits::deallocate(allocatorImp(), node, 1);
2493template <
class VALUE,
class ALLOCATOR>
2495typename list<VALUE, ALLOCATOR>::iterator
2496list<VALUE, ALLOCATOR>::insertNode(const_iterator position, NodePtr node)
2498 NodePtr next = position.d_node_p;
2499 NodePtr prev = next->d_prev_p;
2500 linkNodes(prev, node);
2501 linkNodes(node, next);
2503 return iterator(node);
2506template <
class VALUE,
class ALLOCATOR>
2508void list<VALUE, ALLOCATOR>::linkNodes(NodePtr prev, NodePtr next)
2510 prev->d_next_p = next;
2511 next->d_prev_p = prev;
2514template <
class VALUE,
class ALLOCATOR>
2515template <
class COMPARE>
2516typename list<VALUE, ALLOCATOR>::NodePtr
2522 NodePtr pre = node1->d_prev_p;
2536 while (node1 != node2 && node2 != finish) {
2542 if (comparator(node2->d_value, node1->d_value)) {
2548 NodePtr lastMove = node2;
2549 NodePtr next2 = node2->d_next_p;
2550 while (next2 != finish && comparator(next2->d_value,
2553 next2 = lastMove->d_next_p;
2556 linkNodes(node2->d_prev_p, next2);
2557 linkNodes(node1->d_prev_p, node2);
2558 linkNodes(lastMove, node1);
2567 node1 = node1->d_next_p;
2571 return pre->d_next_p;
2574template <
class VALUE,
class ALLOCATOR>
2575template <
class t_ITERATOR,
class t_SENTINEL>
2580 for (; first != last; ++first) {
2581 emplace_back(*first);
2585template <
class VALUE,
class ALLOCATOR>
2587void list<VALUE, ALLOCATOR>::quickSwap(list *other)
2593 swap(d_sentinel, other->d_sentinel);
2594 swap(sizeRef(), other->sizeRef());
2597template <
class VALUE,
class ALLOCATOR>
2599typename list<VALUE, ALLOCATOR>::AllocTraits::size_type&
2602 return d_alloc_and_size.size();
2605template <
class VALUE,
class ALLOCATOR>
2606template <
class COMPARE>
2607typename list<VALUE, ALLOCATOR>::NodePtr
2610 const COMPARE& comparator)
2614 NodePtr node1 = *nodePtrPtr;
2616 return node1->d_next_p;
2621 NodePtr node2 = sortImp(&node1, half, comparator);
2622 NodePtr next = sortImp(&node2, size - half, comparator);
2624 *nodePtrPtr = mergeImp(node1, node2, next, comparator);
2629template <
class VALUE,
class ALLOCATOR>
2631const typename list<VALUE, ALLOCATOR>::NodeAlloc&
2634 return d_alloc_and_size;
2637template <
class VALUE,
class ALLOCATOR>
2639typename list<VALUE, ALLOCATOR>::NodePtr list<VALUE, ALLOCATOR>::headNode()
2642 return d_sentinel->d_next_p;
2645template <
class VALUE,
class ALLOCATOR>
2647const typename list<VALUE, ALLOCATOR>::AllocTraits::size_type&
2650 return d_alloc_and_size.
size();
2654template <
class VALUE,
class ALLOCATOR>
2657, d_alloc_and_size(ALLOCATOR(), 0)
2660 typename AllocTraits::size_type>::value));
2662 typename AllocTraits::difference_type>::value));
2666template <
class VALUE,
class ALLOCATOR>
2669, d_alloc_and_size(basicAllocator, 0)
2674template <
class VALUE,
class ALLOCATOR>
2677, d_alloc_and_size(ALLOCATOR(),
size_type(-1))
2681 list tmp(this->allocatorImp());
2687 for (
size_type i = 0; i < numElements; ++i) {
2694template <
class VALUE,
class ALLOCATOR>
2696 const ALLOCATOR& basicAllocator)
2698, d_alloc_and_size(basicAllocator,
size_type(-1))
2702 list tmp(this->allocatorImp());
2708 for (
size_type i = 0; i < numElements; ++i) {
2715template <
class VALUE,
class ALLOCATOR>
2718 const ALLOCATOR& basicAllocator)
2720, d_alloc_and_size(basicAllocator,
size_type(-1))
2724 list tmp(this->allocatorImp());
2730template <
class VALUE,
class ALLOCATOR>
2731template <
class t_RANGE>
2736 const ALLOCATOR& basicAllocator)
2738, d_alloc_and_size(basicAllocator,
size_type(-1))
2740 list tmp(this->allocatorImp());
2745template <
class VALUE,
class ALLOCATOR>
2749 AllocTraits::select_on_container_copy_construction(original.allocatorImp()),
2752 list tmp(this->allocatorImp());
2759template <
class VALUE,
class ALLOCATOR>
2761 const typename type_identity<ALLOCATOR>::type& basicAllocator)
2763, d_alloc_and_size(basicAllocator,
size_type(-1))
2765 list tmp(this->allocatorImp());
2772template <
class VALUE,
class ALLOCATOR>
2775, d_alloc_and_size(MoveUtil::access(original).allocatorImp(), 0)
2786 quickSwap(&MoveUtil::access(original));
2789template <
class VALUE,
class ALLOCATOR>
2791 BloombergLP::bslmf::MovableRef<list> original,
2792 const typename type_identity<ALLOCATOR>::type& basicAllocator)
2794, d_alloc_and_size(basicAllocator,
size_type(-1))
2798 list& lvalue = original;
2799 if (this->allocatorImp() == lvalue.allocatorImp()) {
2808 list tmp(this->allocatorImp());
2813 NodePtr endPtr = lvalue.d_sentinel;
2814 for (NodePtr p = lvalue.headNode(); endPtr != p; p = p->d_next_p) {
2824#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2825template <
class VALUE,
class ALLOCATOR>
2828 const ALLOCATOR& basicAllocator)
2829: d_alloc_and_size(basicAllocator, size_type(-1))
2837 list tmp(this->allocatorImp());
2838 tmp.insert(tmp.cbegin(), values.begin(), values.end());
2844template <
class VALUE,
class ALLOCATOR>
2859template <
class VALUE,
class ALLOCATOR>
2863 AllocTraits::propagate_on_container_copy_assignment Propagate;
2866 if (Propagate::value && allocatorImp() !=
rhs.allocatorImp()) {
2870 BloombergLP::bslma::AllocatorUtil::assign(&allocatorImp(),
2875 assign(
rhs.begin(),
rhs.end());
2881template <
class VALUE,
class ALLOCATOR>
2883 BloombergLP::bslmf::MovableRef<list>
rhs)
2887 AllocTraits::propagate_on_container_move_assignment Propagate;
2891 if (
this == &lvalue) {
2895 if (this->allocatorImp() == lvalue.allocatorImp()) {
2900 else if (Propagate::value) {
2914 list other(MoveUtil::move(lvalue));
2917 using BloombergLP::bslma::AllocatorUtil;
2919 AllocatorUtil::swap(
2920 &allocatorImp(), &other.allocatorImp(), Propagate());
2921 swap(d_sentinel, other.d_sentinel);
2922 swap(sizeRef(), other.sizeRef());
2930 NodePtr dstPtr = this->headNode();
2931 const const_iterator dstEnd = this->
cend();
2932 const NodePtr dstEndPtr = dstEnd.d_node_p;
2934 NodePtr srcPtr = lvalue.headNode();
2935 const NodePtr srcEndPtr = lvalue.d_sentinel;
2937 for (; srcEndPtr != srcPtr && dstEndPtr != dstPtr;
2938 srcPtr = srcPtr->d_next_p, dstPtr = dstPtr->d_next_p) {
2939 dstPtr->d_value = MoveUtil::move(srcPtr->d_value);
2942 erase(const_iterator(dstPtr), dstEnd);
2944 for (; srcEndPtr != srcPtr; srcPtr = srcPtr->d_next_p) {
2945 emplace(dstEnd, MoveUtil::move(srcPtr->d_value));
2952#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2953template <
class VALUE,
class ALLOCATOR>
2956 std::initializer_list<VALUE>
rhs)
2963template <
class VALUE,
class ALLOCATOR>
2966 NodePtr dst_p = this->headNode();
2968 const NodePtr dstEnd_p = dstEnd.d_node_p;
2970 for (; 0 < numElements && dstEnd_p != dst_p;
2971 --numElements, dst_p = dst_p->d_next_p) {
2972 dst_p->d_value = value;
2977 for (; 0 < numElements; --numElements) {
2978 insert(dstEnd, value);
2982#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
2983template <
class VALUE,
class ALLOCATOR>
2987 assign(values.begin(), values.end());
2991template <
class VALUE,
class ALLOCATOR>
2992template <
class t_RANGE>
2994void
list<VALUE, ALLOCATOR>::assign_range(
3003template <
class VALUE,
class ALLOCATOR>
3008 return iterator(headNode());
3011template <
class VALUE,
class ALLOCATOR>
3019template <
class VALUE,
class ALLOCATOR>
3027template <
class VALUE,
class ALLOCATOR>
3037template <
class VALUE,
class ALLOCATOR>
3041 const NodePtr e = d_sentinel;
3042 for (NodePtr p = d_sentinel->d_next_p; e != p; ) {
3043 NodePtr condemned = p;
3045 deleteNode(condemned);
3048 linkNodes(d_sentinel, d_sentinel);
3052template <
class VALUE,
class ALLOCATOR>
3055 if (newSize > sizeRef()) {
3059 }
while (newSize > sizeRef());
3062 NodePtr e = d_sentinel;
3063 NodePtr p = e->d_prev_p;
3064 for (
size_type d = sizeRef() - newSize; d > 0; --d) {
3065 NodePtr condemned = p;
3067 deleteNode(condemned);
3070 sizeRef() = newSize;
3074template <
class VALUE,
class ALLOCATOR>
3077 if (newSize > sizeRef()) {
3081 }
while (newSize > sizeRef());
3084 NodePtr e = d_sentinel;
3085 NodePtr p = e->d_prev_p;
3086 for (
size_type d = sizeRef() - newSize; d > 0; --d) {
3087 NodePtr condemned = p;
3089 deleteNode(condemned);
3092 sizeRef() = newSize;
3098template <
class VALUE,
class ALLOCATOR>
3105 return d_sentinel->d_prev_p->d_value;
3108template <
class VALUE,
class ALLOCATOR>
3115 return headNode()->d_value;
3120template <
class VALUE,
class ALLOCATOR>
3129template <
class VALUE,
class ALLOCATOR>
3140template <
class VALUE,
class ALLOCATOR>
3146 NodePtr condemned = position.d_node_p;
3149 linkNodes(condemned->d_prev_p, condemned->d_next_p);
3150 deleteNode(condemned);
3155template <
class VALUE,
class ALLOCATOR>
3159 NodePtr p = dstBegin.d_node_p;
3160 const NodePtr e = dstEnd. d_node_p;
3162 linkNodes(p->d_prev_p, e);
3165 for (; e != p; ++numDeleted) {
3166 NodePtr condemned = p;
3168 deleteNode(condemned);
3171 sizeRef() -= numDeleted;
3179template <
class VALUE,
class ALLOCATOR>
3180template <
class t_RANGE>
3182void
list<VALUE, ALLOCATOR>::append_range(
3185 privateAppendRange(ranges::begin(range), ranges::end(range));
3188#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
3189template <
class VALUE,
class ALLOCATOR>
3190template <
class... ARGS>
3200#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
3201template <
class VALUE,
class ALLOCATOR>
3202template <
class... ARGS>
3212template <
class VALUE,
class ALLOCATOR>
3213template <
class t_RANGE>
3215void
list<VALUE, ALLOCATOR>::prepend_range(
3221template <
class VALUE,
class ALLOCATOR>
3225 emplace(
cend(), value);
3228template <
class VALUE,
class ALLOCATOR>
3231 BloombergLP::bslmf::MovableRef<VALUE> value)
3233 emplace(
cend(), MoveUtil::move(value));
3236template <
class VALUE,
class ALLOCATOR>
3240 emplace(
cbegin(), value);
3243template <
class VALUE,
class ALLOCATOR>
3246 BloombergLP::bslmf::MovableRef<VALUE> value)
3248 emplace(
cbegin(), MoveUtil::move(value));
3253#if !BSLS_COMPILERFEATURES_SIMULATE_CPP11_FEATURES
3254template <
class VALUE,
class ALLOCATOR>
3255template <
class... ARGS>
3259 NodePtr p = allocateNode();
3261 AllocTraits::construct(allocatorImp(),
3262 BloombergLP::bsls::Util::addressOf(p->d_value),
3265 return insertNode(position, p);
3269template <
class VALUE,
class ALLOCATOR>
3273 return emplace(dstPosition, value);
3276template <
class VALUE,
class ALLOCATOR>
3280 BloombergLP::bslmf::MovableRef<VALUE> value)
3282 return emplace(dstPosition, MoveUtil::move(value));
3285template <
class VALUE,
class ALLOCATOR>
3291 if (0 == numElements) {
3292 return dstPosition.unconst();
3297 iterator ret = emplace(dstPosition, value);
3301 for (--numElements; numElements > 0; --numElements) {
3302 emplace(dstPosition, value);
3308#if defined(BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS)
3309template <
class VALUE,
class ALLOCATOR>
3312 std::initializer_list<VALUE> values)
3314 return insert(dstPosition, values.begin(), values.end());
3318template <
class VALUE,
class ALLOCATOR>
3319template <
class t_RANGE>
3321typename list<VALUE, ALLOCATOR>::iterator
3330 splice(position, tmp);
3336template <
class VALUE,
class ALLOCATOR>
3342 merge(other, DefaultLessThan());
3345template <
class VALUE,
class ALLOCATOR>
3349 list& lvalue = other;
3353 merge(lvalue, DefaultLessThan());
3356template <
class VALUE,
class ALLOCATOR>
3357template <
class COMPARE>
3360 if (&other ==
this) {
3364 BSLS_ASSERT(this->allocatorImp() == other.allocatorImp());
3366 if (other.
empty()) {
3375 NodePtr xfirst = other.d_sentinel->d_next_p;
3376 splice(
end(), other);
3382 mergeImp(d_sentinel->d_next_p, xfirst, d_sentinel, comparator);
3385template <
class VALUE,
class ALLOCATOR>
3386template <
class COMPARE>
3389 BloombergLP::bslmf::MovableRef<list> other,
3392 list& lvalue = other;
3396 merge(lvalue, comparator);
3399template <
class VALUE,
class ALLOCATOR>
3403 const size_type origSize = this->size();
3416 return origSize - this->size();
3419template <
class VALUE,
class ALLOCATOR>
3420template <
class PREDICATE>
3424 const size_type origSize = this->size();
3427 if (predicate(*i)) {
3435 return origSize - this->size();
3438template <
class VALUE,
class ALLOCATOR>
3441 NodePtr sentinel = d_sentinel;
3442 NodePtr p = sentinel;
3445 NodePtr tmp = p->d_next_p;
3446 p->d_next_p = p->d_prev_p;
3449 }
while (p != sentinel);
3452template <
class VALUE,
class ALLOCATOR>
3456 sort(DefaultLessThan());
3459template <
class VALUE,
class ALLOCATOR>
3460template <
class COMPARE>
3463 if (sizeRef() < 2) {
3466 NodePtr node1 = d_sentinel->d_next_p;
3467 sortImp(&node1, size(), comparator);
3470template <
class VALUE,
class ALLOCATOR>
3473 BSLS_ASSERT(allocatorImp() == src.allocatorImp());
3480 NodePtr pPos = dstPosition.d_node_p;
3481 NodePtr pFirst = src.headNode();
3482 NodePtr pLast = src.d_sentinel->d_prev_p;
3487 linkNodes(src.d_sentinel, src.d_sentinel);
3492 linkNodes(pPos->d_prev_p, pFirst);
3493 linkNodes(pLast, pPos);
3497template <
class VALUE,
class ALLOCATOR>
3501 BloombergLP::bslmf::MovableRef<list> src)
3503 splice(dstPosition, MoveUtil::access(src));
3506template <
class VALUE,
class ALLOCATOR>
3511 BSLS_ASSERT(allocatorImp() == src.allocatorImp());
3513 NodePtr pPos = dstPosition.d_node_p;
3514 NodePtr pSrcNode = srcNode.d_node_p;
3515 NodePtr pAfterSrcNode = pSrcNode->d_next_p;
3517 if (pPos == pSrcNode || pPos == pAfterSrcNode) {
3523 linkNodes(pSrcNode->d_prev_p, pAfterSrcNode);
3528 linkNodes(pPos->d_prev_p, pSrcNode);
3529 linkNodes(pSrcNode, pPos);
3533template <
class VALUE,
class ALLOCATOR>
3537 BloombergLP::bslmf::MovableRef<list> src,
3540 splice(dstPosition, MoveUtil::access(src), srcNode);
3543template <
class VALUE,
class ALLOCATOR>
3549 BSLS_ASSERT(allocatorImp() == src.allocatorImp());
3551 size_type n = bsl::distance(first, last);
3557 NodePtr pPos = dstPosition.d_node_p;
3558 NodePtr pFirst = first.d_node_p;
3559 NodePtr pLast = last.d_node_p;
3560 NodePtr pSrcLast = pLast->d_prev_p;
3564 linkNodes(pFirst->d_prev_p, pLast);
3569 linkNodes(pPos->d_prev_p, pFirst);
3570 linkNodes(pSrcLast, pPos);
3574template <
class VALUE,
class ALLOCATOR>
3578 BloombergLP::bslmf::MovableRef<list> src,
3582 splice(dstPosition, MoveUtil::access(src), first, last);
3585template <
class VALUE,
class ALLOCATOR>
3596 while (i != e && *i == match) {
3602template <
class VALUE,
class ALLOCATOR>
3603template <
class EQ_PREDICATE>
3614 while (i != e && binaryPredicate(*i, match)) {
3622template <
class VALUE,
class ALLOCATOR>
3629 typedef typename AllocTraits::propagate_on_container_swap Propagate;
3631 if (Propagate::value) {
3633 using BloombergLP::bslma::AllocatorUtil;
3635 AllocatorUtil::swap(
3636 &allocatorImp(), &other.allocatorImp(), Propagate());
3637 swap(d_sentinel, other.d_sentinel);
3638 swap(sizeRef(), other.sizeRef());
3641 allocatorImp() == other.allocatorImp())) {
3655 list toOtherCopy(MoveUtil::move(*
this), other.allocatorImp());
3656 list toThisCopy( MoveUtil::move(other), this->allocatorImp());
3658 toOtherCopy.quickSwap(&other);
3659 toThisCopy .quickSwap(
this);
3667template <
class VALUE,
class ALLOCATOR>
3669typename list<VALUE, ALLOCATOR>::const_iterator
3672 return const_iterator(headNode());
3675template <
class VALUE,
class ALLOCATOR>
3677typename list<VALUE, ALLOCATOR>::const_iterator
3683template <
class VALUE,
class ALLOCATOR>
3691template <
class VALUE,
class ALLOCATOR>
3699template <
class VALUE,
class ALLOCATOR>
3707template <
class VALUE,
class ALLOCATOR>
3715template <
class VALUE,
class ALLOCATOR>
3723template <
class VALUE,
class ALLOCATOR>
3733template <
class VALUE,
class ALLOCATOR>
3737 return 0 == sizeRef();
3740template <
class VALUE,
class ALLOCATOR>
3745 return AllocTraits::max_size(allocatorImp());
3748template <
class VALUE,
class ALLOCATOR>
3758template <
class VALUE,
class ALLOCATOR>
3765 return d_sentinel->d_prev_p->d_value;
3768template <
class VALUE,
class ALLOCATOR>
3775 return headNode()->d_value;
3780template <
class VALUE,
class ALLOCATOR>
3784 return allocatorImp();
3790template <
class VALUE,
class ALLOCATOR>
3792bool bsl::operator==(
const list<VALUE, ALLOCATOR>& lhs,
3793 const list<VALUE, ALLOCATOR>& rhs)
3795 return BloombergLP::bslalg::RangeCompare::equal(lhs.begin(),
3803#ifndef BSLS_COMPILERFEATURES_SUPPORT_THREE_WAY_COMPARISON
3805template <
class VALUE,
class ALLOCATOR>
3808 const list<VALUE, ALLOCATOR>& rhs)
3815#ifdef BSLALG_SYNTHTHREEWAYUTIL_AVAILABLE
3817template <
class VALUE,
class ALLOCATOR>
3819BloombergLP::bslalg::SynthThreeWayUtil::Result<VALUE> bsl::operator<=>(
3820 const list<VALUE, ALLOCATOR>& lhs,
3821 const list<VALUE, ALLOCATOR>& rhs)
3823 return bsl::lexicographical_compare_three_way(
3828 BloombergLP::bslalg::SynthThreeWayUtil::compare);
3833template <
class VALUE,
class ALLOCATOR>
3835bool bsl::operator< (
const list<VALUE, ALLOCATOR>& lhs,
3836 const list<VALUE, ALLOCATOR>& rhs)
3838 return 0 > BloombergLP::bslalg::RangeCompare::lexicographical(
lhs.begin(),
3846template <
class VALUE,
class ALLOCATOR>
3848bool bsl::operator> (
const list<VALUE, ALLOCATOR>& lhs,
3849 const list<VALUE, ALLOCATOR>& rhs)
3854template <
class VALUE,
class ALLOCATOR>
3857 const list<VALUE, ALLOCATOR>& rhs)
3862template <
class VALUE,
class ALLOCATOR>
3865 const list<VALUE, ALLOCATOR>& rhs)
3873template <
class VALUE,
class ALLOCATOR,
class BDE_OTHER_TYPE>
3875bsl::erase(list<VALUE, ALLOCATOR>& l,
const BDE_OTHER_TYPE& value)
3880 typename list<VALUE, ALLOCATOR>::size_type oldSize = l.
size();
3881 for (
typename list<VALUE, ALLOCATOR>::iterator it = l.begin();
3891 return oldSize - l.size();
3894template <
class VALUE,
class ALLOCATOR,
class PREDICATE>
3896bsl::erase_if(list<VALUE, ALLOCATOR>& l, PREDICATE predicate)
3898 return BloombergLP::bslstl::AlgorithmUtil::containerEraseIf(l, predicate);
3901template <
class VALUE,
class ALLOCATOR>
3903void bsl::swap(list<VALUE, ALLOCATOR>& a, list<VALUE, ALLOCATOR>& b)
3923template <
class VALUE,
class ALLOCATOR>
3932template <
class VALUE,
class ALLOCATOR>
3943template <
class VALUE,
class ALLOCATOR>
3945 : BloombergLP::bslmf::IsBitwiseMoveable<ALLOCATOR>
3953#undef BSLSTL_LIST_REQUIRES_CONTAINER_COMPATIBLE_RANGE
size_type size() const BSLS_KEYWORD_NOEXCEPT
Return the number of elements contained by this deque.
Definition bslstl_deque.h:2241
Definition bslstl_list.h:959
List_AllocAndSizeWrapper(const NodeAlloc &basicAllocator, size_type size)
Definition bslstl_list.h:2359
size_type & size()
Definition bslstl_list.h:2371
const size_type & size() const
Definition bslstl_list.h:2380
Definition bslstl_list.h:769
List_Iterator & operator--()
Definition bslstl_list.h:2282
List_Iterator(const List_Iterator &)
friend class list
Definition bslstl_list.h:783
VALUE * pointer
Definition bslstl_list.h:803
List_Iterator & operator++()
Definition bslstl_list.h:2274
friend class List_Iterator
Definition bslstl_list.h:786
reference operator*() const
Definition bslstl_list.h:2310
friend bool operator==(List_Iterator< T1 >, List_Iterator< T2 >)
Definition bslstl_list.h:2326
std::bidirectional_iterator_tag iterator_category
Definition bslstl_list.h:800
VALUE & reference
Definition bslstl_list.h:804
NcType value_type
Definition bslstl_list.h:801
List_Iterator & operator=(const List_Iterator &)=default
BloombergLP::bsls::Types::IntPtr difference_type
Definition bslstl_list.h:802
pointer operator->() const
Definition bslstl_list.h:2318
Definition bslstl_list.h:1018
AllocTraits::pointer NodePtr
Definition bslstl_list.h:1034
void release()
Definition bslstl_list.h:2414
~List_NodeProctor()
Definition bslstl_list.h:2404
Definition bslstl_list.h:730
Definition bslma_bslallocator.h:588
Forward declaration required by List_NodeProctor.
Definition bslstl_list.h:1078
void reverse() BSLS_KEYWORD_NOEXCEPT
Reverse the order of the elements in this list.
Definition bslstl_list.h:3439
void resize(size_type newSize)
Definition bslstl_list.h:3053
allocator_type get_allocator() const BSLS_KEYWORD_NOEXCEPT
Return a copy of the allocator used for memory allocation by this list.
Definition bslstl_list.h:3782
const VALUE & const_reference
Definition bslstl_list.h:1114
const_reverse_iterator crend() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_list.h:3710
VALUE & reference
Definition bslstl_list.h:1113
iterator insert(const_iterator dstPosition, const value_type &value)
Definition bslstl_list.h:3271
iterator insert_range(const_iterator position, BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range)
void merge(list &other)
Definition bslstl_list.h:3338
reference back()
Definition bslstl_list.h:3101
const_iterator cend() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_list.h:3694
const_reverse_iterator crbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_list.h:3702
list()
Definition bslstl_list.h:2655
void sort()
Definition bslstl_list.h:3454
allocator_traits< ALLOCATOR >::size_type size_type
Definition bslstl_list.h:1121
List_Iterator< VALUE > iterator
Definition bslstl_list.h:1115
bsl::reverse_iterator< const_iterator > const_reverse_iterator
Definition bslstl_list.h:1127
size_type remove_if(PREDICATE predicate)
void unique()
Definition bslstl_list.h:3586
void swap(list &other) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocTraits const_iterator begin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_list.h:1965
size_type remove(const value_type &value)
Definition bslstl_list.h:3401
void append_range(BSLS_COMPILERFEATURES_FORWARD_REF(t_RANGE) range)
Definition bslstl_list.h:3182
void pop_front()
Definition bslstl_list.h:3131
size_type max_size() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_list.h:3743
allocator_traits< ALLOCATOR >::pointer pointer
Definition bslstl_list.h:1117
void push_back(const value_type &value)
Definition bslstl_list.h:3223
iterator insert(const_iterator dstPosition, BloombergLP::bslmf::MovableRef< value_type > value)
Definition bslstl_list.h:3278
iterator insert(const_iterator dstPosition, size_type numElements, const value_type &value)
Definition bslstl_list.h:3287
VALUE value_type
Definition bslstl_list.h:1124
void pop_back()
Definition bslstl_list.h:3122
allocator_traits< ALLOCATOR >::difference_type difference_type
Definition bslstl_list.h:1123
List_Iterator< const VALUE > const_iterator
Definition bslstl_list.h:1116
allocator_traits< ALLOCATOR >::const_pointer const_pointer
Definition bslstl_list.h:1119
list & operator=(const list &rhs)
Definition bslstl_list.h:2860
void push_front(const value_type &value)
Definition bslstl_list.h:3238
iterator insert(const_iterator dstPosition, INPUT_ITERATOR first, INPUT_ITERATOR last, typename enable_if< !is_arithmetic< INPUT_ITERATOR >::value &&!is_enum< INPUT_ITERATOR >::value >::type *=0)
Definition bslstl_list.h:1779
iterator emplace(const_iterator position, ARGS &&... arguments)
reference emplace_front(ARGS &&... arguments)
reverse_iterator rend() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_list.h:3030
void splice(const_iterator dstPosition, list &src)
Definition bslstl_list.h:3471
reference emplace_back(ARGS &&... arguments)
~list()
Definition bslstl_list.h:2845
reference front()
Definition bslstl_list.h:3111
ALLOCATOR allocator_type
Definition bslstl_list.h:1125
size_type size() const BSLS_KEYWORD_NOEXCEPT
Return the number of elements in this list.
Definition bslstl_list.h:3750
reverse_iterator rbegin() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_list.h:3022
list &operator=(BloombergLP::bslmf::MovableRef< list > rhs) BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(AllocTraits void assign(INPUT_ITERATOR first, INPUT_ITERATOR last, typename enable_if< !is_arithmetic< INPUT_ITERATOR >::value &&!is_enum< INPUT_ITERATOR >::value >::type *=0)
Definition bslstl_list.h:1488
iterator erase(const_iterator position)
Definition bslstl_list.h:3142
iterator end() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_list.h:3013
bool empty() const BSLS_KEYWORD_NOEXCEPT
Return true if this list has no elements, and false otherwise.
Definition bslstl_list.h:3735
void clear() BSLS_KEYWORD_NOEXCEPT
Remove all the elements from this list.
Definition bslstl_list.h:3039
const_iterator cbegin() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_list.h:3686
bsl::reverse_iterator< iterator > reverse_iterator
Definition bslstl_list.h:1126
void assign(size_type numElements, const value_type &value)
Definition bslstl_list.h:2964
#define BSLMF_ASSERT(expr)
Definition bslmf_assert.h:231
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1976
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1917
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2343
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2349
#define BSLS_IDENT(str)
BSLS_IDENT() - insert string into .comment binary segment (if supported)
Definition bsls_ident.h:238
#define BSLS_KEYWORD_NOEXCEPT_OPERATOR(...)
Definition bsls_keyword.h:677
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:674
#define BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(...)
Definition bsls_keyword.h:676
#define BSLSTL_LIST_REQUIRES_CONTAINER_COMPATIBLE_RANGE(R, T)
Definition bslstl_list.h:699
void swap(OptionValue &a, OptionValue &b)
int assign(LHS_TYPE *lhs, const RHS_TYPE &rhs)
Definition bdlat_valuetypefunctions.h:939
T::reverse_iterator rend(T &container)
Definition bslstl_iterator.h:1723
void swap(array< VALUE_TYPE, SIZE > &lhs, array< VALUE_TYPE, SIZE > &rhs)
T::const_iterator cend(const T &container)
Definition bslstl_iterator.h:1709
T::reverse_iterator rbegin(T &container)
Definition bslstl_iterator.h:1665
bool operator>=(const array< VALUE_TYPE, SIZE > &lhs, const array< VALUE_TYPE, SIZE > &rhs)
bool operator<=(const array< VALUE_TYPE, SIZE > &lhs, const array< VALUE_TYPE, SIZE > &rhs)
ALLOCATOR const STRING_VIEW_LIKE_TYPE & rhs
Definition bslstl_string.h:3918
deque< VALUE_TYPE, ALLOCATOR >::size_type erase(deque< VALUE_TYPE, ALLOCATOR > &deq, const BDE_OTHER_TYPE &value)
Definition bslstl_deque.h:4424
T::iterator begin(T &container)
Definition bslstl_iterator.h:1593
const from_range_t from_range
T::const_iterator cbegin(const T &container)
Definition bslstl_iterator.h:1651
ALLOCATOR & lhs
Definition bslstl_string.h:3917
T::iterator end(T &container)
Definition bslstl_iterator.h:1621
deque< VALUE_TYPE, ALLOCATOR >::size_type erase_if(deque< VALUE_TYPE, ALLOCATOR > &deq, PREDICATE predicate)
Definition bslstl_deque.h:4433
bool operator!=(const memory_resource &a, const memory_resource &b)
Definition bdlc_flathashmap.h:2218
Definition baljsn_encoder_testtypes.h:76
Definition bdlbb_blob.h:579
Definition bslstl_list.h:937
bool operator()(const VALUE &lhs, const VALUE &rhs) const
Definition bslstl_list.h:2426
Definition bslma_allocatortraits.h:1089
BloombergLP::bslma::AllocatorTraits_ConstPointerType< ALLOCATOR_TYPE >::type const_pointer
Definition bslma_allocatortraits.h:1183
BloombergLP::bslma::AllocatorTraits_SizeType< ALLOCATOR_TYPE >::type size_type
Definition bslma_allocatortraits.h:1196
BloombergLP::bslma::AllocatorTraits_PointerType< ALLOCATOR_TYPE >::type pointer
Definition bslma_allocatortraits.h:1180
BloombergLP::bslma::AllocatorTraits_DifferenceType< ALLOCATOR_TYPE >::type difference_type
Definition bslma_allocatortraits.h:1193
Definition bslmf_enableif.h:530
Definition bslstl_ranges.h:301
Definition bslmf_isarithmetic.h:124
Definition bslmf_isconvertible.h:875
Definition bslmf_isenum.h:272
Definition bslmf_issame.h:146
remove_const< typenameremove_volatile< t_TYPE >::type >::type type
Definition bslmf_removecv.h:128
Definition bslalg_hasstliterators.h:99
Definition bslma_usesbslmaallocator.h:344
Definition bslmf_isbitwisemoveable.h:718