|
718 | 718 | model \libconcept{contiguous_iterator}\iref{iterator.concept.contiguous}.
|
719 | 719 |
|
720 | 720 | \pnum
|
721 |
| -\tref{container.opt} lists operations that are provided |
| 721 | +The following operations are provided |
722 | 722 | for some types of containers but not others. Those containers for which the
|
723 |
| -listed operations are provided shall implement the semantics described in |
724 |
| -\tref{container.opt} unless otherwise stated. |
| 723 | +listed operations are provided shall implement the semantics as described |
| 724 | +unless otherwise stated. |
725 | 725 | If the iterators passed to \tcode{lexicographical_compare_three_way}
|
726 | 726 | meet the constexpr iterator requirements\iref{iterator.requirements.general}
|
727 |
| -then the operations described in \tref{container.opt} |
| 727 | +then the operations described below |
728 | 728 | are implemented by constexpr functions.
|
729 | 729 |
|
730 |
| -\begin{libreqtab5} |
731 |
| -{Optional container operations} |
732 |
| -{container.opt} |
733 |
| -\\ \topline |
734 |
| -\lhdr{Expression} & \chdr{Return type} & \chdr{Operational} & |
735 |
| -\chdr{Assertion/note} & \rhdr{Complexity} \\ |
736 |
| - & & \chdr{semantics} & \chdr{pre-/post-condition} & \\ \capsep |
737 |
| -\endfirsthead |
738 |
| -\continuedcaption\\ |
739 |
| -\topline |
740 |
| -\lhdr{Expression} & \chdr{Return type} & \chdr{Operational} & |
741 |
| -\chdr{Assertion/note} & \rhdr{Complexity} \\ |
742 |
| - & & \chdr{semantics} & \chdr{pre-/post-condition} & \\ \capsep |
743 |
| -\endhead |
| 730 | +\begin{itemexpr} |
| 731 | +a <=> b |
| 732 | +\end{itemexpr} |
744 | 733 |
|
745 |
| -\tcode{a <=> b} & |
746 |
| - \tcode{\placeholdernc{synth-three-\brk{}way-result}\brk{}<value_type>} & |
747 |
| - \tcode{lexicographical_compare_three_way(a.begin(), a.end(), |
748 |
| - b.begin(), b.end(), \placeholdernc{synth-three-way})} & |
749 |
| - \expects |
750 |
| - Either \tcode{<=>} is defined for values of type (possibly const) \tcode{T}, |
751 |
| - or \tcode{<} is defined for values of type (possibly const) \tcode{T} and |
752 |
| - \tcode{<} is a total ordering relationship. & |
753 |
| - linear \\ |
754 |
| -\end{libreqtab5} |
| 734 | +\begin{itemdescr} |
| 735 | +\pnum |
| 736 | +\result |
| 737 | +\tcode{\exposid{synth-three-way-result}<X::value_type>} |
755 | 738 |
|
| 739 | +\pnum |
| 740 | +\expects |
| 741 | +Either \tcode{<=>} is defined for values of type (possibly const) \tcode{T}, |
| 742 | +or \tcode{<} is defined for values of type (possibly const) \tcode{T} and |
| 743 | +\tcode{<} is a total ordering relationship. |
| 744 | + |
| 745 | +\pnum |
| 746 | +\cvalue |
| 747 | +\tcode{lexicographical_compare_three_way(a.begin(), a.end(), |
| 748 | +b.begin(), b.end(),\newline \exposidnc{synth-three-way})} |
756 | 749 | \begin{note}
|
757 | 750 | The algorithm \tcode{lexicographical_compare_three_way}
|
758 | 751 | is defined in \ref{algorithms}.
|
759 | 752 | \end{note}
|
760 | 753 |
|
| 754 | +\pnum |
| 755 | +\complexity |
| 756 | +Linear. |
| 757 | +\end{itemdescr} |
| 758 | + |
761 | 759 | \pnum
|
762 | 760 | All of the containers defined in this Clause and in~\ref{basic.string} except \tcode{array}
|
763 |
| -meet the additional requirements of an allocator-aware container, as described in |
764 |
| -\tref{container.alloc.req}. |
| 761 | +meet the additional requirements of an \defnadj{allocator-aware}{container}, |
| 762 | +as described below. |
765 | 763 |
|
766 | 764 | \pnum
|
767 | 765 | Given an allocator type \tcode{A}
|
|
849 | 847 | \end{note}
|
850 | 848 |
|
851 | 849 | \pnum
|
852 |
| -In \tref{container.alloc.req}, |
| 850 | +In this subclause, |
853 | 851 | \begin{itemize}
|
854 | 852 | \item
|
855 | 853 | \tcode{X} denotes an allocator-aware container class
|
856 |
| -with a \tcode{value_type} of \tcode{T} using allocator of type \tcode{A}, |
| 854 | +with a \tcode{value_type} of \tcode{T} using an allocator of type \tcode{A}, |
857 | 855 | \item
|
858 | 856 | \tcode{u} denotes a variable,
|
859 | 857 | \item
|
860 | 858 | \tcode{a} and \tcode{b} denote non-const lvalues of type \tcode{X},
|
861 | 859 | \item
|
| 860 | +\tcode{c} denotes an lvalue of type \tcode{\keyword{const} X}. |
| 861 | +\item |
862 | 862 | \tcode{t} denotes an lvalue or a const rvalue of type \tcode{X},
|
863 | 863 | \item
|
864 | 864 | \tcode{rv} denotes a non-const rvalue of type \tcode{X}, and
|
865 | 865 | \item
|
866 | 866 | \tcode{m} is a value of type \tcode{A}.
|
867 | 867 | \end{itemize}
|
868 | 868 |
|
869 |
| -\begin{libreqtab4a} |
870 |
| -{Allocator-aware container requirements} |
871 |
| -{container.alloc.req} |
872 |
| -\\ \topline |
873 |
| -\lhdr{Expression} & \chdr{Return type} & |
874 |
| -\chdr{Assertion/note} & \rhdr{Complexity} \\ |
875 |
| - & & \chdr{pre-/post-condition} & \\ \capsep |
876 |
| -\endfirsthead |
877 |
| -\continuedcaption\\ |
878 |
| -\hline |
| 869 | +A type \tcode{X} meets the allocator-aware container requirements |
| 870 | +if \tcode{X} meets the container requirements and |
| 871 | +the following types and expressions are well-formed and have |
| 872 | +the specified semantics. |
| 873 | +\begin{itemize} |
| 874 | +\item |
| 875 | +\tcode{X::allocator_type} denotes the type \tcode{A}. |
| 876 | +\tcode{allocator_type::value_type} is the same as \tcode{X::value_type}. |
| 877 | +\end{itemize} |
879 | 878 |
|
880 |
| -\lhdr{Expression} & \chdr{Return type} & |
881 |
| -\chdr{Assertion/note} & \rhdr{Complexity} \\ |
882 |
| - & & \chdr{pre-/post-condition} & \\ \capsep |
883 |
| -\endhead |
| 879 | +\begin{itemexpr} |
| 880 | +c.get_allocator() |
| 881 | +\end{itemexpr} |
884 | 882 |
|
885 |
| -\tcode{allocator_type} & |
886 |
| - \tcode{A} & |
887 |
| - \mandates \tcode{allocator_type::value_type} is the same as \tcode{X::value_type}. & |
888 |
| - compile time \\ \rowsep |
889 |
| - |
890 |
| -\tcode{get_-} \tcode{allocator()} & |
891 |
| - \tcode{A} & |
892 |
| - & |
893 |
| - constant \\ \rowsep |
894 |
| - |
895 |
| -\tcode{X()}\br |
896 |
| -\tcode{X u;} & |
897 |
| - & |
898 |
| - \expects \tcode{A} meets the \oldconcept{DefaultConstructible} requirements.\br |
899 |
| - \ensures \tcode{u.empty()} returns \tcode{true}, |
900 |
| - \tcode{u.get_allocator() == A()} & |
901 |
| - constant \\ \rowsep |
902 |
| - |
903 |
| -\tcode{X(m)} & |
904 |
| - & |
905 |
| - \ensures |
906 |
| - \tcode{u.empty()} returns \tcode{true}, & |
907 |
| - constant \\ |
908 |
| -\tcode{X u(m);} & |
909 |
| - & |
910 |
| -\tcode{u.get_allocator() == m} & |
911 |
| - \\ \rowsep |
912 |
| - |
913 |
| -\tcode{X(t, m)}\br |
914 |
| -\tcode{X u(t, m);} & |
915 |
| - & |
916 |
| - \expects |
917 |
| - \tcode{T} is \oldconcept{CopyInsertable} into \tcode{X}.\br |
918 |
| - \ensures |
919 |
| - \tcode{u == t}, \tcode{u.get_allocator() == m} & |
920 |
| - linear \\ \rowsep |
921 |
| - |
922 |
| -\tcode{X(rv)}\br |
923 |
| -\tcode{X u(rv);} |
924 |
| - & |
925 |
| - & |
926 |
| - \ensures \tcode{u} has the same elements as \tcode{rv} had before this |
927 |
| - construction; the value of \tcode{u.get_allocator()} is the same as the |
928 |
| - value of \tcode{rv.get_allocator()} before this construction. & |
929 |
| - constant \\ \rowsep |
930 |
| - |
931 |
| -\tcode{X(rv, m)}\br |
932 |
| -\tcode{X u(rv, m);} & |
933 |
| - & |
934 |
| - \expects \tcode{T} is |
935 |
| - \oldconcept{MoveInsertable} into \tcode{X}.\br |
936 |
| - \ensures \tcode{u} has the same elements, |
937 |
| - or copies of the elements, that \tcode{rv} had before |
938 |
| - this construction, \tcode{u.get_allocator() == m} & |
939 |
| - constant if \tcode{m ==} \tcode{rv.get_allocator()}, otherwise linear \\ \rowsep |
940 |
| - |
941 |
| -\tcode{a = t} & |
942 |
| - \tcode{X\&} & |
943 |
| - \expects \tcode{T} is |
944 |
| - \oldconcept{CopyInsertable} into \tcode{X} |
945 |
| - and \oldconcept{CopyAssignable}.\br |
946 |
| - \ensures \tcode{a == t} & |
947 |
| - linear \\ \rowsep |
948 |
| - |
949 |
| -\tcode{a = rv} & |
950 |
| - \tcode{X\&} & |
951 |
| - \expects If \tcode{allocator_-}\br |
952 |
| - \tcode{traits<allocator_type>}\br |
953 |
| - \tcode{::propagate_on_container_-}\br |
954 |
| - \tcode{move_assignment::value} is\br |
955 |
| - \tcode{false}, \tcode{T} is |
956 |
| - \oldconcept{MoveInsertable} into \tcode{X} and |
957 |
| - \oldconcept{MoveAssignable}.\br |
958 |
| - \effects All existing elements of \tcode{a} |
959 |
| - are either move assigned to or destroyed.\br |
960 |
| - \ensures If \tcode{a} and \tcode{rv} do not refer to the same object, |
961 |
| - \tcode{a} is equal to the value that \tcode{rv} had before |
962 |
| - this assignment. & |
963 |
| - linear \\ \rowsep |
964 |
| - |
965 |
| -\tcode{a.swap(b)} & |
966 |
| - \keyword{void} & |
967 |
| - \effects exchanges the contents of \tcode{a} and \tcode{b} & |
968 |
| - constant \\ \rowsep |
| 883 | +\begin{itemdescr} |
| 884 | +\pnum |
| 885 | +\result |
| 886 | +\tcode{A} |
969 | 887 |
|
970 |
| -\end{libreqtab4a} |
| 888 | +\pnum |
| 889 | +\complexity |
| 890 | +Constant. |
| 891 | +\end{itemdescr} |
| 892 | + |
| 893 | +\begin{itemstmt} |
| 894 | +X() |
| 895 | +X u; |
| 896 | +\end{itemstmt} |
| 897 | + |
| 898 | +\begin{itemdescr} |
| 899 | +\pnum |
| 900 | +\expects |
| 901 | +\tcode{A} meets the \oldconcept{DefaultConstructible} requirements. |
| 902 | + |
| 903 | +\pnum |
| 904 | +\ensures |
| 905 | +\tcode{u.empty()} returns \tcode{true}, \tcode{u.get_allocator() == A()}. |
| 906 | + |
| 907 | +\pnum |
| 908 | +\complexity |
| 909 | +Constant. |
| 910 | +\end{itemdescr} |
| 911 | + |
| 912 | +\begin{itemexpr} |
| 913 | +X(m) |
| 914 | +X u(m); |
| 915 | +\end{itemexpr} |
| 916 | + |
| 917 | +\begin{itemdescr} |
| 918 | +\pnum |
| 919 | +\ensures |
| 920 | +\tcode{u.empty()} returns \tcode{true}, \tcode{u.get_allocator() == m}. |
| 921 | + |
| 922 | +\pnum |
| 923 | +\complexity |
| 924 | +Constant. |
| 925 | +\end{itemdescr} |
| 926 | + |
| 927 | +\begin{itemstmt} |
| 928 | +X(t, m) |
| 929 | +X u(t, m); |
| 930 | +\end{itemstmt} |
| 931 | + |
| 932 | +\begin{itemdescr} |
| 933 | +\pnum |
| 934 | +\expects |
| 935 | +\tcode{T} is \oldconcept{CopyInsertable} into \tcode{X}. |
| 936 | + |
| 937 | +\pnum |
| 938 | +\ensures |
| 939 | +\tcode{u == t}, \tcode{u.get_allocator() == m} |
| 940 | + |
| 941 | +\pnum |
| 942 | +\complexity |
| 943 | +Linear. |
| 944 | +\end{itemdescr} |
| 945 | + |
| 946 | +\begin{itemstmt} |
| 947 | +X(rv) |
| 948 | +X u(rv); |
| 949 | +\end{itemstmt} |
| 950 | + |
| 951 | +\begin{itemdescr} |
| 952 | +\pnum |
| 953 | +\ensures |
| 954 | +\tcode{u} has the same elements as \tcode{rv} had before this construction; |
| 955 | +the value of \tcode{u.get_allocator()} is the same as |
| 956 | +the value of \tcode{rv.get_allocator()} before this construction. |
| 957 | + |
| 958 | +\pnum |
| 959 | +\complexity |
| 960 | +Constant. |
| 961 | +\end{itemdescr} |
| 962 | + |
| 963 | +\begin{itemstmt} |
| 964 | +X(rv, m) |
| 965 | +X u(rv, m); |
| 966 | +\end{itemstmt} |
| 967 | + |
| 968 | +\begin{itemdescr} |
| 969 | +\pnum |
| 970 | +\expects |
| 971 | +\tcode{T} is \oldconcept{MoveInsertable} into \tcode{X}. |
| 972 | + |
| 973 | +\pnum |
| 974 | +\ensures |
| 975 | +\tcode{u} has the same elements, or copies of the elements, |
| 976 | +that \tcode{rv} had before this construction, |
| 977 | +\tcode{u.get_allocator() == m}. |
| 978 | + |
| 979 | +\pnum |
| 980 | +\complexity |
| 981 | +Constant if \tcode{m == rv.get_allocator()}, otherwise linear. |
| 982 | +\end{itemdescr} |
| 983 | + |
| 984 | +\begin{itemexpr} |
| 985 | +a = t |
| 986 | +\end{itemexpr} |
| 987 | + |
| 988 | +\begin{itemdescr} |
| 989 | +\pnum |
| 990 | +\result |
| 991 | +\tcode{X\&} |
| 992 | + |
| 993 | +\pnum |
| 994 | +\expects |
| 995 | +\tcode{T} is \oldconcept{CopyInsertable} into \tcode{X} and |
| 996 | +\oldconcept{CopyAssignable}. |
| 997 | + |
| 998 | +\pnum |
| 999 | +\ensures |
| 1000 | +\tcode{a == t} is \tcode{true}. |
| 1001 | + |
| 1002 | +\pnum |
| 1003 | +\complexity |
| 1004 | +Linear. |
| 1005 | +\end{itemdescr} |
| 1006 | + |
| 1007 | +\begin{itemexpr} |
| 1008 | +\tcode{a = rv} |
| 1009 | +\end{itemexpr} |
| 1010 | + |
| 1011 | +\begin{itemdescr} |
| 1012 | +\pnum |
| 1013 | +\result |
| 1014 | +\tcode{X\&} |
| 1015 | + |
| 1016 | +\pnum |
| 1017 | +\expects |
| 1018 | +If |
| 1019 | +\tcode{allocator_traits<allocator_type>::propagate_on_container_move_assign\-ment::value} |
| 1020 | +is \tcode{false}, |
| 1021 | +\tcode{T} is \oldconcept{MoveInsertable} into \tcode{X} and |
| 1022 | +\oldconcept{MoveAssignable}. |
| 1023 | + |
| 1024 | +\pnum |
| 1025 | +\effects |
| 1026 | +All existing elements of \tcode{a} are either move assigned to or destroyed. |
| 1027 | + |
| 1028 | +\pnum |
| 1029 | +\ensures |
| 1030 | +If \tcode{a} and \tcode{rv} do not refer to the same object, |
| 1031 | +\tcode{a} is equal to the value that \tcode{rv} had before this assignment. |
| 1032 | + |
| 1033 | +\pnum |
| 1034 | +\complexity |
| 1035 | +Linear. |
| 1036 | +\end{itemdescr} |
| 1037 | + |
| 1038 | +\begin{itemexpr} |
| 1039 | +a.swap(b) |
| 1040 | +\end{itemexpr} |
| 1041 | + |
| 1042 | +\begin{itemdescr} |
| 1043 | +\pnum |
| 1044 | +\result |
| 1045 | +\keyword{void} |
| 1046 | + |
| 1047 | +\pnum |
| 1048 | +\effects |
| 1049 | +Exchanges the contents of \tcode{a} and \tcode{b}. |
| 1050 | + |
| 1051 | +\pnum |
| 1052 | +\complexity |
| 1053 | +Constant. |
| 1054 | +\end{itemdescr} |
971 | 1055 |
|
972 | 1056 | \pnum
|
973 | 1057 | The behavior of certain container member functions and deduction guides
|
|
0 commit comments