Init
This commit is contained in:
3305
cppdraft/container/adaptors.md
Normal file
3305
cppdraft/container/adaptors.md
Normal file
File diff suppressed because one or more lines are too long
48
cppdraft/container/adaptors/format.md
Normal file
48
cppdraft/container/adaptors/format.md
Normal file
@@ -0,0 +1,48 @@
|
||||
[container.adaptors.format]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.6 Container adaptors [[container.adaptors]](container.adaptors#format)
|
||||
|
||||
### 23.6.13 Container adaptors formatting [container.adaptors.format]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20100)
|
||||
|
||||
For each ofqueue,priority_queue, andstack,
|
||||
the library provides the following formatter specialization
|
||||
where *adaptor-type* is the name of the template:
|
||||
|
||||
[ð](#lib:formatter)
|
||||
|
||||
namespace std {template<class charT, class T, [formattable](format.formattable#concept:formattable "28.5.6.3 Concept formattable [format.formattable]")<charT> Container, class... U>struct formatter<*adaptor-type*<T, Container, U...>, charT> {private:using *maybe-const-container* = // *exposition only**fmt-maybe-const*<Container, charT>; using *maybe-const-adaptor* = // *exposition only**maybe-const*<is_const_v<*maybe-const-container*>, // see [[ranges.syn]](ranges.syn "25.2 Header <ranges> synopsis")*adaptor-type*<T, Container, U...>>;
|
||||
formatter<ranges::ref_view<*maybe-const-container*>, charT> *underlying_*; // *exposition only*public:template<class ParseContext>constexpr typename ParseContext::iterator
|
||||
parse(ParseContext& ctx); template<class FormatContext>typename FormatContext::iterator
|
||||
format(*maybe-const-adaptor*& r, FormatContext& ctx) const; };}
|
||||
|
||||
[ð](#lib:parse,formatter)
|
||||
|
||||
`template<class ParseContext>
|
||||
constexpr typename ParseContext::iterator
|
||||
parse(ParseContext& ctx);
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20140)
|
||||
|
||||
*Effects*: Equivalent to: return *underlying_*.parse(ctx);
|
||||
|
||||
[ð](#lib:format,formatter)
|
||||
|
||||
`template<class FormatContext>
|
||||
typename FormatContext::iterator
|
||||
format(maybe-const-adaptor& r, FormatContext& ctx) const;
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L20153)
|
||||
|
||||
*Effects*: Equivalent to: return *underlying_*.format(r.c, ctx);
|
||||
125
cppdraft/container/adaptors/general.md
Normal file
125
cppdraft/container/adaptors/general.md
Normal file
@@ -0,0 +1,125 @@
|
||||
[container.adaptors.general]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.6 Container adaptors [[container.adaptors]](container.adaptors#general)
|
||||
|
||||
### 23.6.1 General [container.adaptors.general]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L15483)
|
||||
|
||||
The headers[<queue>](queue.syn#header:%3cqueue%3e "23.6.2 Header <queue> synopsis [queue.syn]"),[<stack>](stack.syn#header:%3cstack%3e "23.6.5 Header <stack> synopsis [stack.syn]"),[<flat_map>](flat.map.syn#header:%3cflat_map%3e "23.6.7 Header <flat_map> synopsis [flat.map.syn]"),
|
||||
and [<flat_set>](flat.set.syn#header:%3cflat_set%3e "23.6.10 Header <flat_set> synopsis [flat.set.syn]") define the container adaptorsqueue and priority_queue,stack,flat_map and flat_multimap,
|
||||
and flat_set and flat_multiset,
|
||||
respectively[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L15496)
|
||||
|
||||
Each container adaptor takes
|
||||
one or more template parameters
|
||||
named Container, KeyContainer, or MappedContainer that denote the types of containers that the container adaptor adapts[.](#2.sentence-1)
|
||||
|
||||
Each container adaptor has at least one constructor
|
||||
that takes a reference argument to one or more such template parameters[.](#2.sentence-2)
|
||||
|
||||
For each constructor reference argument to a container C,
|
||||
the constructor copies the container into the container adaptor[.](#2.sentence-3)
|
||||
|
||||
If C takes an allocator, then a compatible allocator may be passed in
|
||||
to the adaptor's constructor[.](#2.sentence-4)
|
||||
|
||||
Otherwise, normal copy or move construction is used for the container
|
||||
argument[.](#2.sentence-5)
|
||||
|
||||
For the container adaptors
|
||||
that take a single container template parameter Container,
|
||||
the first template parameter T of the container adaptor
|
||||
shall denote the same type as Container::value_type[.](#2.sentence-6)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L15513)
|
||||
|
||||
For container adaptors, no swap function throws an exception unless that
|
||||
exception is thrown by the swap of the adaptor'sContainer,KeyContainer,MappedContainer, orCompare object (if any)[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L15521)
|
||||
|
||||
A constructor template of a container adaptor
|
||||
shall not participate in overload resolution
|
||||
if it has an InputIterator template parameter and
|
||||
a type that does not qualify as an input iterator is deduced for that parameter[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L15527)
|
||||
|
||||
For container adaptors that have them,
|
||||
the insert, emplace, and erase members
|
||||
affect the validity of iterators, references, and pointers
|
||||
to the adaptor's container(s) in the same way that
|
||||
the containers' respectiveinsert, emplace, and erase members do[.](#5.sentence-1)
|
||||
|
||||
[*Example [1](#example-1)*:
|
||||
|
||||
A call to flat_map<Key, T>::insert can invalidate all iterators to the flat_map[.](#5.sentence-2)
|
||||
|
||||
â *end example*]
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L15539)
|
||||
|
||||
A deduction guide for a container adaptor shall not participate in overload resolution if any of the following are true:
|
||||
|
||||
- [(6.1)](#6.1)
|
||||
|
||||
It has an InputIterator template parameter and a type that does not qualify as an input iterator is deduced for that parameter[.](#6.1.sentence-1)
|
||||
|
||||
- [(6.2)](#6.2)
|
||||
|
||||
It has a Compare template parameter and a type that qualifies as an allocator is deduced for that parameter[.](#6.2.sentence-1)
|
||||
|
||||
- [(6.3)](#6.3)
|
||||
|
||||
It has a Container, KeyContainer, or MappedContainer template parameter and a type that qualifies as an allocator is deduced for that parameter[.](#6.3.sentence-1)
|
||||
|
||||
- [(6.4)](#6.4)
|
||||
|
||||
It has no Container, KeyContainer, or MappedContainer template parameter, and it has an Allocator template parameter, and a type that does not qualify as an allocator is deduced for that parameter[.](#6.4.sentence-1)
|
||||
|
||||
- [(6.5)](#6.5)
|
||||
|
||||
It has both Container and Allocator template parameters, and uses_allocator_v<Container, Allocator> is false[.](#6.5.sentence-1)
|
||||
|
||||
- [(6.6)](#6.6)
|
||||
|
||||
It has both KeyContainer and Allocator template parameters, anduses_allocator_v<KeyContainer, Allocator> is false[.](#6.6.sentence-1)
|
||||
|
||||
- [(6.7)](#6.7)
|
||||
|
||||
It has both KeyContainer and Compare template parameters, andis_invocable_v<const Compare&, const typename KeyContainer::value_type&, const typename KeyContainer::value_type&> is not a valid expression or is false[.](#6.7.sentence-1)
|
||||
|
||||
- [(6.8)](#6.8)
|
||||
|
||||
It has both MappedContainer and Allocator template parameters, anduses_allocator_v<MappedContainer, Allocator> is false[.](#6.8.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L15560)
|
||||
|
||||
The exposition-only alias template *iter-value-type* defined in [[sequences.general]](sequences.general "23.3.1 General") and
|
||||
the exposition-only alias templates *iter-key-type*, *iter-mapped-type*,*range-key-type*, and *range-mapped-type* defined in [[associative.general]](associative.general "23.4.1 General") may appear in deduction guides for container adaptors[.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L15568)
|
||||
|
||||
The following exposition-only alias template
|
||||
may appear in deduction guides for container adaptors:template<class Allocator, class T>using *alloc-rebind* = // *exposition only*typename allocator_traits<Allocator>::template rebind_alloc<T>;
|
||||
346
cppdraft/container/alloc/reqmts.md
Normal file
346
cppdraft/container/alloc/reqmts.md
Normal file
@@ -0,0 +1,346 @@
|
||||
[container.alloc.reqmts]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.2 Requirements [[container.requirements]](container.requirements#container.alloc.reqmts)
|
||||
|
||||
### 23.2.2 General containers [[container.requirements.general]](container.requirements.general#container.alloc.reqmts)
|
||||
|
||||
#### 23.2.2.5 Allocator-aware containers [container.alloc.reqmts]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L957)
|
||||
|
||||
Except for array and inplace_vector,
|
||||
all of the containers defined in [[containers]](containers "23 Containers library"),[[stacktrace.basic]](stacktrace.basic "19.6.4 Class template basic_stacktrace"), [[basic.string]](basic.string "27.4.3 Class template basic_string"), and [[re.results]](re.results "28.6.9 Class template match_results") meet the additional requirements of an [*allocator-aware container*](#def:container,allocator-aware "23.2.2.5 Allocator-aware containers [container.alloc.reqmts]"),
|
||||
as described below[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L964)
|
||||
|
||||
Given an allocator type A and given a container type X having a value_type identical to T and an allocator_type identical to allocator_traits<A>::rebind_alloc<T> and given an lvalue m of type A,
|
||||
a pointer p of type T*,
|
||||
an expression v that denotes
|
||||
an lvalue of type T or const T or
|
||||
an rvalue of type const T,
|
||||
and an rvalue rv of type T,
|
||||
the following terms are defined[.](#2.sentence-1)
|
||||
|
||||
If X is not allocator-aware or is a specialization of basic_string,
|
||||
the terms below are defined as if A wereallocator<T> â no allocator object needs to be created
|
||||
and user specializations of allocator<T> are not instantiated:
|
||||
|
||||
- [(2.1)](#2.1)
|
||||
|
||||
T is [**Cpp17DefaultInsertable* into X*](#def:Cpp17DefaultInsertable_into_X "23.2.2.5 Allocator-aware containers [container.alloc.reqmts]") means that the following expression is well-formed:allocator_traits<A>::construct(m, p)
|
||||
|
||||
- [(2.2)](#2.2)
|
||||
|
||||
An element of X is [*default-inserted*](#def:default-inserted "23.2.2.5 Allocator-aware containers [container.alloc.reqmts]") if it is initialized
|
||||
by evaluation of the expressionallocator_traits<A>::construct(m, p) where p is the address of the uninitialized storage for the element
|
||||
allocated within X.
|
||||
|
||||
- [(2.3)](#2.3)
|
||||
|
||||
T is [**Cpp17MoveInsertable* into X*](#def:Cpp17MoveInsertable_into_X "23.2.2.5 Allocator-aware containers [container.alloc.reqmts]") means that the following expression
|
||||
is well-formed:allocator_traits<A>::construct(m, p, rv) and its evaluation causes the following postcondition to hold: The value
|
||||
of *p is equivalent to the value of rv before the evaluation. [*Note [1](#note-1)*:
|
||||
rv remains a valid object[.](#2.3.sentence-2)
|
||||
Its state is unspecified[.](#2.3.sentence-3)
|
||||
â *end note*]
|
||||
|
||||
- [(2.4)](#2.4)
|
||||
|
||||
T is [**Cpp17CopyInsertable* into X*](#def:Cpp17CopyInsertable_into_X "23.2.2.5 Allocator-aware containers [container.alloc.reqmts]") means that, in addition to T being *Cpp17MoveInsertable* intoX, the following expression is well-formed:allocator_traits<A>::construct(m, p, v) and its evaluation causes the following postcondition to hold:
|
||||
The value of v is unchanged and is equivalent to *p.
|
||||
|
||||
- [(2.5)](#2.5)
|
||||
|
||||
T is[**Cpp17EmplaceConstructible* into X from args*](#def:Cpp17EmplaceConstructible_into_X_from_args "23.2.2.5 Allocator-aware containers [container.alloc.reqmts]"),
|
||||
for zero
|
||||
or more arguments args, means that the following expression is well-formed:allocator_traits<A>::construct(m, p, args)
|
||||
|
||||
- [(2.6)](#2.6)
|
||||
|
||||
T is[**Cpp17Erasable* from X*](#def:Cpp17Erasable_from_X "23.2.2.5 Allocator-aware containers [container.alloc.reqmts]") means that the following expression is well-formed:allocator_traits<A>::destroy(m, p)
|
||||
|
||||
[*Note [2](#note-2)*:
|
||||
|
||||
A container calls allocator_traits<A>::construct(m, p, args) to construct an element at p using args,
|
||||
with m == get_allocator()[.](#2.sentence-3)
|
||||
|
||||
The default construct in allocator will
|
||||
call ::new((void*)p) T(args),
|
||||
but specialized allocators can choose a different definition[.](#2.sentence-4)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1051)
|
||||
|
||||
In this subclause,
|
||||
|
||||
- [(3.1)](#3.1)
|
||||
|
||||
X denotes an allocator-aware container class
|
||||
with a value_type of T using an allocator of type A,
|
||||
|
||||
- [(3.2)](#3.2)
|
||||
|
||||
u denotes a variable,
|
||||
|
||||
- [(3.3)](#3.3)
|
||||
|
||||
a and b denote non-const lvalues of type X,
|
||||
|
||||
- [(3.4)](#3.4)
|
||||
|
||||
c denotes an lvalue of type const X,
|
||||
|
||||
- [(3.5)](#3.5)
|
||||
|
||||
t denotes an lvalue or a const rvalue of type X,
|
||||
|
||||
- [(3.6)](#3.6)
|
||||
|
||||
rv denotes a non-const rvalue of type X, and
|
||||
|
||||
- [(3.7)](#3.7)
|
||||
|
||||
m is a value of type A[.](#3.sentence-1)
|
||||
|
||||
A type X meets the allocator-aware container requirements
|
||||
if X meets the container requirements and
|
||||
the following types, statements, and expressions are well-formed and have
|
||||
the specified semantics[.](#3.sentence-2)
|
||||
|
||||
[ð](#lib:allocator_type,containers)
|
||||
|
||||
`typename X::allocator_type
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1100)
|
||||
|
||||
*Result*: A
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1104)
|
||||
|
||||
*Mandates*: allocator_type::value_type is the same as X::value_type[.](#5.sentence-1)
|
||||
|
||||
[ð](#lib:get_allocator,containers)
|
||||
|
||||
`c.get_allocator()
|
||||
`
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1115)
|
||||
|
||||
*Result*: A
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1119)
|
||||
|
||||
*Complexity*: Constant[.](#7.sentence-1)
|
||||
|
||||
[ð](#itemdecl:3)
|
||||
|
||||
`X u;
|
||||
X u = X();
|
||||
`
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1130)
|
||||
|
||||
*Preconditions*: A meets the *Cpp17DefaultConstructible* requirements[.](#8.sentence-1)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1134)
|
||||
|
||||
*Postconditions*: u.empty() returns true, u.get_allocator() == A()[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1138)
|
||||
|
||||
*Complexity*: Constant[.](#10.sentence-1)
|
||||
|
||||
[ð](#itemdecl:4)
|
||||
|
||||
`X u(m);
|
||||
`
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1148)
|
||||
|
||||
*Postconditions*: u.empty() returns true, u.get_allocator() == m[.](#11.sentence-1)
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1152)
|
||||
|
||||
*Complexity*: Constant[.](#12.sentence-1)
|
||||
|
||||
[ð](#itemdecl:5)
|
||||
|
||||
`X u(t, m);
|
||||
`
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1162)
|
||||
|
||||
*Preconditions*: T is *Cpp17CopyInsertable* into X[.](#13.sentence-1)
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1166)
|
||||
|
||||
*Postconditions*: u == t, u.get_allocator() == m[.](#14.sentence-1)
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1170)
|
||||
|
||||
*Complexity*: Linear[.](#15.sentence-1)
|
||||
|
||||
[ð](#itemdecl:6)
|
||||
|
||||
`X u(rv);
|
||||
`
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1180)
|
||||
|
||||
*Postconditions*: u has the same elements as rv had before this construction;
|
||||
the value of u.get_allocator() is the same as
|
||||
the value of rv.get_allocator() before this construction[.](#16.sentence-1)
|
||||
|
||||
[17](#17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1186)
|
||||
|
||||
*Complexity*: Constant[.](#17.sentence-1)
|
||||
|
||||
[ð](#itemdecl:7)
|
||||
|
||||
`X u(rv, m);
|
||||
`
|
||||
|
||||
[18](#18)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1196)
|
||||
|
||||
*Preconditions*: T is *Cpp17MoveInsertable* into X[.](#18.sentence-1)
|
||||
|
||||
[19](#19)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1200)
|
||||
|
||||
*Postconditions*: u has the same elements, or copies of the elements,
|
||||
that rv had before this construction,u.get_allocator() == m[.](#19.sentence-1)
|
||||
|
||||
[20](#20)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1206)
|
||||
|
||||
*Complexity*: Constant if m == rv.get_allocator(), otherwise linear[.](#20.sentence-1)
|
||||
|
||||
[ð](#itemdecl:8)
|
||||
|
||||
`a = t
|
||||
`
|
||||
|
||||
[21](#21)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1216)
|
||||
|
||||
*Result*: X&[.](#21.sentence-1)
|
||||
|
||||
[22](#22)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1220)
|
||||
|
||||
*Preconditions*: T is *Cpp17CopyInsertable* into X and*Cpp17CopyAssignable*[.](#22.sentence-1)
|
||||
|
||||
[23](#23)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1225)
|
||||
|
||||
*Postconditions*: a == t is true[.](#23.sentence-1)
|
||||
|
||||
[24](#24)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1229)
|
||||
|
||||
*Complexity*: Linear[.](#24.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,containers)
|
||||
|
||||
`a = rv
|
||||
`
|
||||
|
||||
[25](#25)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1240)
|
||||
|
||||
*Result*: X&[.](#25.sentence-1)
|
||||
|
||||
[26](#26)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1244)
|
||||
|
||||
*Preconditions*: Ifallocator_traits<allocator_type>::propagate_on_container_move_assignment::value is false,T is *Cpp17MoveInsertable* into X and*Cpp17MoveAssignable*[.](#26.sentence-1)
|
||||
|
||||
[27](#27)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1252)
|
||||
|
||||
*Effects*: All existing elements of a are either move assigned to or destroyed[.](#27.sentence-1)
|
||||
|
||||
[28](#28)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1256)
|
||||
|
||||
*Postconditions*: If a and rv do not refer to the same object,a is equal to the value that rv had before this assignment[.](#28.sentence-1)
|
||||
|
||||
[29](#29)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1261)
|
||||
|
||||
*Complexity*: Linear[.](#29.sentence-1)
|
||||
|
||||
[ð](#lib:swap,containers)
|
||||
|
||||
`a.swap(b)
|
||||
`
|
||||
|
||||
[30](#30)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1272)
|
||||
|
||||
*Result*: void
|
||||
|
||||
[31](#31)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1276)
|
||||
|
||||
*Effects*: Exchanges the contents of a and b[.](#31.sentence-1)
|
||||
|
||||
[32](#32)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1280)
|
||||
|
||||
*Complexity*: Constant[.](#32.sentence-1)
|
||||
30
cppdraft/container/insert/return.md
Normal file
30
cppdraft/container/insert/return.md
Normal file
@@ -0,0 +1,30 @@
|
||||
[container.insert.return]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.2 Requirements [[container.requirements]](container.requirements#container.insert.return)
|
||||
|
||||
### 23.2.6 Insert return type [container.insert.return]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2605)
|
||||
|
||||
The associative containers with unique keys and the unordered containers with unique keys
|
||||
have a member function insert that returns a nested type insert_return_type[.](#1.sentence-1)
|
||||
|
||||
That return type is a specialization of the template specified in this subclause[.](#1.sentence-2)
|
||||
|
||||
template<class Iterator, class NodeType>struct *insert-return-type*{ Iterator position; bool inserted;
|
||||
NodeType node;};
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2620)
|
||||
|
||||
The name *insert-return-type* is for exposition only[.](#2.sentence-1)
|
||||
|
||||
*insert-return-type* has the template parameters,
|
||||
data members, and special members specified above[.](#2.sentence-2)
|
||||
|
||||
It has no base classes or members other than those specified[.](#2.sentence-3)
|
||||
54
cppdraft/container/intro/reqmts.md
Normal file
54
cppdraft/container/intro/reqmts.md
Normal file
@@ -0,0 +1,54 @@
|
||||
[container.intro.reqmts]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.2 Requirements [[container.requirements]](container.requirements#container.intro.reqmts)
|
||||
|
||||
### 23.2.2 General containers [[container.requirements.general]](container.requirements.general#container.intro.reqmts)
|
||||
|
||||
#### 23.2.2.1 Introduction [container.intro.reqmts]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L77)
|
||||
|
||||
In [[container.requirements.general]](container.requirements.general "23.2.2 General containers"),
|
||||
|
||||
- [(1.1)](#1.1)
|
||||
|
||||
X denotes a container class containing objects of type T,
|
||||
|
||||
- [(1.2)](#1.2)
|
||||
|
||||
a denotes a value of type X,
|
||||
|
||||
- [(1.3)](#1.3)
|
||||
|
||||
b and c denote values of type (possibly const) X,
|
||||
|
||||
- [(1.4)](#1.4)
|
||||
|
||||
i and j denote values of type (possibly const) X::iterator,
|
||||
|
||||
- [(1.5)](#1.5)
|
||||
|
||||
u denotes an identifier,
|
||||
|
||||
- [(1.6)](#1.6)
|
||||
|
||||
v denotes an lvalue of type (possibly const) X or
|
||||
an rvalue of type const X,
|
||||
|
||||
- [(1.7)](#1.7)
|
||||
|
||||
s and t denote non-const lvalues of type X, and
|
||||
|
||||
- [(1.8)](#1.8)
|
||||
|
||||
rv denotes a non-const rvalue of type X[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L99)
|
||||
|
||||
The following exposition-only concept is used in the definition of containers:template<class R, class T>concept [*container-compatible-range*](#concept:container-compatible-range "23.2.2.1 Introduction [container.intro.reqmts]") = // *exposition only* ranges::[input_range](range.refinements#concept:input_range "25.4.6 Other range refinements [range.refinements]")<R> && [convertible_to](concept.convertible#concept:convertible_to "18.4.4 Concept convertible_to [concept.convertible]")<ranges::range_reference_t<R>, T>;
|
||||
292
cppdraft/container/node.md
Normal file
292
cppdraft/container/node.md
Normal file
@@ -0,0 +1,292 @@
|
||||
[container.node]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.2 Requirements [[container.requirements]](container.requirements#container.node)
|
||||
|
||||
### 23.2.5 Node handles [container.node]
|
||||
|
||||
#### [23.2.5.1](#overview) Overview [[container.node.overview]](container.node.overview)
|
||||
|
||||
[1](#overview-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2318)
|
||||
|
||||
A [*node handle*](#def:node_handle "23.2.5.1 Overview [container.node.overview]") is an object that accepts ownership of a single element
|
||||
from an associative container ([[associative.reqmts]](associative.reqmts "23.2.7 Associative containers")) or an unordered
|
||||
associative container ([[unord.req]](unord.req "23.2.8 Unordered associative containers"))[.](#overview-1.sentence-1)
|
||||
|
||||
It may be used to transfer that
|
||||
ownership to another container with compatible nodes[.](#overview-1.sentence-2)
|
||||
|
||||
Containers with
|
||||
compatible nodes have the same node handle type[.](#overview-1.sentence-3)
|
||||
|
||||
Elements may be transferred in
|
||||
either direction between container types in the same row of
|
||||
Table [75](#tab:container.node.compat "Table 75: Container types with compatible nodes")[.](#overview-1.sentence-4)
|
||||
|
||||
Table [75](#tab:container.node.compat) — Container types with compatible nodes [[tab:container.node.compat]](./tab:container.node.compat)
|
||||
|
||||
| [ð](#tab:container.node.compat-row-1)<br>map<K, T, C1, A> | map<K, T, C2, A> |
|
||||
| --- | --- |
|
||||
| [ð](#tab:container.node.compat-row-2)<br>map<K, T, C1, A> | multimap<K, T, C2, A> |
|
||||
| [ð](#tab:container.node.compat-row-3)<br>set<K, C1, A> | set<K, C2, A> |
|
||||
| [ð](#tab:container.node.compat-row-4)<br>set<K, C1, A> | multiset<K, C2, A> |
|
||||
| [ð](#tab:container.node.compat-row-5)<br>unordered_map<K, T, H1, E1, A> | unordered_map<K, T, H2, E2, A> |
|
||||
| [ð](#tab:container.node.compat-row-6)<br>unordered_map<K, T, H1, E1, A> | unordered_multimap<K, T, H2, E2, A> |
|
||||
| [ð](#tab:container.node.compat-row-7)<br>unordered_set<K, H1, E1, A> | unordered_set<K, H2, E2, A> |
|
||||
| [ð](#tab:container.node.compat-row-8)<br>unordered_set<K, H1, E1, A> | unordered_multiset<K, H2, E2, A> |
|
||||
|
||||
[2](#overview-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2347)
|
||||
|
||||
If a node handle is not empty, then it contains an allocator that is equal to
|
||||
the allocator of the container when the element was extracted[.](#overview-2.sentence-1)
|
||||
|
||||
If a node handle
|
||||
is empty, it contains no allocator[.](#overview-2.sentence-2)
|
||||
|
||||
[3](#overview-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2352)
|
||||
|
||||
Class *node-handle* is for exposition only[.](#overview-3.sentence-1)
|
||||
|
||||
[4](#overview-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2355)
|
||||
|
||||
If a user-defined specialization of pair exists forpair<const Key, T> or pair<Key, T>, where Key is the
|
||||
container's key_type and T is the container'smapped_type, the behavior of operations involving node handles is
|
||||
undefined[.](#overview-4.sentence-1)
|
||||
|
||||
template<*unspecified*>class *node-handle* {public:// These type declarations are described in [[associative.reqmts]](associative.reqmts "23.2.7 Associative containers") and [[unord.req]](unord.req "23.2.8 Unordered associative containers").using value_type = *see below*; // not present for map containersusing key_type = *see below*; // not present for set containersusing mapped_type = *see below*; // not present for set containersusing allocator_type = *see below*;
|
||||
|
||||
private:using container_node_type = *unspecified*; // *exposition only*using ator_traits = allocator_traits<allocator_type>; // *exposition only*typename ator_traits::template rebind_traits<container_node_type>::pointer ptr_; // *exposition only* optional<allocator_type> alloc_; // *exposition only*public:// [[container.node.cons]](#cons "23.2.5.2 Constructors, copy, and assignment"), constructors, copy, and assignmentconstexpr *node-handle*() noexcept : ptr_(), alloc_() {}constexpr *node-handle*(*node-handle*&&) noexcept; constexpr *node-handle*& operator=(*node-handle*&&); // [[container.node.dtor]](#dtor "23.2.5.3 Destructor"), destructorconstexpr ~*node-handle*(); // [[container.node.observers]](#observers "23.2.5.4 Observers"), observersconstexpr value_type& value() const; // not present for map containers key_type& key() const; // not present for set containersconstexpr mapped_type& mapped() const; // not present for set containersconstexpr allocator_type get_allocator() const; constexpr explicit operator bool() const noexcept; constexpr bool empty() const noexcept; // [[container.node.modifiers]](#modifiers "23.2.5.5 Modifiers"), modifiersconstexpr void swap(*node-handle*&)noexcept(ator_traits::propagate_on_container_swap::value || ator_traits::is_always_equal::value); friend constexpr void swap(*node-handle*& x, *node-handle*& y) noexcept(noexcept(x.swap(y))) { x.swap(y); }};
|
||||
|
||||
#### [23.2.5.2](#cons) Constructors, copy, and assignment [[container.node.cons]](container.node.cons)
|
||||
|
||||
[ð](#cons-itemdecl:1)
|
||||
|
||||
`constexpr node-handle(node-handle&& nh) noexcept;
|
||||
`
|
||||
|
||||
[1](#cons-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2416)
|
||||
|
||||
*Effects*: Constructs a *node-handle* object initializingptr_ with nh.ptr_[.](#cons-1.sentence-1)
|
||||
|
||||
Move constructs alloc_ withnh.alloc_[.](#cons-1.sentence-2)
|
||||
|
||||
Assigns nullptr to nh.ptr_ and assignsnullopt to nh.alloc_[.](#cons-1.sentence-3)
|
||||
|
||||
[ð](#cons-itemdecl:2)
|
||||
|
||||
`constexpr node-handle& operator=(node-handle&& nh);
|
||||
`
|
||||
|
||||
[2](#cons-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2429)
|
||||
|
||||
*Preconditions*: Either !alloc_, orator_traits::propagate_on_container_move_assignment::value is true, or alloc_ == nh.alloc_[.](#cons-2.sentence-1)
|
||||
|
||||
[3](#cons-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2435)
|
||||
|
||||
*Effects*:
|
||||
|
||||
- [(3.1)](#cons-3.1)
|
||||
|
||||
If ptr_ != nullptr, destroys the value_type subobject in the container_node_type object pointed to by ptr_ by calling ator_traits::destroy, then deallocates ptr_ by
|
||||
calling ator_traits::template rebind_traits<container_node_type>::deallocate[.](#cons-3.1.sentence-1)
|
||||
|
||||
- [(3.2)](#cons-3.2)
|
||||
|
||||
Assigns nh.ptr_ to ptr_[.](#cons-3.2.sentence-1)
|
||||
|
||||
- [(3.3)](#cons-3.3)
|
||||
|
||||
If !alloc_ or ator_traits::propagate_on_container_move_assignment::value is true, move assigns nh.alloc_ to alloc_[.](#cons-3.3.sentence-1)
|
||||
|
||||
- [(3.4)](#cons-3.4)
|
||||
|
||||
Assignsnullptr to nh.ptr_ and assigns nullopt tonh.alloc_[.](#cons-3.4.sentence-1)
|
||||
|
||||
[4](#cons-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2454)
|
||||
|
||||
*Returns*: *this[.](#cons-4.sentence-1)
|
||||
|
||||
[5](#cons-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2458)
|
||||
|
||||
*Throws*: Nothing[.](#cons-5.sentence-1)
|
||||
|
||||
#### [23.2.5.3](#dtor) Destructor [[container.node.dtor]](container.node.dtor)
|
||||
|
||||
[ð](#dtor-itemdecl:1)
|
||||
|
||||
`constexpr ~node-handle();
|
||||
`
|
||||
|
||||
[1](#dtor-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2470)
|
||||
|
||||
*Effects*: If ptr_ != nullptr, destroys the value_type subobject
|
||||
in the container_node_type object pointed to by ptr_ by callingator_traits::destroy, then deallocates ptr_ by callingator_traits::template rebind_traits<container_node_type>::deallocate[.](#dtor-1.sentence-1)
|
||||
|
||||
#### [23.2.5.4](#observers) Observers [[container.node.observers]](container.node.observers)
|
||||
|
||||
[ð](#observers-itemdecl:1)
|
||||
|
||||
`constexpr value_type& value() const;
|
||||
`
|
||||
|
||||
[1](#observers-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2485)
|
||||
|
||||
*Preconditions*: empty() == false[.](#observers-1.sentence-1)
|
||||
|
||||
[2](#observers-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2489)
|
||||
|
||||
*Returns*: A reference to the value_type subobject in thecontainer_node_type object pointed to by ptr_[.](#observers-2.sentence-1)
|
||||
|
||||
[3](#observers-3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2494)
|
||||
|
||||
*Throws*: Nothing[.](#observers-3.sentence-1)
|
||||
|
||||
[ð](#observers-itemdecl:2)
|
||||
|
||||
`key_type& key() const;
|
||||
`
|
||||
|
||||
[4](#observers-4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2504)
|
||||
|
||||
*Preconditions*: empty() == false[.](#observers-4.sentence-1)
|
||||
|
||||
[5](#observers-5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2508)
|
||||
|
||||
*Returns*: A non-const reference to the key_type member of thevalue_type subobject in the container_node_type object
|
||||
pointed to by ptr_[.](#observers-5.sentence-1)
|
||||
|
||||
[6](#observers-6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2514)
|
||||
|
||||
*Throws*: Nothing[.](#observers-6.sentence-1)
|
||||
|
||||
[7](#observers-7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2518)
|
||||
|
||||
*Remarks*: Modifying the key through the returned reference is permitted[.](#observers-7.sentence-1)
|
||||
|
||||
[ð](#observers-itemdecl:3)
|
||||
|
||||
`constexpr mapped_type& mapped() const;
|
||||
`
|
||||
|
||||
[8](#observers-8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2528)
|
||||
|
||||
*Preconditions*: empty() == false[.](#observers-8.sentence-1)
|
||||
|
||||
[9](#observers-9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2532)
|
||||
|
||||
*Returns*: A reference to the mapped_type member of thevalue_type subobject in the container_node_type object
|
||||
pointed to by ptr_[.](#observers-9.sentence-1)
|
||||
|
||||
[10](#observers-10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2538)
|
||||
|
||||
*Throws*: Nothing[.](#observers-10.sentence-1)
|
||||
|
||||
[ð](#observers-itemdecl:4)
|
||||
|
||||
`constexpr allocator_type get_allocator() const;
|
||||
`
|
||||
|
||||
[11](#observers-11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2548)
|
||||
|
||||
*Preconditions*: empty() == false[.](#observers-11.sentence-1)
|
||||
|
||||
[12](#observers-12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2552)
|
||||
|
||||
*Returns*: *alloc_[.](#observers-12.sentence-1)
|
||||
|
||||
[13](#observers-13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2556)
|
||||
|
||||
*Throws*: Nothing[.](#observers-13.sentence-1)
|
||||
|
||||
[ð](#observers-itemdecl:5)
|
||||
|
||||
`constexpr explicit operator bool() const noexcept;
|
||||
`
|
||||
|
||||
[14](#observers-14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2566)
|
||||
|
||||
*Returns*: ptr_ != nullptr[.](#observers-14.sentence-1)
|
||||
|
||||
[ð](#observers-itemdecl:6)
|
||||
|
||||
`constexpr bool empty() const noexcept;
|
||||
`
|
||||
|
||||
[15](#observers-15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2576)
|
||||
|
||||
*Returns*: ptr_ == nullptr[.](#observers-15.sentence-1)
|
||||
|
||||
#### [23.2.5.5](#modifiers) Modifiers [[container.node.modifiers]](container.node.modifiers)
|
||||
|
||||
[ð](#modifiers-itemdecl:1)
|
||||
|
||||
`constexpr void swap(node-handle& nh)
|
||||
noexcept(ator_traits::propagate_on_container_swap::value ||
|
||||
ator_traits::is_always_equal::value);
|
||||
`
|
||||
|
||||
[1](#modifiers-1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2590)
|
||||
|
||||
*Preconditions*: !alloc_, or !nh.alloc_, orator_traits::propagate_on_container_swap::value is true,
|
||||
or alloc_ == nh.alloc_[.](#modifiers-1.sentence-1)
|
||||
|
||||
[2](#modifiers-2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2596)
|
||||
|
||||
*Effects*: Calls swap(ptr_, nh.ptr_)[.](#modifiers-2.sentence-1)
|
||||
|
||||
If !alloc_, or!nh.alloc_, or ator_traits::propagate_on_container_swap::value is true calls swap(alloc_, nh.alloc_)[.](#modifiers-2.sentence-2)
|
||||
70
cppdraft/container/node/cons.md
Normal file
70
cppdraft/container/node/cons.md
Normal file
@@ -0,0 +1,70 @@
|
||||
[container.node.cons]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.2 Requirements [[container.requirements]](container.requirements#container.node.cons)
|
||||
|
||||
### 23.2.5 Node handles [[container.node]](container.node#cons)
|
||||
|
||||
#### 23.2.5.2 Constructors, copy, and assignment [container.node.cons]
|
||||
|
||||
[ð](#itemdecl:1)
|
||||
|
||||
`constexpr node-handle(node-handle&& nh) noexcept;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2416)
|
||||
|
||||
*Effects*: Constructs a *node-handle* object initializingptr_ with nh.ptr_[.](#1.sentence-1)
|
||||
|
||||
Move constructs alloc_ withnh.alloc_[.](#1.sentence-2)
|
||||
|
||||
Assigns nullptr to nh.ptr_ and assignsnullopt to nh.alloc_[.](#1.sentence-3)
|
||||
|
||||
[ð](#itemdecl:2)
|
||||
|
||||
`constexpr node-handle& operator=(node-handle&& nh);
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2429)
|
||||
|
||||
*Preconditions*: Either !alloc_, orator_traits::propagate_on_container_move_assignment::value is true, or alloc_ == nh.alloc_[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2435)
|
||||
|
||||
*Effects*:
|
||||
|
||||
- [(3.1)](#3.1)
|
||||
|
||||
If ptr_ != nullptr, destroys the value_type subobject in the container_node_type object pointed to by ptr_ by calling ator_traits::destroy, then deallocates ptr_ by
|
||||
calling ator_traits::template rebind_traits<container_node_type>::deallocate[.](#3.1.sentence-1)
|
||||
|
||||
- [(3.2)](#3.2)
|
||||
|
||||
Assigns nh.ptr_ to ptr_[.](#3.2.sentence-1)
|
||||
|
||||
- [(3.3)](#3.3)
|
||||
|
||||
If !alloc_ or ator_traits::propagate_on_container_move_assignment::value is true, move assigns nh.alloc_ to alloc_[.](#3.3.sentence-1)
|
||||
|
||||
- [(3.4)](#3.4)
|
||||
|
||||
Assignsnullptr to nh.ptr_ and assigns nullopt tonh.alloc_[.](#3.4.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2454)
|
||||
|
||||
*Returns*: *this[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2458)
|
||||
|
||||
*Throws*: Nothing[.](#5.sentence-1)
|
||||
21
cppdraft/container/node/dtor.md
Normal file
21
cppdraft/container/node/dtor.md
Normal file
@@ -0,0 +1,21 @@
|
||||
[container.node.dtor]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.2 Requirements [[container.requirements]](container.requirements#container.node.dtor)
|
||||
|
||||
### 23.2.5 Node handles [[container.node]](container.node#dtor)
|
||||
|
||||
#### 23.2.5.3 Destructor [container.node.dtor]
|
||||
|
||||
[ð](#itemdecl:1)
|
||||
|
||||
`constexpr ~node-handle();
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2470)
|
||||
|
||||
*Effects*: If ptr_ != nullptr, destroys the value_type subobject
|
||||
in the container_node_type object pointed to by ptr_ by callingator_traits::destroy, then deallocates ptr_ by callingator_traits::template rebind_traits<container_node_type>::deallocate[.](#1.sentence-1)
|
||||
31
cppdraft/container/node/modifiers.md
Normal file
31
cppdraft/container/node/modifiers.md
Normal file
@@ -0,0 +1,31 @@
|
||||
[container.node.modifiers]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.2 Requirements [[container.requirements]](container.requirements#container.node.modifiers)
|
||||
|
||||
### 23.2.5 Node handles [[container.node]](container.node#modifiers)
|
||||
|
||||
#### 23.2.5.5 Modifiers [container.node.modifiers]
|
||||
|
||||
[ð](#itemdecl:1)
|
||||
|
||||
`constexpr void swap(node-handle& nh)
|
||||
noexcept(ator_traits::propagate_on_container_swap::value ||
|
||||
ator_traits::is_always_equal::value);
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2590)
|
||||
|
||||
*Preconditions*: !alloc_, or !nh.alloc_, orator_traits::propagate_on_container_swap::value is true,
|
||||
or alloc_ == nh.alloc_[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2596)
|
||||
|
||||
*Effects*: Calls swap(ptr_, nh.ptr_)[.](#2.sentence-1)
|
||||
|
||||
If !alloc_, or!nh.alloc_, or ator_traits::propagate_on_container_swap::value is true calls swap(alloc_, nh.alloc_)[.](#2.sentence-2)
|
||||
131
cppdraft/container/node/observers.md
Normal file
131
cppdraft/container/node/observers.md
Normal file
@@ -0,0 +1,131 @@
|
||||
[container.node.observers]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.2 Requirements [[container.requirements]](container.requirements#container.node.observers)
|
||||
|
||||
### 23.2.5 Node handles [[container.node]](container.node#observers)
|
||||
|
||||
#### 23.2.5.4 Observers [container.node.observers]
|
||||
|
||||
[ð](#itemdecl:1)
|
||||
|
||||
`constexpr value_type& value() const;
|
||||
`
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2485)
|
||||
|
||||
*Preconditions*: empty() == false[.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2489)
|
||||
|
||||
*Returns*: A reference to the value_type subobject in thecontainer_node_type object pointed to by ptr_[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2494)
|
||||
|
||||
*Throws*: Nothing[.](#3.sentence-1)
|
||||
|
||||
[ð](#itemdecl:2)
|
||||
|
||||
`key_type& key() const;
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2504)
|
||||
|
||||
*Preconditions*: empty() == false[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2508)
|
||||
|
||||
*Returns*: A non-const reference to the key_type member of thevalue_type subobject in the container_node_type object
|
||||
pointed to by ptr_[.](#5.sentence-1)
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2514)
|
||||
|
||||
*Throws*: Nothing[.](#6.sentence-1)
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2518)
|
||||
|
||||
*Remarks*: Modifying the key through the returned reference is permitted[.](#7.sentence-1)
|
||||
|
||||
[ð](#itemdecl:3)
|
||||
|
||||
`constexpr mapped_type& mapped() const;
|
||||
`
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2528)
|
||||
|
||||
*Preconditions*: empty() == false[.](#8.sentence-1)
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2532)
|
||||
|
||||
*Returns*: A reference to the mapped_type member of thevalue_type subobject in the container_node_type object
|
||||
pointed to by ptr_[.](#9.sentence-1)
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2538)
|
||||
|
||||
*Throws*: Nothing[.](#10.sentence-1)
|
||||
|
||||
[ð](#itemdecl:4)
|
||||
|
||||
`constexpr allocator_type get_allocator() const;
|
||||
`
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2548)
|
||||
|
||||
*Preconditions*: empty() == false[.](#11.sentence-1)
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2552)
|
||||
|
||||
*Returns*: *alloc_[.](#12.sentence-1)
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2556)
|
||||
|
||||
*Throws*: Nothing[.](#13.sentence-1)
|
||||
|
||||
[ð](#itemdecl:5)
|
||||
|
||||
`constexpr explicit operator bool() const noexcept;
|
||||
`
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2566)
|
||||
|
||||
*Returns*: ptr_ != nullptr[.](#14.sentence-1)
|
||||
|
||||
[ð](#itemdecl:6)
|
||||
|
||||
`constexpr bool empty() const noexcept;
|
||||
`
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2576)
|
||||
|
||||
*Returns*: ptr_ == nullptr[.](#15.sentence-1)
|
||||
67
cppdraft/container/node/overview.md
Normal file
67
cppdraft/container/node/overview.md
Normal file
@@ -0,0 +1,67 @@
|
||||
[container.node.overview]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.2 Requirements [[container.requirements]](container.requirements#container.node.overview)
|
||||
|
||||
### 23.2.5 Node handles [[container.node]](container.node#overview)
|
||||
|
||||
#### 23.2.5.1 Overview [container.node.overview]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2318)
|
||||
|
||||
A [*node handle*](#def:node_handle "23.2.5.1 Overview [container.node.overview]") is an object that accepts ownership of a single element
|
||||
from an associative container ([[associative.reqmts]](associative.reqmts "23.2.7 Associative containers")) or an unordered
|
||||
associative container ([[unord.req]](unord.req "23.2.8 Unordered associative containers"))[.](#1.sentence-1)
|
||||
|
||||
It may be used to transfer that
|
||||
ownership to another container with compatible nodes[.](#1.sentence-2)
|
||||
|
||||
Containers with
|
||||
compatible nodes have the same node handle type[.](#1.sentence-3)
|
||||
|
||||
Elements may be transferred in
|
||||
either direction between container types in the same row of
|
||||
Table [75](#tab:container.node.compat "Table 75: Container types with compatible nodes")[.](#1.sentence-4)
|
||||
|
||||
Table [75](#tab:container.node.compat) — Container types with compatible nodes [[tab:container.node.compat]](./tab:container.node.compat)
|
||||
|
||||
| [ð](#tab:container.node.compat-row-1)<br>map<K, T, C1, A> | map<K, T, C2, A> |
|
||||
| --- | --- |
|
||||
| [ð](#tab:container.node.compat-row-2)<br>map<K, T, C1, A> | multimap<K, T, C2, A> |
|
||||
| [ð](#tab:container.node.compat-row-3)<br>set<K, C1, A> | set<K, C2, A> |
|
||||
| [ð](#tab:container.node.compat-row-4)<br>set<K, C1, A> | multiset<K, C2, A> |
|
||||
| [ð](#tab:container.node.compat-row-5)<br>unordered_map<K, T, H1, E1, A> | unordered_map<K, T, H2, E2, A> |
|
||||
| [ð](#tab:container.node.compat-row-6)<br>unordered_map<K, T, H1, E1, A> | unordered_multimap<K, T, H2, E2, A> |
|
||||
| [ð](#tab:container.node.compat-row-7)<br>unordered_set<K, H1, E1, A> | unordered_set<K, H2, E2, A> |
|
||||
| [ð](#tab:container.node.compat-row-8)<br>unordered_set<K, H1, E1, A> | unordered_multiset<K, H2, E2, A> |
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2347)
|
||||
|
||||
If a node handle is not empty, then it contains an allocator that is equal to
|
||||
the allocator of the container when the element was extracted[.](#2.sentence-1)
|
||||
|
||||
If a node handle
|
||||
is empty, it contains no allocator[.](#2.sentence-2)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2352)
|
||||
|
||||
Class *node-handle* is for exposition only[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L2355)
|
||||
|
||||
If a user-defined specialization of pair exists forpair<const Key, T> or pair<Key, T>, where Key is the
|
||||
container's key_type and T is the container'smapped_type, the behavior of operations involving node handles is
|
||||
undefined[.](#4.sentence-1)
|
||||
|
||||
template<*unspecified*>class *node-handle* {public:// These type declarations are described in [[associative.reqmts]](associative.reqmts "23.2.7 Associative containers") and [[unord.req]](unord.req "23.2.8 Unordered associative containers").using value_type = *see below*; // not present for map containersusing key_type = *see below*; // not present for set containersusing mapped_type = *see below*; // not present for set containersusing allocator_type = *see below*;
|
||||
|
||||
private:using container_node_type = *unspecified*; // *exposition only*using ator_traits = allocator_traits<allocator_type>; // *exposition only*typename ator_traits::template rebind_traits<container_node_type>::pointer ptr_; // *exposition only* optional<allocator_type> alloc_; // *exposition only*public:// [[container.node.cons]](container.node.cons "23.2.5.2 Constructors, copy, and assignment"), constructors, copy, and assignmentconstexpr *node-handle*() noexcept : ptr_(), alloc_() {}constexpr *node-handle*(*node-handle*&&) noexcept; constexpr *node-handle*& operator=(*node-handle*&&); // [[container.node.dtor]](container.node.dtor "23.2.5.3 Destructor"), destructorconstexpr ~*node-handle*(); // [[container.node.observers]](container.node.observers "23.2.5.4 Observers"), observersconstexpr value_type& value() const; // not present for map containers key_type& key() const; // not present for set containersconstexpr mapped_type& mapped() const; // not present for set containersconstexpr allocator_type get_allocator() const; constexpr explicit operator bool() const noexcept; constexpr bool empty() const noexcept; // [[container.node.modifiers]](container.node.modifiers "23.2.5.5 Modifiers"), modifiersconstexpr void swap(*node-handle*&)noexcept(ator_traits::propagate_on_container_swap::value || ator_traits::is_always_equal::value); friend constexpr void swap(*node-handle*& x, *node-handle*& y) noexcept(noexcept(x.swap(y))) { x.swap(y); }};
|
||||
62
cppdraft/container/opt/reqmts.md
Normal file
62
cppdraft/container/opt/reqmts.md
Normal file
@@ -0,0 +1,62 @@
|
||||
[container.opt.reqmts]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.2 Requirements [[container.requirements]](container.requirements#container.opt.reqmts)
|
||||
|
||||
### 23.2.2 General containers [[container.requirements.general]](container.requirements.general#container.opt.reqmts)
|
||||
|
||||
#### 23.2.2.4 Optional container requirements [container.opt.reqmts]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L896)
|
||||
|
||||
The following operations are provided
|
||||
for some types of containers but not others[.](#1.sentence-1)
|
||||
|
||||
Those containers for which the
|
||||
listed operations are provided shall implement the semantics as described
|
||||
unless otherwise stated[.](#1.sentence-2)
|
||||
|
||||
If the iterators passed to lexicographical_compare_three_way meet the constexpr iterator requirements ([[iterator.requirements.general]](iterator.requirements.general "24.3.1 General"))
|
||||
then the operations described below
|
||||
are implemented by constexpr functions[.](#1.sentence-3)
|
||||
|
||||
[ð](#lib:operator%3c=%3e,containers)
|
||||
|
||||
`a <=> b
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L931)
|
||||
|
||||
*Result*: *synth-three-way-result*<X::value_type>[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L935)
|
||||
|
||||
*Preconditions*: Either T models [three_way_comparable](cmp.concept#concept:three_way_comparable "17.12.4 Concept three_way_comparable [cmp.concept]"),
|
||||
or < is defined for values of type (possibly const) T and< is a total ordering relationship[.](#3.sentence-1)
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L941)
|
||||
|
||||
*Returns*: lexicographical_compare_three_way(a.begin(), a.end(),
|
||||
b.begin(), b.end(),
|
||||
*synth-three-way*)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
The algorithm lexicographical_compare_three_way is defined in [[algorithms]](algorithms "26 Algorithms library")[.](#4.sentence-1)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L950)
|
||||
|
||||
*Complexity*: Linear[.](#5.sentence-1)
|
||||
708
cppdraft/container/reqmts.md
Normal file
708
cppdraft/container/reqmts.md
Normal file
@@ -0,0 +1,708 @@
|
||||
[container.reqmts]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.2 Requirements [[container.requirements]](container.requirements#container.reqmts)
|
||||
|
||||
### 23.2.2 General containers [[container.requirements.general]](container.requirements.general#container.reqmts)
|
||||
|
||||
#### 23.2.2.2 Container requirements [container.reqmts]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L132)
|
||||
|
||||
A type X meets the [*container*](#def:container "23.2.2.2 Container requirements [container.reqmts]") requirements
|
||||
if the following types, statements, and expressions are well-formed and
|
||||
have the specified semantics[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:value_type,containers)
|
||||
|
||||
`typename X::value_type
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L143)
|
||||
|
||||
*Result*: T
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L147)
|
||||
|
||||
*Preconditions*: T is *Cpp17Erasable* from X (see [[container.alloc.reqmts]](container.alloc.reqmts "23.2.2.5 Allocator-aware containers"), below)[.](#3.sentence-1)
|
||||
|
||||
[ð](#lib:reference,containers)
|
||||
|
||||
`typename X::reference
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L159)
|
||||
|
||||
*Result*: T&
|
||||
|
||||
[ð](#lib:const_reference,containers)
|
||||
|
||||
`typename X::const_reference
|
||||
`
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L170)
|
||||
|
||||
*Result*: const T&
|
||||
|
||||
[ð](#lib:iterator,containers)
|
||||
|
||||
`typename X::iterator
|
||||
`
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L181)
|
||||
|
||||
*Result*: A type that meets the forward iterator requirements ([[forward.iterators]](forward.iterators "24.3.5.5 Forward iterators"))
|
||||
with value type T[.](#6.sentence-1)
|
||||
|
||||
The type X::iterator is convertible to X::const_iterator[.](#6.sentence-2)
|
||||
|
||||
[ð](#lib:const_iterator,containers)
|
||||
|
||||
`typename X::const_iterator
|
||||
`
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L194)
|
||||
|
||||
*Result*: A type that meets the requirements of a constant iterator and
|
||||
those of a forward iterator with value type T[.](#7.sentence-1)
|
||||
|
||||
[ð](#lib:difference_type,containers)
|
||||
|
||||
`typename X::difference_type
|
||||
`
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L206)
|
||||
|
||||
*Result*: A signed integer type,
|
||||
identical to the difference type ofX::iterator and X::const_iterator[.](#8.sentence-1)
|
||||
|
||||
[ð](#lib:size_type,containers)
|
||||
|
||||
`typename X::size_type
|
||||
`
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L219)
|
||||
|
||||
*Result*: An unsigned integer type
|
||||
that can represent any non-negative value of X::difference_type[.](#9.sentence-1)
|
||||
|
||||
[ð](#itemdecl:8)
|
||||
|
||||
`X u;
|
||||
X u = X();
|
||||
`
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L231)
|
||||
|
||||
*Postconditions*: u.empty()
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L235)
|
||||
|
||||
*Complexity*: Constant[.](#11.sentence-1)
|
||||
|
||||
[ð](#itemdecl:9)
|
||||
|
||||
`X u(v);
|
||||
X u = v;
|
||||
`
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L246)
|
||||
|
||||
*Preconditions*: T is *Cpp17CopyInsertable* into X (see below)[.](#12.sentence-1)
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L250)
|
||||
|
||||
*Postconditions*: u == v[.](#13.sentence-1)
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L254)
|
||||
|
||||
*Complexity*: Linear[.](#14.sentence-1)
|
||||
|
||||
[ð](#itemdecl:10)
|
||||
|
||||
`X u(rv);
|
||||
X u = rv;
|
||||
`
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L265)
|
||||
|
||||
*Postconditions*: u is equal to the value that rv had before this construction[.](#15.sentence-1)
|
||||
|
||||
[16](#16)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L269)
|
||||
|
||||
*Complexity*: Linear for array and inplace_vector and constant for all other standard containers[.](#16.sentence-1)
|
||||
|
||||
[ð](#lib:operator=,containers)
|
||||
|
||||
`t = v;
|
||||
`
|
||||
|
||||
[17](#17)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L280)
|
||||
|
||||
*Result*: X&[.](#17.sentence-1)
|
||||
|
||||
[18](#18)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L284)
|
||||
|
||||
*Postconditions*: t == v[.](#18.sentence-1)
|
||||
|
||||
[19](#19)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L288)
|
||||
|
||||
*Complexity*: Linear[.](#19.sentence-1)
|
||||
|
||||
[ð](#itemdecl:12)
|
||||
|
||||
`t = rv
|
||||
`
|
||||
|
||||
[20](#20)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L298)
|
||||
|
||||
*Result*: X&[.](#20.sentence-1)
|
||||
|
||||
[21](#21)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L302)
|
||||
|
||||
*Effects*: All existing elements of t are either move assigned to or destroyed[.](#21.sentence-1)
|
||||
|
||||
[22](#22)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L306)
|
||||
|
||||
*Postconditions*: If t and rv do not refer to the same object,t is equal to the value that rv had before this assignment[.](#22.sentence-1)
|
||||
|
||||
[23](#23)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L311)
|
||||
|
||||
*Complexity*: Linear[.](#23.sentence-1)
|
||||
|
||||
[ð](#itemdecl:13)
|
||||
|
||||
`a.~X()
|
||||
`
|
||||
|
||||
[24](#24)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L321)
|
||||
|
||||
*Result*: void[.](#24.sentence-1)
|
||||
|
||||
[25](#25)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L325)
|
||||
|
||||
*Effects*: Destroys every element of a; any memory obtained is deallocated[.](#25.sentence-1)
|
||||
|
||||
[26](#26)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L329)
|
||||
|
||||
*Complexity*: Linear[.](#26.sentence-1)
|
||||
|
||||
[ð](#lib:begin,containers)
|
||||
|
||||
`b.begin()
|
||||
`
|
||||
|
||||
[27](#27)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L340)
|
||||
|
||||
*Result*: iterator;const_iterator for constant b[.](#27.sentence-1)
|
||||
|
||||
[28](#28)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L345)
|
||||
|
||||
*Returns*: An iterator referring to the first element in the container[.](#28.sentence-1)
|
||||
|
||||
[29](#29)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L349)
|
||||
|
||||
*Complexity*: Constant[.](#29.sentence-1)
|
||||
|
||||
[ð](#lib:end,containers)
|
||||
|
||||
`b.end()
|
||||
`
|
||||
|
||||
[30](#30)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L360)
|
||||
|
||||
*Result*: iterator;const_iterator for constant b[.](#30.sentence-1)
|
||||
|
||||
[31](#31)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L365)
|
||||
|
||||
*Returns*: An iterator which is the past-the-end value for the container[.](#31.sentence-1)
|
||||
|
||||
[32](#32)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L369)
|
||||
|
||||
*Complexity*: Constant[.](#32.sentence-1)
|
||||
|
||||
[ð](#lib:cbegin,containers)
|
||||
|
||||
`b.cbegin()
|
||||
`
|
||||
|
||||
[33](#33)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L380)
|
||||
|
||||
*Result*: const_iterator[.](#33.sentence-1)
|
||||
|
||||
[34](#34)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L384)
|
||||
|
||||
*Returns*: const_cast<X const&>(b).begin()
|
||||
|
||||
[35](#35)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L388)
|
||||
|
||||
*Complexity*: Constant[.](#35.sentence-1)
|
||||
|
||||
[ð](#lib:cend,containers)
|
||||
|
||||
`b.cend()
|
||||
`
|
||||
|
||||
[36](#36)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L399)
|
||||
|
||||
*Result*: const_iterator[.](#36.sentence-1)
|
||||
|
||||
[37](#37)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L403)
|
||||
|
||||
*Returns*: const_cast<X const&>(b).end()
|
||||
|
||||
[38](#38)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L407)
|
||||
|
||||
*Complexity*: Constant[.](#38.sentence-1)
|
||||
|
||||
[ð](#itemdecl:18)
|
||||
|
||||
`i <=> j
|
||||
`
|
||||
|
||||
[39](#39)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L417)
|
||||
|
||||
*Result*: strong_ordering[.](#39.sentence-1)
|
||||
|
||||
[40](#40)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L421)
|
||||
|
||||
*Constraints*: X::iterator meets the random access iterator requirements[.](#40.sentence-1)
|
||||
|
||||
[41](#41)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L425)
|
||||
|
||||
*Complexity*: Constant[.](#41.sentence-1)
|
||||
|
||||
[ð](#lib:operator==,containers)
|
||||
|
||||
`c == b
|
||||
`
|
||||
|
||||
[42](#42)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L454)
|
||||
|
||||
*Preconditions*: T meets the *Cpp17EqualityComparable* requirements[.](#42.sentence-1)
|
||||
|
||||
[43](#43)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L458)
|
||||
|
||||
*Result*: bool[.](#43.sentence-1)
|
||||
|
||||
[44](#44)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L462)
|
||||
|
||||
*Returns*: equal(c.begin(), c.end(), b.begin(), b.end())
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
The algorithm equal is defined in [[alg.equal]](alg.equal "26.6.13 Equal")[.](#44.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[45](#45)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L470)
|
||||
|
||||
*Complexity*: Constant if c.size() != b.size(), linear otherwise[.](#45.sentence-1)
|
||||
|
||||
[46](#46)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L474)
|
||||
|
||||
*Remarks*: == is an equivalence relation[.](#46.sentence-1)
|
||||
|
||||
[ð](#lib:operator!=,containers)
|
||||
|
||||
`c != b
|
||||
`
|
||||
|
||||
[47](#47)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L503)
|
||||
|
||||
*Effects*: Equivalent to !(c == b)[.](#47.sentence-1)
|
||||
|
||||
[ð](#lib:swap,containers)
|
||||
|
||||
`t.swap(s)
|
||||
`
|
||||
|
||||
[48](#48)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L514)
|
||||
|
||||
*Result*: void[.](#48.sentence-1)
|
||||
|
||||
[49](#49)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L518)
|
||||
|
||||
*Effects*: Exchanges the contents of t and s[.](#49.sentence-1)
|
||||
|
||||
[50](#50)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L522)
|
||||
|
||||
*Complexity*: Linear for array and inplace_vector, and
|
||||
constant for all other standard containers[.](#50.sentence-1)
|
||||
|
||||
[ð](#itemdecl:22)
|
||||
|
||||
`swap(t, s)
|
||||
`
|
||||
|
||||
[51](#51)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L533)
|
||||
|
||||
*Effects*: Equivalent to t.swap(s)[.](#51.sentence-1)
|
||||
|
||||
[ð](#lib:size,containers)
|
||||
|
||||
`c.size()
|
||||
`
|
||||
|
||||
[52](#52)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L544)
|
||||
|
||||
*Result*: size_type[.](#52.sentence-1)
|
||||
|
||||
[53](#53)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L548)
|
||||
|
||||
*Returns*: distance(c.begin(), c.end()),
|
||||
i.e., the number of elements in the container[.](#53.sentence-1)
|
||||
|
||||
[54](#54)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L553)
|
||||
|
||||
*Complexity*: Constant[.](#54.sentence-1)
|
||||
|
||||
[55](#55)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L557)
|
||||
|
||||
*Remarks*: The number of elements is defined by the rules of
|
||||
constructors, inserts, and erases[.](#55.sentence-1)
|
||||
|
||||
[ð](#lib:max_size,containers)
|
||||
|
||||
`c.max_size()
|
||||
`
|
||||
|
||||
[56](#56)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L569)
|
||||
|
||||
*Result*: size_type[.](#56.sentence-1)
|
||||
|
||||
[57](#57)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L573)
|
||||
|
||||
*Returns*: distance(begin(), end()) for the largest possible container[.](#57.sentence-1)
|
||||
|
||||
[58](#58)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L577)
|
||||
|
||||
*Complexity*: Constant[.](#58.sentence-1)
|
||||
|
||||
[ð](#lib:empty,containers)
|
||||
|
||||
`c.empty()
|
||||
`
|
||||
|
||||
[59](#59)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L588)
|
||||
|
||||
*Result*: bool[.](#59.sentence-1)
|
||||
|
||||
[60](#60)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L592)
|
||||
|
||||
*Returns*: c.begin() == c.end()
|
||||
|
||||
[61](#61)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L596)
|
||||
|
||||
*Complexity*: Constant[.](#61.sentence-1)
|
||||
|
||||
[62](#62)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L600)
|
||||
|
||||
*Remarks*: If the container is empty, then c.empty() is true[.](#62.sentence-1)
|
||||
|
||||
[63](#63)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L605)
|
||||
|
||||
In the expressionsi == j
|
||||
i != j
|
||||
i < j
|
||||
i <= j
|
||||
i >= j
|
||||
i > j
|
||||
i <=> j
|
||||
i - j where i and j denote objects of a container's iterator type, either or both may be replaced by an object of the container'sconst_iterator type referring to the same element with no change in semantics[.](#63.sentence-1)
|
||||
|
||||
[64](#64)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L621)
|
||||
|
||||
Unless otherwise specified, all containers defined in this Clause obtain memory
|
||||
using an allocator (see [[allocator.requirements]](allocator.requirements "16.4.4.6 Cpp17Allocator requirements"))[.](#64.sentence-1)
|
||||
|
||||
[*Note [2](#note-2)*:
|
||||
|
||||
In particular, containers and iterators do not store references
|
||||
to allocated elements other than through the allocator's pointer type,
|
||||
i.e., as objects of type P orpointer_traits<P>::template rebind<*unspecified*>,
|
||||
where P is allocator_traits<allocator_type>::pointer[.](#64.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
|
||||
Copy constructors for these container types obtain an allocator by callingallocator_traits<allocator_type>::select_on_container_copy_construction on the allocator belonging to the container being copied[.](#64.sentence-3)
|
||||
|
||||
Move constructors obtain an allocator by move construction from the allocator belonging to
|
||||
the container being moved[.](#64.sentence-4)
|
||||
|
||||
Such move construction of the allocator shall not exit via an
|
||||
exception[.](#64.sentence-5)
|
||||
|
||||
All other constructors for these container types take aconst allocator_type& argument[.](#64.sentence-6)
|
||||
|
||||
[*Note [3](#note-3)*:
|
||||
|
||||
If an invocation of a constructor uses the default value of an optional
|
||||
allocator argument, then the allocator type must support value-initialization[.](#64.sentence-7)
|
||||
|
||||
â *end note*]
|
||||
|
||||
A copy of this allocator is used for any memory allocation and element construction
|
||||
performed, by these constructors and by all member functions,
|
||||
during the lifetime of each container object
|
||||
or until the allocator is replaced[.](#64.sentence-8)
|
||||
|
||||
The allocator may be replaced only via assignment orswap()[.](#64.sentence-9)
|
||||
|
||||
Allocator replacement is performed by
|
||||
copy assignment, move assignment, or swapping of the allocator only if
|
||||
|
||||
- [(64.1)](#64.1)
|
||||
|
||||
allocator_traits<allocator_type>::propagate_on_container_copy_assignment::value,
|
||||
|
||||
- [(64.2)](#64.2)
|
||||
|
||||
allocator_traits<allocator_type>::propagate_on_container_move_assignment::value,
|
||||
or
|
||||
|
||||
- [(64.3)](#64.3)
|
||||
|
||||
allocator_traits<allocator_type>::propagate_on_container_swap::value
|
||||
|
||||
is true within the implementation of the corresponding container operation[.](#64.sentence-10)
|
||||
|
||||
In all container types defined in this Clause, the member get_allocator() returns a copy of the allocator used to construct the container or, if that allocator
|
||||
has been replaced, a copy of the most recent replacement[.](#64.sentence-11)
|
||||
|
||||
[65](#65)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L661)
|
||||
|
||||
The expression a.swap(b), for containers a and b of a standard
|
||||
container type other than array and inplace_vector,
|
||||
shall exchange the values of a andb without invoking any move, copy, or swap operations on the individual
|
||||
container elements[.](#65.sentence-1)
|
||||
|
||||
Any Compare, Pred, or Hash types
|
||||
belonging to a and b shall meet the *Cpp17Swappable* requirements
|
||||
and shall be exchanged by calling swap as described in [[swappable.requirements]](swappable.requirements "16.4.4.3 Swappable requirements")[.](#65.sentence-2)
|
||||
|
||||
Ifallocator_traits<allocator_type>::propagate_on_container_swap::value istrue, thenallocator_type shall meet the *Cpp17Swappable* requirements and
|
||||
the allocators of a and b shall also be exchanged
|
||||
by calling swap as described in [[swappable.requirements]](swappable.requirements "16.4.4.3 Swappable requirements")[.](#65.sentence-3)
|
||||
|
||||
Otherwise, the allocators shall not be swapped, and the behavior is
|
||||
undefined unless a.get_allocator() == b.get_allocator()[.](#65.sentence-4)
|
||||
|
||||
Every iterator
|
||||
referring to an element in one container before the swap shall refer to the same
|
||||
element in the other container after the swap[.](#65.sentence-5)
|
||||
|
||||
It is unspecified whether an iterator
|
||||
with value a.end() before the swap will have value b.end() after the
|
||||
swap[.](#65.sentence-6)
|
||||
|
||||
[66](#66)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L683)
|
||||
|
||||
Unless otherwise specified (see [[associative.reqmts.except]](associative.reqmts.except "23.2.7.2 Exception safety guarantees"), [[unord.req.except]](unord.req.except "23.2.8.2 Exception safety guarantees"), [[deque.modifiers]](deque.modifiers "23.3.5.4 Modifiers"), [[inplace.vector.modifiers]](inplace.vector.modifiers "23.3.16.5 Modifiers"), and[[vector.modifiers]](vector.modifiers "23.3.13.5 Modifiers"))
|
||||
all container types defined in this Clause meet
|
||||
the following additional requirements:
|
||||
|
||||
- [(66.1)](#66.1)
|
||||
|
||||
If an exception is thrown by aninsert() or emplace() function while inserting a single element, that
|
||||
function has no effects[.](#66.1.sentence-1)
|
||||
|
||||
- [(66.2)](#66.2)
|
||||
|
||||
If an exception is thrown by apush_back(),push_front(),emplace_back(), or emplace_front() function, that function has no effects[.](#66.2.sentence-1)
|
||||
|
||||
- [(66.3)](#66.3)
|
||||
|
||||
Noerase(),clear(),pop_back() orpop_front() function throws an exception[.](#66.3.sentence-1)
|
||||
|
||||
- [(66.4)](#66.4)
|
||||
|
||||
No copy constructor or assignment operator of a returned iterator
|
||||
throws an exception[.](#66.4.sentence-1)
|
||||
|
||||
- [(66.5)](#66.5)
|
||||
|
||||
Noswap() function throws an exception[.](#66.5.sentence-1)
|
||||
|
||||
- [(66.6)](#66.6)
|
||||
|
||||
Noswap() function invalidates any references,
|
||||
pointers, or iterators referring to the elements
|
||||
of the containers being swapped[.](#66.6.sentence-1)
|
||||
[*Note [4](#note-4)*:
|
||||
The end() iterator does not refer to any element, so it can be invalidated[.](#66.6.sentence-2)
|
||||
â *end note*]
|
||||
|
||||
[67](#67)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L726)
|
||||
|
||||
Unless otherwise specified (either explicitly or by defining a
|
||||
function in terms of other functions), invoking a container member
|
||||
function or passing a container as an argument to a library function
|
||||
shall not invalidate iterators to, or change the values of, objects
|
||||
within that container[.](#67.sentence-1)
|
||||
|
||||
[68](#68)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L733)
|
||||
|
||||
A [*contiguous container*](#def:container,contiguous "23.2.2.2 Container requirements [container.reqmts]") is a container
|
||||
whose member types iterator and const_iterator meet the*Cpp17RandomAccessIterator* requirements ([[random.access.iterators]](random.access.iterators "24.3.5.7 Random access iterators")) and
|
||||
model [contiguous_iterator](iterator.concept.contiguous#concept:contiguous_iterator "24.3.4.14 Concept contiguous_iterator [iterator.concept.contiguous]") ([[iterator.concept.contiguous]](iterator.concept.contiguous "24.3.4.14 Concept contiguous_iterator"))[.](#68.sentence-1)
|
||||
|
||||
[69](#69)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L741)
|
||||
|
||||
The behavior of certain container member functions and deduction guides
|
||||
depends on whether types qualify as input iterators or allocators[.](#69.sentence-1)
|
||||
|
||||
The extent to which an implementation determines that a type cannot be an input
|
||||
iterator is unspecified, except that as a minimum integral types shall not qualify
|
||||
as input iterators[.](#69.sentence-2)
|
||||
|
||||
Likewise, the extent to which an implementation determines that a type cannot be
|
||||
an allocator is unspecified, except that as a minimum a type A shall not qualify
|
||||
as an allocator unless it meets both of the following conditions:
|
||||
|
||||
- [(69.1)](#69.1)
|
||||
|
||||
The [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3 Qualified names [expr.prim.id.qual]") A::value_type is valid and denotes a type ([[temp.deduct]](temp.deduct "13.10.3 Template argument deduction"))[.](#69.1.sentence-1)
|
||||
|
||||
- [(69.2)](#69.2)
|
||||
|
||||
The expression declval<A&>().allocate(size_t{}) is well-formed when treated as an unevaluated operand[.](#69.2.sentence-1)
|
||||
6854
cppdraft/container/requirements.md
Normal file
6854
cppdraft/container/requirements.md
Normal file
File diff suppressed because it is too large
Load Diff
36
cppdraft/container/requirements/dataraces.md
Normal file
36
cppdraft/container/requirements/dataraces.md
Normal file
@@ -0,0 +1,36 @@
|
||||
[container.requirements.dataraces]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.2 Requirements [[container.requirements]](container.requirements#dataraces)
|
||||
|
||||
### 23.2.3 Container data races [container.requirements.dataraces]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1288)
|
||||
|
||||
For purposes of avoiding data races ([[res.on.data.races]](res.on.data.races "16.4.6.10 Data race avoidance")), implementations shall
|
||||
consider the following functions to be const: begin, end,rbegin, rend, front, back, data, find,lower_bound, upper_bound, equal_range, at and, except in
|
||||
associative or unordered associative containers, operator[][.](#1.sentence-1)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1295)
|
||||
|
||||
Notwithstanding [[res.on.data.races]](res.on.data.races "16.4.6.10 Data race avoidance"), implementations are required to avoid data
|
||||
races when the contents of the contained object in different elements in the same
|
||||
container, excepting vector<bool>, are modified concurrently[.](#2.sentence-1)
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L1300)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
For a vector<int> x with a size greater than one, x[1] = 5 and *x.begin() = 10 can be executed concurrently without a data race, butx[0] = 5 and *x.begin() = 10 executed concurrently can result in a data
|
||||
race[.](#3.sentence-1)
|
||||
|
||||
As an exception to the general rule, for a vector<bool> y, y[0] = true can race with y[1] = true[.](#3.sentence-2)
|
||||
|
||||
â *end note*]
|
||||
1278
cppdraft/container/requirements/general.md
Normal file
1278
cppdraft/container/requirements/general.md
Normal file
File diff suppressed because it is too large
Load Diff
50
cppdraft/container/requirements/pre.md
Normal file
50
cppdraft/container/requirements/pre.md
Normal file
@@ -0,0 +1,50 @@
|
||||
[container.requirements.pre]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.2 Requirements [[container.requirements]](container.requirements#pre)
|
||||
|
||||
### 23.2.1 Preamble [container.requirements.pre]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L40)
|
||||
|
||||
Containers are objects that store other objects[.](#1.sentence-1)
|
||||
|
||||
They control allocation and deallocation of these objects
|
||||
through constructors, destructors, insert and erase operations[.](#1.sentence-2)
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L45)
|
||||
|
||||
All of the complexity requirements in this Clause are stated solely
|
||||
in terms of the number of operations on the contained objects[.](#2.sentence-1)
|
||||
|
||||
[*Example [1](#example-1)*:
|
||||
|
||||
The copy constructor of typevector<vector<int>> has linear complexity,
|
||||
even though the complexity of copying each containedvector<int> is itself linear[.](#2.sentence-2)
|
||||
|
||||
â *end example*]
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L57)
|
||||
|
||||
Allocator-aware containers ([[container.alloc.reqmts]](container.alloc.reqmts "23.2.2.5 Allocator-aware containers"))
|
||||
other than basic_string construct elements using the functionallocator_traits<allocator_type>::rebind_traits<U>::construct and destroy elements using the functionallocator_traits<allocator_type>::rebind_traits<U>::destroy ([[allocator.traits.members]](allocator.traits.members "20.2.9.3 Static member functions")),
|
||||
where U is either allocator_type::value_type or
|
||||
an internal type used by the container[.](#3.sentence-1)
|
||||
|
||||
These functions are called only for the
|
||||
container's element type, not for internal types used by the container[.](#3.sentence-2)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
This
|
||||
means, for example, that a node-based container would need to construct nodes containing
|
||||
aligned buffers and call construct to place the element into the buffer[.](#3.sentence-3)
|
||||
|
||||
â *end note*]
|
||||
136
cppdraft/container/rev/reqmts.md
Normal file
136
cppdraft/container/rev/reqmts.md
Normal file
@@ -0,0 +1,136 @@
|
||||
[container.rev.reqmts]
|
||||
|
||||
# 23 Containers library [[containers]](./#containers)
|
||||
|
||||
## 23.2 Requirements [[container.requirements]](container.requirements#container.rev.reqmts)
|
||||
|
||||
### 23.2.2 General containers [[container.requirements.general]](container.requirements.general#container.rev.reqmts)
|
||||
|
||||
#### 23.2.2.3 Reversible container requirements [container.rev.reqmts]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L782)
|
||||
|
||||
A type X meets the [*reversible container*](#def:container,reversible "23.2.2.3 Reversible container requirements [container.rev.reqmts]") requirements ifX meets the container requirements,
|
||||
the iterator type of X belongs to the
|
||||
bidirectional or random access iterator categories ([[iterator.requirements]](iterator.requirements "24.3 Iterator requirements")),
|
||||
and
|
||||
the following types and expressions are well-formed and have
|
||||
the specified semantics[.](#1.sentence-1)
|
||||
|
||||
[ð](#lib:reverse_iterator,containers)
|
||||
|
||||
`typename X::reverse_iterator
|
||||
`
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L797)
|
||||
|
||||
*Result*: The type reverse_iterator<X::iterator>,
|
||||
an iterator type whose value type is T[.](#2.sentence-1)
|
||||
|
||||
[ð](#lib:const_reverse_iterator,containers)
|
||||
|
||||
`typename X::const_reverse_iterator
|
||||
`
|
||||
|
||||
[3](#3)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L809)
|
||||
|
||||
*Result*: The type reverse_iterator<X::const_iterator>,
|
||||
a constant iterator type whose value type is T[.](#3.sentence-1)
|
||||
|
||||
[ð](#lib:rbegin,containers)
|
||||
|
||||
`a.rbegin()
|
||||
`
|
||||
|
||||
[4](#4)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L821)
|
||||
|
||||
*Result*: reverse_iterator;const_reverse_iterator for constant a[.](#4.sentence-1)
|
||||
|
||||
[5](#5)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L826)
|
||||
|
||||
*Returns*: reverse_iterator(end())
|
||||
|
||||
[6](#6)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L830)
|
||||
|
||||
*Complexity*: Constant[.](#6.sentence-1)
|
||||
|
||||
[ð](#lib:rend,containers)
|
||||
|
||||
`a.rend()
|
||||
`
|
||||
|
||||
[7](#7)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L841)
|
||||
|
||||
*Result*: reverse_iterator;const_reverse_iterator for constant a[.](#7.sentence-1)
|
||||
|
||||
[8](#8)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L846)
|
||||
|
||||
*Returns*: reverse_iterator(begin())
|
||||
|
||||
[9](#9)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L850)
|
||||
|
||||
*Complexity*: Constant[.](#9.sentence-1)
|
||||
|
||||
[ð](#lib:crbegin,containers)
|
||||
|
||||
`a.crbegin()
|
||||
`
|
||||
|
||||
[10](#10)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L861)
|
||||
|
||||
*Result*: const_reverse_iterator[.](#10.sentence-1)
|
||||
|
||||
[11](#11)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L865)
|
||||
|
||||
*Returns*: const_cast<X const&>(a).rbegin()
|
||||
|
||||
[12](#12)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L869)
|
||||
|
||||
*Complexity*: Constant[.](#12.sentence-1)
|
||||
|
||||
[ð](#lib:crend,containers)
|
||||
|
||||
`a.crend()
|
||||
`
|
||||
|
||||
[13](#13)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L880)
|
||||
|
||||
*Result*: const_reverse_iterator[.](#13.sentence-1)
|
||||
|
||||
[14](#14)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L884)
|
||||
|
||||
*Returns*: const_cast<X const&>(a).rend()
|
||||
|
||||
[15](#15)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L888)
|
||||
|
||||
*Complexity*: Constant[.](#15.sentence-1)
|
||||
Reference in New Issue
Block a user