Skip to content

Commit 55e61b0

Browse files
committed
[container.requirements.general] optional and allocator-aware containers
1 parent c68fcd6 commit 55e61b0

File tree

1 file changed

+219
-130
lines changed

1 file changed

+219
-130
lines changed

source/containers.tex

Lines changed: 219 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -808,50 +808,48 @@
808808
model \libconcept{contiguous_iterator}\iref{iterator.concept.contiguous}.
809809

810810
\pnum
811-
\tref{container.opt} lists operations that are provided
811+
The following operations are provided
812812
for some types of containers but not others. Those containers for which the
813-
listed operations are provided shall implement the semantics described in
814-
\tref{container.opt} unless otherwise stated.
813+
listed operations are provided shall implement the semantics as described
814+
unless otherwise stated.
815815
If the iterators passed to \tcode{lexicographical_compare_three_way}
816816
meet the constexpr iterator requirements\iref{iterator.requirements.general}
817-
then the operations described in \tref{container.opt}
817+
then the operations described below
818818
are implemented by constexpr functions.
819819

820-
\begin{libreqtab5}
821-
{Optional container operations}
822-
{container.opt}
823-
\\ \topline
824-
\lhdr{Expression} & \chdr{Return type} & \chdr{Operational} &
825-
\chdr{Assertion/note} & \rhdr{Complexity} \\
826-
& & \chdr{semantics} & \chdr{pre-/post-condition} & \\ \capsep
827-
\endfirsthead
828-
\continuedcaption\\
829-
\topline
830-
\lhdr{Expression} & \chdr{Return type} & \chdr{Operational} &
831-
\chdr{Assertion/note} & \rhdr{Complexity} \\
832-
& & \chdr{semantics} & \chdr{pre-/post-condition} & \\ \capsep
833-
\endhead
820+
\begin{itemdecl}
821+
a <=> b
822+
\end{itemdecl}
823+
824+
\begin{itemdescr}
825+
\pnum
826+
\result
827+
\tcode{\exposid{synth-three-way-result}<X::value_type>}.
834828

835-
\tcode{a <=> b} &
836-
\tcode{\placeholdernc{synth-three-\brk{}way-result}\brk{}<value_type>} &
837-
\tcode{lexicographical_compare_three_way(a.begin(), a.end(),
838-
b.begin(), b.end(), \placeholdernc{synth-three-way})} &
839-
\expects
840-
Either \tcode{<=>} is defined for values of type (possibly const) \tcode{T},
841-
or \tcode{<} is defined for values of type (possibly const) \tcode{T} and
842-
\tcode{<} is a total ordering relationship. &
843-
linear \\
844-
\end{libreqtab5}
829+
\pnum
830+
\expects
831+
Either \tcode{<=>} is defined for values of type (possibly const) \tcode{T},
832+
or \tcode{<} is defined for values of type (possibly const) \tcode{T} and
833+
\tcode{<} is a total ordering relationship.
845834

835+
\pnum
836+
\cvalue
837+
\tcode{lexicographical_compare_three_way(a.begin(), a.end(),
838+
b.begin(), b.end(),\newline \exposidnc{synth-three-way})}
846839
\begin{note}
847840
The algorithm \tcode{lexicographical_compare_three_way}
848841
is defined in \ref{algorithms}.
849842
\end{note}
850843

851844
\pnum
852-
All of the containers defined in this Clause and in~\ref{basic.string} except \tcode{array}
853-
meet the additional requirements of an allocator-aware container, as described in
854-
\tref{container.alloc.req}.
845+
\complexity
846+
Linear.
847+
\end{itemdescr}
848+
849+
\pnum
850+
All of the containers defined in \ref{containers} and in~\ref{basic.string} except \tcode{array}
851+
meet the additional requirements of an \defnadj{allocator-aware}{container},
852+
as described below.
855853

