|
749 | 749 | model \libconcept{contiguous_iterator}\iref{iterator.concept.contiguous}.
|
750 | 750 |
|
751 | 751 | \pnum
|
752 |
| -\tref{container.opt} lists operations that are provided |
| 752 | +The following operations are provided |
753 | 753 | for some types of containers but not others. Those containers for which the
|
754 |
| -listed operations are provided shall implement the semantics described in |
755 |
| -\tref{container.opt} unless otherwise stated. |
| 754 | +listed operations are provided shall implement the semantics as described |
| 755 | +unless otherwise stated. |
756 | 756 | If the iterators passed to \tcode{lexicographical_compare_three_way}
|
757 | 757 | meet the constexpr iterator requirements\iref{iterator.requirements.general}
|
758 |
| -then the operations described in \tref{container.opt} |
| 758 | +then the operations described below |
759 | 759 | are implemented by constexpr functions.
|
760 | 760 |
|
761 |
| -\begin{libreqtab5} |
762 |
| -{Optional container operations} |
763 |
| -{container.opt} |
764 |
| -\\ \topline |
765 |
| -\lhdr{Expression} & \chdr{Return type} & \chdr{Operational} & |
766 |
| -\chdr{Assertion/note} & \rhdr{Complexity} \\ |
767 |
| - & & \chdr{semantics} & \chdr{pre-/post-condition} & \\ \capsep |
768 |
| -\endfirsthead |
769 |
| -\continuedcaption\\ |
770 |
| -\topline |
771 |
| -\lhdr{Expression} & \chdr{Return type} & \chdr{Operational} & |
772 |
| -\chdr{Assertion/note} & \rhdr{Complexity} \\ |
773 |
| - & & \chdr{semantics} & \chdr{pre-/post-condition} & \\ \capsep |
774 |
| -\endhead |
| 761 | +\begin{itemdecl} |
| 762 | +a <=> b |
| 763 | +\end{itemdecl} |
| 764 | + |
| 765 | +\begin{itemdescr} |
| 766 | +\pnum |
| 767 | +\result |
| 768 | +A prvalue of type \tcode{\exposid{synth-three-way-result}<X::value_type>}. |
775 | 769 |
|
776 |
| -\tcode{a <=> b} & |
777 |
| - \tcode{\placeholdernc{synth-three-\brk{}way-result}\brk{}<value_type>} & |
778 |
| - \tcode{lexicographical_compare_three_way(a.begin(), a.end(), |
779 |
| - b.begin(), b.end(), \placeholdernc{synth-three-way})} & |
780 |
| - \expects |
781 |
| - Either \tcode{<=>} is defined for values of type (possibly const) \tcode{T}, |
782 |
| - or \tcode{<} is defined for values of type (possibly const) \tcode{T} and |
783 |
| - \tcode{<} is a total ordering relationship. & |
784 |
| - linear \\ |
785 |
| -\end{libreqtab5} |
| 770 | +\pnum |
| 771 | +\expects |
| 772 | +Either \tcode{<=>} is defined for values of type (possibly const) \tcode{T}, |
| 773 | +or \tcode{<} is defined for values of type (possibly const) \tcode{T} and |
| 774 | +\tcode{<} is a total ordering relationship. |
786 | 775 |
|
| 776 | +\pnum |
| 777 | +\cvalue |
| 778 | +\tcode{lexicographical_compare_three_way(a.begin(), a.end(), |
| 779 | +b.begin(), b.end(),\newline \exposidnc{synth-three-way})} |
787 | 780 | \begin{note}
|
788 | 781 | The algorithm \tcode{lexicographical_compare_three_way}
|
789 | 782 | is defined in \ref{algorithms}.
|
790 | 783 | \end{note}
|
791 | 784 |
|
792 | 785 | \pnum
|
793 |
| -All of the containers defined in this Clause and in~\ref{basic.string} except \tcode{array} |
794 |
| -meet the additional requirements of an allocator-aware container, as described in |
795 |
| -\tref{container.alloc.req}. |
| 786 | +\complexity |
| 787 | +Linear. |
| 788 | +\end{itemdescr} |
| 789 | + |
| 790 | +\pnum |
| 791 | +All of the containers defined in \ref{containers} and in~\ref{basic.string} except \tcode{array} |
| 792 | +meet the additional requirements of an \defnadj{allocator-aware}{container}, |
| 793 | +as described below. |
796 | 794 |
|
797 | 795 | \pnum
|
798 | 796 | Given an allocator type \tcode{A}
|
|
881 | 879 | \end{note}
|
882 | 880 |
|
883 | 881 | \pnum
|
884 |
| -In \tref{container.alloc.req}, |
| 882 | +In this subclause, |
885 | 883 | \begin{itemize}
|
886 | 884 | \item
|
887 | 885 | \tcode{X} denotes an allocator-aware container class
|
888 |
| -with a \tcode{value_type} of \tcode{T} using allocator of type \tcode{A}, |
| 886 | +with a \tcode{value_type} of \tcode{T} using an allocator of type \tcode{A}, |
889 | 887 | \item
|
890 | 888 | \tcode{u} denotes a variable,
|
891 | 889 | \item
|
892 | 890 | \tcode{a} and \tcode{b} denote non-const lvalues of type \tcode{X},
|
893 | 891 | \item
|
| 892 | +\tcode{c} denotes an lvalue of type \tcode{\keyword{const} X}, |
| 893 | +\item |
894 | 894 | \tcode{t} denotes an lvalue or a const rvalue of type \tcode{X},
|
895 | 895 | \item
|
896 | 896 | \tcode{rv} denotes a non-const rvalue of type \tcode{X}, and
|
897 | 897 | \item
|
898 | 898 | \tcode{m} is a value of type \tcode{A}.
|
899 | 899 | \end{itemize}
|
900 | 900 |
|
901 |
| -\begin{libreqtab4a} |
902 |
| -{Allocator-aware container requirements} |
903 |
| -{container.alloc.req} |
904 |
| -\\ \topline |
905 |
| -\lhdr{Expression} & \chdr{Return type} & |
906 |
| -\chdr{Assertion/note} & \rhdr{Complexity} \\ |
907 |
| - & & \chdr{pre-/post-condition} & \\ \capsep |
908 |
| -\endfirsthead |
909 |
| -\continuedcaption\\ |
910 |
| -\hline |
| 901 | +A type \tcode{X} meets the allocator-aware container requirements |
| 902 | +if \tcode{X} meets the container requirements and |
| 903 | +the following types, statements, and expressions are well-formed and have |
| 904 | +the specified semantics. |
911 | 905 |
|
912 |
| -\lhdr{Expression} & \chdr{Return type} & |
913 |
| -\chdr{Assertion/note} & \rhdr{Complexity} \\ |
914 |
| - & & \chdr{pre-/post-condition} & \\ \capsep |
915 |
| -\endhead |
| 906 | +\begin{itemdecl} |
| 907 | +typename X::allocator_type |
| 908 | +\end{itemdecl} |
916 | 909 |
|
917 |
| -\tcode{allocator_type} & |
918 |
| - \tcode{A} & |
919 |
| - \mandates \tcode{allocator_type::value_type} is the same as \tcode{X::value_type}. & |
920 |
| - compile time \\ \rowsep |
921 |
| - |
922 |
| -\tcode{get_-} \tcode{allocator()} & |
923 |
| - \tcode{A} & |
924 |
| - & |
925 |
| - constant \\ \rowsep |
926 |
| - |
927 |
| -\tcode{X()}\br |
928 |
| -\tcode{X u;} & |
929 |
| - & |
930 |
| - \expects \tcode{A} meets the \oldconcept{DefaultConstructible} requirements.\br |
931 |
| - \ensures \tcode{u.empty()} returns \tcode{true}, |
932 |
| - \tcode{u.get_allocator() == A()} & |
933 |
| - constant \\ \rowsep |
934 |
| - |
935 |
| -\tcode{X(m)} & |
936 |
| - & |
937 |
| - \ensures |
938 |
| - \tcode{u.empty()} returns \tcode{true}, & |
939 |
| - constant \\ |
940 |
| -\tcode{X u(m);} & |
941 |
| - & |
942 |
| -\tcode{u.get_allocator() == m} & |
943 |
| - \\ \rowsep |
944 |
| - |
945 |
| -\tcode{X(t, m)}\br |
946 |
| -\tcode{X u(t, m);} & |
947 |
| - & |
948 |
| - \expects |
949 |
| - \tcode{T} is \oldconcept{CopyInsertable} into \tcode{X}.\br |
950 |
| - \ensures |
951 |
| - \tcode{u == t}, \tcode{u.get_allocator() == m} & |
952 |
| - linear \\ \rowsep |
953 |
| - |
954 |
| -\tcode{X(rv)}\br |
955 |
| -\tcode{X u(rv);} |
956 |
| - & |
957 |
| - & |
958 |
| - \ensures \tcode{u} has the same elements as \tcode{rv} had before this |
959 |
| - construction; the value of \tcode{u.get_allocator()} is the same as the |
960 |
| - value of \tcode{rv.get_allocator()} before this construction. & |
961 |
| - constant \\ \rowsep |
962 |
| - |
963 |
| -\tcode{X(rv, m)}\br |
964 |
| -\tcode{X u(rv, m);} & |
965 |
| - & |
966 |
| - \expects \tcode{T} is |
967 |
| - \oldconcept{MoveInsertable} into \tcode{X}.\br |
968 |
| - \ensures \tcode{u} has the same elements, |
969 |
| - or copies of the elements, that \tcode{rv} had before |
970 |
| - this construction, \tcode{u.get_allocator() == m} & |
971 |
| - constant if \tcode{m ==} \tcode{rv.get_allocator()}, otherwise linear \\ \rowsep |
972 |
| - |
973 |
| -\tcode{a = t} & |
974 |
| - \tcode{X\&} & |
975 |
| - \expects \tcode{T} is |
976 |
| - \oldconcept{CopyInsertable} into \tcode{X} |
977 |
| - and \oldconcept{CopyAssignable}.\br |
978 |
| - \ensures \tcode{a == t} & |
979 |
| - linear \\ \rowsep |
980 |
| - |
981 |
| -\tcode{a = rv} & |
982 |
| - \tcode{X\&} & |
983 |
| - \expects If \tcode{allocator_-}\br |
984 |
| - \tcode{traits<allocator_type>}\br |
985 |
| - \tcode{::propagate_on_container_-}\br |
986 |
| - \tcode{move_assignment::value} is\br |
987 |
| - \tcode{false}, \tcode{T} is |
988 |
| - \oldconcept{MoveInsertable} into \tcode{X} and |
989 |
| - \oldconcept{MoveAssignable}.\br |
990 |
| - \effects All existing elements of \tcode{a} |
991 |
| - are either move assigned to or destroyed.\br |
992 |
| - \ensures If \tcode{a} and \tcode{rv} do not refer to the same object, |
993 |
| - \tcode{a} is equal to the value that \tcode{rv} had before |
994 |
| - this assignment. & |
995 |
| - linear \\ \rowsep |
996 |
| - |
997 |
| -\tcode{a.swap(b)} & |
998 |
| - \keyword{void} & |
999 |
| - \effects exchanges the contents of \tcode{a} and \tcode{b} & |
1000 |
| - constant \\ \rowsep |
| 910 | +\begin{itemdescr} |
| 911 | +\pnum |
| 912 | +\result |
| 913 | +\tcode{A} |
1001 | 914 |
|
1002 |
| -\end{libreqtab4a} |
| 915 | +\pnum |
| 916 | +\expects |
| 917 | +\tcode{allocator_type::value_type} is the same as \tcode{X::value_type}. |
| 918 | +\end{itemdescr} |
| 919 | + |
| 920 | +\begin{itemdecl} |
| 921 | +c.get_allocator() |
| 922 | +\end{itemdecl} |
| 923 | + |
| 924 | +\begin{itemdescr} |
| 925 | +\pnum |
| 926 | +\result |
| 927 | +\tcode{A} |
| 928 | + |
| 929 | +\pnum |
| 930 | +\complexity |
| 931 | +Constant. |
| 932 | +\end{itemdescr} |
| 933 | + |
| 934 | +\begin{itemdecl} |
| 935 | +X u; |
| 936 | +X u = X(); |
| 937 | +\end{itemdecl} |
| 938 | + |
| 939 | +\begin{itemdescr} |
| 940 | +\pnum |
| 941 | +\expects |
| 942 | +\tcode{A} meets the \oldconcept{DefaultConstructible} requirements. |
| 943 | + |
| 944 | +\pnum |
| 945 | +\ensures |
| 946 | +\tcode{u.empty()} returns \tcode{true}, \tcode{u.get_allocator() == A()}. |
| 947 | + |
| 948 | +\pnum |
| 949 | +\complexity |
| 950 | +Constant. |
| 951 | +\end{itemdescr} |
| 952 | + |
| 953 | +\begin{itemdecl} |
| 954 | +X u(m); |
| 955 | +\end{itemdecl} |
| 956 | + |
| 957 | +\begin{itemdescr} |
| 958 | +\pnum |
| 959 | +\ensures |
| 960 | +\tcode{u.empty()} returns \tcode{true}, \tcode{u.get_allocator() == m}. |
| 961 | + |
| 962 | +\pnum |
| 963 | +\complexity |
| 964 | +Constant. |
| 965 | +\end{itemdescr} |
| 966 | + |
| 967 | +\begin{itemdecl} |
| 968 | +X u(t, m); |
| 969 | +\end{itemdecl} |
| 970 | + |
| 971 | +\begin{itemdescr} |
| 972 | +\pnum |
| 973 | +\expects |
| 974 | +\tcode{T} is \oldconcept{CopyInsertable} into \tcode{X}. |
| 975 | + |
| 976 | +\pnum |
| 977 | +\ensures |
| 978 | +\tcode{u == t}, \tcode{u.get_allocator() == m} |
| 979 | + |
| 980 | +\pnum |
| 981 | +\complexity |
| 982 | +Linear. |
| 983 | +\end{itemdescr} |
| 984 | + |
| 985 | +\begin{itemdecl} |
| 986 | +X u(rv); |
| 987 | +\end{itemdecl} |
| 988 | + |
| 989 | +\begin{itemdescr} |
| 990 | +\pnum |
| 991 | +\ensures |
| 992 | +\tcode{u} has the same elements as \tcode{rv} had before this construction; |
| 993 | +the value of \tcode{u.get_allocator()} is the same as |
| 994 | +the value of \tcode{rv.get_allocator()} before this construction. |
| 995 | + |
| 996 | +\pnum |
| 997 | +\complexity |
| 998 | +Constant. |
| 999 | +\end{itemdescr} |
| 1000 | + |
| 1001 | +\begin{itemdecl} |
| 1002 | +X u(rv, m); |
| 1003 | +\end{itemdecl} |
| 1004 | + |
| 1005 | +\begin{itemdescr} |
| 1006 | +\pnum |
| 1007 | +\expects |
| 1008 | +\tcode{T} is \oldconcept{MoveInsertable} into \tcode{X}. |
| 1009 | + |
| 1010 | +\pnum |
| 1011 | +\ensures |
| 1012 | +\tcode{u} has the same elements, or copies of the elements, |
| 1013 | +that \tcode{rv} had before this construction, |
| 1014 | +\tcode{u.get_allocator() == m}. |
| 1015 | + |
| 1016 | +\pnum |
| 1017 | +\complexity |
| 1018 | +Constant if \tcode{m == rv.get_allocator()}, otherwise linear. |
| 1019 | +\end{itemdescr} |
| 1020 | + |
| 1021 | +\begin{itemdecl} |
| 1022 | +a = t |
| 1023 | +\end{itemdecl} |
| 1024 | + |
| 1025 | +\begin{itemdescr} |
| 1026 | +\pnum |
| 1027 | +\result |
| 1028 | +An lvalue of type \tcode{X}. |
| 1029 | + |
| 1030 | +\pnum |
| 1031 | +\expects |
| 1032 | +\tcode{T} is \oldconcept{CopyInsertable} into \tcode{X} and |
| 1033 | +\oldconcept{CopyAssignable}. |
| 1034 | + |
| 1035 | +\pnum |
| 1036 | +\ensures |
| 1037 | +\tcode{a == t} is \tcode{true}. |
| 1038 | + |
| 1039 | +\pnum |
| 1040 | +\complexity |
| 1041 | +Linear. |
| 1042 | +\end{itemdescr} |
| 1043 | + |
| 1044 | +\begin{itemdecl} |
| 1045 | +a = rv |
| 1046 | +\end{itemdecl} |
| 1047 | + |
| 1048 | +\begin{itemdescr} |
| 1049 | +\pnum |
| 1050 | +\result |
| 1051 | +An lvalue of type \tcode{X}. |
| 1052 | + |
| 1053 | +\pnum |
| 1054 | +\expects |
| 1055 | +If |
| 1056 | +\tcode{allocator_traits<allocator_type>::propagate_on_container_move_assign\-ment::value} |
| 1057 | +is \tcode{false}, |
| 1058 | +\tcode{T} is \oldconcept{MoveInsertable} into \tcode{X} and |
| 1059 | +\oldconcept{MoveAssignable}. |
| 1060 | + |
| 1061 | +\pnum |
| 1062 | +\effects |
| 1063 | +All existing elements of \tcode{a} are either move assigned to or destroyed. |
| 1064 | + |
| 1065 | +\pnum |
| 1066 | +\ensures |
| 1067 | +If \tcode{a} and \tcode{rv} do not refer to the same object, |
| 1068 | +\tcode{a} is equal to the value that \tcode{rv} had before this assignment. |
| 1069 | + |
| 1070 | +\pnum |
| 1071 | +\complexity |
| 1072 | +Linear. |
| 1073 | +\end{itemdescr} |
| 1074 | + |
| 1075 | +\begin{itemdecl} |
| 1076 | +a.swap(b) |
| 1077 | +\end{itemdecl} |
| 1078 | + |
| 1079 | +\begin{itemdescr} |
| 1080 | +\pnum |
| 1081 | +\result |
| 1082 | +\keyword{void} |
| 1083 | + |
| 1084 | +\pnum |
| 1085 | +\effects |
| 1086 | +Exchanges the contents of \tcode{a} and \tcode{b}. |
| 1087 | + |
| 1088 | +\pnum |
| 1089 | +\complexity |
| 1090 | +Constant. |
| 1091 | +\end{itemdescr} |
1003 | 1092 |
|
1004 | 1093 | \pnum
|
1005 | 1094 | The behavior of certain container member functions and deduction guides
|
|
0 commit comments