|
868 | 868 | constexpr size_type max_size() const noexcept;
|
869 | 869 | constexpr void resize(size_type n, charT c);
|
870 | 870 | constexpr void resize(size_type n);
|
| 871 | + template<class Operation> constexpr void resize_and_overwrite(size_type n, Operation op); |
871 | 872 | constexpr size_type capacity() const noexcept;
|
872 | 873 | constexpr void reserve(size_type res_arg);
|
873 | 874 | constexpr void shrink_to_fit();
|
|
1109 | 1110 | the type \tcode{traits} shall meet
|
1110 | 1111 | the character traits requirements\iref{char.traits}.
|
1111 | 1112 | \begin{note}
|
| 1113 | +Every specialization \tcode{basic_string<charT, traits, Allocator>} is |
| 1114 | +an allocator-aware container, |
| 1115 | +but does not use the allocator's \tcode{construct} and \tcode{destroy} |
| 1116 | +member functions\iref{container.requirements.general}. |
| 1117 | +\end{note} |
| 1118 | +\begin{note} |
1112 | 1119 | The program is ill-formed if \tcode{traits::char_type}
|
1113 | 1120 | is not the same type as \tcode{charT}.
|
1114 | 1121 | \end{note}
|
|
1609 | 1616 | Equivalent to \tcode{resize(n, charT())}.
|
1610 | 1617 | \end{itemdescr}
|
1611 | 1618 |
|
| 1619 | +\indexlibrarymember{resize_and_overwrite}{basic_string}% |
| 1620 | +\begin{itemdecl} |
| 1621 | +template<class Operation> constexpr void resize_and_overwrite(size_type n, Operation op); |
| 1622 | +\end{itemdecl} |
| 1623 | + |
| 1624 | +\begin{itemdescr} |
| 1625 | +\pnum |
| 1626 | +Let |
| 1627 | +\begin{itemize} |
| 1628 | +\item |
| 1629 | +\tcode{o = size()} before the call to \tcode{resize_and_overwrite}. |
| 1630 | +\item |
| 1631 | +\tcode{k} be \tcode{min(o, n)}. |
| 1632 | +\item |
| 1633 | +\tcode{p} be a \tcode{charT*}, |
| 1634 | +such that the range \crange{p}{p + n} is valid and |
| 1635 | +\tcode{this->compare(0, k, p, k) == 0} is \tcode{true} before the call. |
| 1636 | +The values in the range \crange{p + k}{p + n} may be indeterminate\iref{basic.indet}. |
| 1637 | +\item |
| 1638 | +$OP$ be the expression \tcode{std::move(op)(p, n)}. |
| 1639 | +\item |
| 1640 | +\tcode{r} = $OP$. |
| 1641 | +\end{itemize} |
| 1642 | + |
| 1643 | +\pnum |
| 1644 | +\mandates |
| 1645 | +$OP$ has an integer-like type\iref{iterator.concept.winc}. |
| 1646 | + |
| 1647 | +\pnum |
| 1648 | +\expects |
| 1649 | +\begin{itemize} |
| 1650 | +\item |
| 1651 | +$OP$ does not throw an exception or modify \tcode{p} or \tcode{n}. |
| 1652 | +\item |
| 1653 | +$\tcode{r} \geq 0$. |
| 1654 | +\item |
| 1655 | +$\tcode{r} \leq \tcode{n}$. |
| 1656 | +\item |
| 1657 | +After evaluating $OP$ |
| 1658 | +there are no indeterminate values in the range \range{p}{p + r}. |
| 1659 | +\end{itemize} |
| 1660 | + |
| 1661 | +\pnum |
| 1662 | +\effects |
| 1663 | +Evaluates $OP$, |
| 1664 | +replaces the contents of \tcode{*this} with \range{p}{p + r}, and |
| 1665 | +invalidates all pointers and references to the range \crange{p}{p + n}. |
| 1666 | + |
| 1667 | +\pnum |
| 1668 | +\recommended |
| 1669 | +Implementations should avoid unnecessary copies and allocations |
| 1670 | +by, for example, making \tcode{p} a pointer into internal storage and |
| 1671 | +by restoring \tcode{*(p + r)} to \tcode{charT()} after evaluating $OP$. |
| 1672 | +\end{itemdescr} |
| 1673 | + |
1612 | 1674 | \indexlibrarymember{capacity}{basic_string}%
|
1613 | 1675 | \begin{itemdecl}
|
1614 | 1676 | constexpr size_type capacity() const noexcept;
|
|
0 commit comments