856854
\pnum
857855
Given an allocator type \tcode{A}
@@ -940,16 +938,18 @@
940938
\end{note}
941939

942940
\pnum
943-
In \tref{container.alloc.req},
941+
In this subclause,
944942
\begin{itemize}
945943
\item
946944
\tcode{X} denotes an allocator-aware container class
947-
with a \tcode{value_type} of \tcode{T} using allocator of type \tcode{A},
945+
with a \tcode{value_type} of \tcode{T} using an allocator of type \tcode{A},
948946
\item
949947
\tcode{u} denotes a variable,
950948
\item
951949
\tcode{a} and \tcode{b} denote non-const lvalues of type \tcode{X},
952950
\item
951+
\tcode{c} denotes an lvalue of type \tcode{\keyword{const} X},
952+
\item
953953
\tcode{t} denotes an lvalue or a const rvalue of type \tcode{X},
954954
\item
955955
\tcode{rv} denotes a non-const rvalue of type \tcode{X}, and
@@ -974,112 +974,201 @@
974974
\indexlibrarymemberx{unordered_multimap}{#1}%
975975
}
976976

977-
\begin{libreqtab4a}
978-
{Allocator-aware container requirements}
979-
{container.alloc.req}
980-
\\ \topline
981-
\lhdr{Expression} & \chdr{Return type} &
982-
\chdr{Assertion/note} & \rhdr{Complexity} \\
983-
& & \chdr{pre-/post-condition} & \\ \capsep
984-
\endfirsthead
985-
\continuedcaption\\
986-
\hline
987-
988-
\lhdr{Expression} & \chdr{Return type} &
989-
\chdr{Assertion/note} & \rhdr{Complexity} \\
990-
& & \chdr{pre-/post-condition} & \\ \capsep
991-
\endhead
977+
A type \tcode{X} meets the allocator-aware container requirements
978+
if \tcode{X} meets the container requirements and
979+
the following types, statements, and expressions are well-formed and have
980+
the specified semantics.
992981

993982
\indexcont{allocator_type}%
994-
\tcode{allocator_type} &
995-
\tcode{A} &
996-
\mandates \tcode{allocator_type::value_type} is the same as \tcode{X::value_type}. &
997-
compile time \\ \rowsep
983+
\begin{itemdecl}
984+
typename X::allocator_type
985+
\end{itemdecl}
986+
987+
\begin{itemdescr}
988+
\pnum
989+
\result
990+
\tcode{A}
991+
992+
\pnum
993+
\expects
994+
\tcode{allocator_type::value_type} is the same as \tcode{X::value_type}.
995+
\end{itemdescr}
998996

999997
\indexcont{get_allocator}%
1000-
\tcode{get_-} \tcode{allocator()} &
1001-
\tcode{A} &
1002-
&
1003-
constant \\ \rowsep
1004-
1005-
\tcode{X()}\br
1006-
\tcode{X u;} &
1007-
&
1008-
\expects \tcode{A} meets the \oldconcept{DefaultConstructible} requirements.\br
1009-
\ensures \tcode{u.empty()} returns \tcode{true},
1010-
\tcode{u.get_allocator() == A()} &
1011-
constant \\ \rowsep
1012-
1013-
\tcode{X(m)} &
1014-
&
1015-
\ensures
1016-
\tcode{u.empty()} returns \tcode{true}, &
1017-
constant \\
1018-
\tcode{X u(m);} &
1019-
&
1020-
\tcode{u.get_allocator() == m} &
1021-
\\ \rowsep
1022-
1023-
\tcode{X(t, m)}\br
1024-
\tcode{X u(t, m);} &
1025-
&
1026-
\expects
1027-
\tcode{T} is \oldconcept{CopyInsertable} into \tcode{X}.\br
1028-
\ensures
1029-
\tcode{u == t}, \tcode{u.get_allocator() == m} &
1030-
linear \\ \rowsep
1031-
1032-
\tcode{X(rv)}\br
1033-
\tcode{X u(rv);}
1034-
&
1035-
&
1036-
\ensures \tcode{u} has the same elements as \tcode{rv} had before this
1037-
construction; the value of \tcode{u.get_allocator()} is the same as the
1038-
value of \tcode{rv.get_allocator()} before this construction. &
1039-
constant \\ \rowsep
1040-
1041-
\tcode{X(rv, m)}\br
1042-
\tcode{X u(rv, m);} &
1043-
&
1044-
\expects \tcode{T} is
1045-
\oldconcept{MoveInsertable} into \tcode{X}.\br
1046-
\ensures \tcode{u} has the same elements,
1047-
or copies of the elements, that \tcode{rv} had before
1048-
this construction, \tcode{u.get_allocator() == m} &
1049-
constant if \tcode{m ==} \tcode{rv.get_allocator()}, otherwise linear \\ \rowsep
1050-
1051-
\tcode{a = t} &
1052-
\tcode{X\&} &
1053-
\expects \tcode{T} is
1054-
\oldconcept{CopyInsertable} into \tcode{X}
1055-
and \oldconcept{CopyAssignable}.\br
1056-
\ensures \tcode{a == t} &
1057-
linear \\ \rowsep
998+
\begin{itemdecl}
999+
c.get_allocator()
1000+
\end{itemdecl}
1001+
1002+
\begin{itemdescr}
1003+
\pnum
1004+
\result
1005+
\tcode{A}
1006+
1007+
\pnum
1008+
\complexity
1009+
Constant.
1010+
\end{itemdescr}
1011+
1012+
\begin{itemdecl}
1013+
X u;
1014+
X u = X();
1015+
\end{itemdecl}
1016+
1017+
\begin{itemdescr}
1018+
\pnum
1019+
\expects
1020+
\tcode{A} meets the \oldconcept{DefaultConstructible} requirements.
1021+
1022+
\pnum
1023+
\ensures
1024+
\tcode{u.empty()} returns \tcode{true}, \tcode{u.get_allocator() == A()}.
1025+
1026+
\pnum
1027+
\complexity
1028+
Constant.
1029+
\end{itemdescr}
1030+
1031+
\begin{itemdecl}
1032+
X u(m);
1033+
\end{itemdecl}
1034+
1035+
\begin{itemdescr}
1036+
\pnum
1037+
\ensures
1038+
\tcode{u.empty()} returns \tcode{true}, \tcode{u.get_allocator() == m}.
1039+
1040+
\pnum
1041+
\complexity
1042+
Constant.
1043+
\end{itemdescr}
1044+
1045+
\begin{itemdecl}
1046+
X u(t, m);
1047+
\end{itemdecl}
1048+
1049+
\begin{itemdescr}
1050+
\pnum
1051+
\expects
1052+
\tcode{T} is \oldconcept{CopyInsertable} into \tcode{X}.
1053+
1054+
\pnum
1055+
\ensures
1056+
\tcode{u == t}, \tcode{u.get_allocator() == m}
1057+
1058+
\pnum
1059+
\complexity
1060+
Linear.
1061+
\end{itemdescr}
1062+
1063+
\begin{itemdecl}
1064+
X u(rv);
1065+
\end{itemdecl}
1066+
1067+
\begin{itemdescr}
1068+
\pnum
1069+
\ensures
1070+
\tcode{u} has the same elements as \tcode{rv} had before this construction;
1071+
the value of \tcode{u.get_allocator()} is the same as
1072+
the value of \tcode{rv.get_allocator()} before this construction.
1073+
1074+
\pnum
1075+
\complexity
1076+
Constant.
1077+
\end{itemdescr}
1078+
1079+
\begin{itemdecl}
1080+
X u(rv, m);
1081+
\end{itemdecl}
1082+
1083+
\begin{itemdescr}
1084+
\pnum
1085+
\expects
1086+
\tcode{T} is \oldconcept{MoveInsertable} into \tcode{X}.
1087+
1088+
\pnum
1089+
\ensures
1090+
\tcode{u} has the same elements, or copies of the elements,
1091+
that \tcode{rv} had before this construction,
1092+
\tcode{u.get_allocator() == m}.
1093+
1094+
\pnum
1095+
\complexity
1096+
Constant if \tcode{m == rv.get_allocator()}, otherwise linear.
1097+
\end{itemdescr}
1098+
1099+
\begin{itemdecl}
1100+
a = t
1101+
\end{itemdecl}
1102+
1103+
\begin{itemdescr}
1104+
\pnum
1105+
\result
1106+
\tcode{X\&}.
1107+
1108+
\pnum
1109+
\expects
1110+
\tcode{T} is \oldconcept{CopyInsertable} into \tcode{X} and
1111+
\oldconcept{CopyAssignable}.
1112+
1113+
\pnum
1114+
\ensures
1115+
\tcode{a == t} is \tcode{true}.
1116+
1117+
\pnum
1118+
\complexity
1119+
Linear.
1120+
\end{itemdescr}
10581121

10591122
\indexcont{operator=}%
1060-
\tcode{a = rv} &
1061-
\tcode{X\&} &
1062-
\expects If \tcode{allocator_-}\br
1063-
\tcode{traits<allocator_type>}\br
1064-
\tcode{::propagate_on_container_-}\br
1065-
\tcode{move_assignment::value} is\br
1066-
\tcode{false}, \tcode{T} is
1067-
\oldconcept{MoveInsertable} into \tcode{X} and
1068-
\oldconcept{MoveAssignable}.\br
1069-
\effects All existing elements of \tcode{a}
1070-
are either move assigned to or destroyed.\br
1071-
\ensures If \tcode{a} and \tcode{rv} do not refer to the same object,
1072-
\tcode{a} is equal to the value that \tcode{rv} had before
1073-
this assignment. &
1074-
linear \\ \rowsep
1123+
\begin{itemdecl}
1124+
a = rv
1125+
\end{itemdecl}
1126+
1127+
\begin{itemdescr}
1128+
\pnum
1129+
\result
1130+
\tcode{X\&}.
1131+
1132+
\pnum
1133+
\expects
1134+
If
1135+
\tcode{allocator_traits<allocator_type>::propagate_on_container_move_assign\-ment::value}
1136+
is \tcode{false},
1137+
\tcode{T} is \oldconcept{MoveInsertable} into \tcode{X} and
1138+
\oldconcept{MoveAssignable}.
1139+
1140+
\pnum
1141+
\effects
1142+
All existing elements of \tcode{a} are either move assigned to or destroyed.
1143+
1144+
\pnum
1145+
\ensures
1146+
If \tcode{a} and \tcode{rv} do not refer to the same object,
1147+
\tcode{a} is equal to the value that \tcode{rv} had before this assignment.
1148+
1149+
\pnum
1150+
\complexity
1151+
Linear.
1152+
\end{itemdescr}
10751153

10761154
\indexcont{swap}%
1077-
\tcode{a.swap(b)} &
1078-
\keyword{void} &
1079-
\effects exchanges the contents of \tcode{a} and \tcode{b} &
1080-
constant \\ \rowsep
1155+
\begin{itemdecl}
1156+
a.swap(b)
1157+
\end{itemdecl}
10811158

1082-
\end{libreqtab4a}
1159+
\begin{itemdescr}
1160+
\pnum
1161+
\result
1162+
\keyword{void}
1163+
1164+
\pnum
1165+
\effects
1166+
Exchanges the contents of \tcode{a} and \tcode{b}.
1167+
1168+
\pnum
1169+
\complexity
1170+
Constant.
1171+
\end{itemdescr}
10831172

10841173
\pnum
10851174
The behavior of certain container member functions and deduction guides

0 commit comments

Comments
 (0)