mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-04 14:14:09 +00:00
add doc: basic_string (array compatible)
This commit is contained in:
parent
260291ea69
commit
7b0f0541e3
68 changed files with 4688 additions and 50 deletions
44
source/libs/string/basic_string/at.rst
Normal file
44
source/libs/string/basic_string/at.rst
Normal file
|
@ -0,0 +1,44 @@
|
|||
.. _sprout-string-basic_string-at:
|
||||
###############################################################################
|
||||
at
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
reference at(size_type n);
|
||||
|
||||
SPROUT_CONSTEXPR const_reference at(size_type n) const;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| The element at the specified position in the string.
|
||||
|
||||
Throws
|
||||
========================================
|
||||
|
||||
| It throws std::out_of_range if n is out of bounds.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = string<8>("homuhomu");
|
||||
static_assert(input.at(4) == 'h', "an element at position 5 is h.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| Recursive function invocations in *O(1)* (constant) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
39
source/libs/string/basic_string/back.rst
Normal file
39
source/libs/string/basic_string/back.rst
Normal file
|
@ -0,0 +1,39 @@
|
|||
.. _sprout-string-basic_string-back:
|
||||
###############################################################################
|
||||
back
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
reference back();
|
||||
|
||||
SPROUT_CONSTEXPR const_reference back() const;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| A reference to the last element in the string.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = string<8>("homuhomu");
|
||||
static_assert(input.back() == 'u', "a last element is u.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| Recursive function invocations in *O(1)* (constant) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
39
source/libs/string/basic_string/begin.rst
Normal file
39
source/libs/string/basic_string/begin.rst
Normal file
|
@ -0,0 +1,39 @@
|
|||
.. _sprout-string-basic_string-begin:
|
||||
###############################################################################
|
||||
begin
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
iterator begin() SPROUT_NOEXCEPT;
|
||||
|
||||
SPROUT_CONSTEXPR const_iterator begin() const SPROUT_NOEXCEPT;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| iterator for the first element.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = string<8>("homuhomu");
|
||||
static_assert(*input.begin() == 'h', "input first element is h.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| Recursive function invocations in *O(1)* (constant) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
39
source/libs/string/basic_string/c_array.rst
Normal file
39
source/libs/string/basic_string/c_array.rst
Normal file
|
@ -0,0 +1,39 @@
|
|||
.. _sprout-string-basic_string-c_array:
|
||||
###############################################################################
|
||||
back
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
pointer c_array() SPROUT_NOEXCEPT;
|
||||
|
||||
SPROUT_CONSTEXPR const_pointer c_array() const SPROUT_NOEXCEPT;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| Pointer to the data contained by the string.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = string<8>("homuhomu");
|
||||
static_assert(input.c_array()[0] == 'h', "a first element is h.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| Recursive function invocations in *O(1)* (constant) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
37
source/libs/string/basic_string/cbegin.rst
Normal file
37
source/libs/string/basic_string/cbegin.rst
Normal file
|
@ -0,0 +1,37 @@
|
|||
.. _sprout-string-basic_string-cbegin:
|
||||
###############################################################################
|
||||
cbegin
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
SPROUT_CONSTEXPR const_iterator cbegin() const SPROUT_NOEXCEPT;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| iterator for the first element always const.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = string<8>("homuhomu");
|
||||
static_assert(*input.cbegin() == 'h', "input first element is h.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| Recursive function invocations in *O(1)* (constant) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
37
source/libs/string/basic_string/cend.rst
Normal file
37
source/libs/string/basic_string/cend.rst
Normal file
|
@ -0,0 +1,37 @@
|
|||
.. _sprout-string-basic_string-cbegin:
|
||||
###############################################################################
|
||||
cbegin
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
SPROUT_CONSTEXPR const_iterator cbegin() const SPROUT_NOEXCEPT;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| iterator for position after the last element always const.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = string<8>("homuhomu");
|
||||
static_assert(*(input.cbegin() - 1) == 'u', "input last element is u.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| Recursive function invocations in *O(1)* (constant) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
37
source/libs/string/basic_string/crbegin.rst
Normal file
37
source/libs/string/basic_string/crbegin.rst
Normal file
|
@ -0,0 +1,37 @@
|
|||
.. _sprout-string-basic_string-crbegin:
|
||||
###############################################################################
|
||||
crbegin
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
SPROUT_CONSTEXPR const_reverse_iterator crbegin() const SPROUT_NOEXCEPT;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| reverse iterator for the first element of reverse iteration always const.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = string<8>("homuhomu");
|
||||
static_assert(*input.crbegin() == 'u', "input first element of reverse iteration is u.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| Recursive function invocations in *O(1)* (constant) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
37
source/libs/string/basic_string/crend.rst
Normal file
37
source/libs/string/basic_string/crend.rst
Normal file
|
@ -0,0 +1,37 @@
|
|||
.. _sprout-string-basic_string-crend:
|
||||
###############################################################################
|
||||
crend
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
SPROUT_CONSTEXPR const_reverse_iterator crend() const SPROUT_NOEXCEPT;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| reverse iterator for position after the last element in reverse iteration always const.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = string<8>("homuhomu");
|
||||
static_assert(*(input.crend() - 1) == 'h', "input last element of reverse iteration is h.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| Recursive function invocations in *O(1)* (constant) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
39
source/libs/string/basic_string/data.rst
Normal file
39
source/libs/string/basic_string/data.rst
Normal file
|
@ -0,0 +1,39 @@
|
|||
.. _sprout-string-basic_string-data:
|
||||
###############################################################################
|
||||
back
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
pointer data() SPROUT_NOEXCEPT;
|
||||
|
||||
SPROUT_CONSTEXPR const_pointer data() const SPROUT_NOEXCEPT;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| Pointer to the data contained by the string.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = string<8>("homuhomu");
|
||||
static_assert(input.data()[0] == 'h', "a first element is h.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| Recursive function invocations in *O(1)* (constant) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
37
source/libs/string/basic_string/empty.rst
Normal file
37
source/libs/string/basic_string/empty.rst
Normal file
|
@ -0,0 +1,37 @@
|
|||
.. _sprout-string-basic_string-empty:
|
||||
###############################################################################
|
||||
empty
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
SPROUT_CONSTEXPR bool empty() const SPROUT_NOEXCEPT;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| true if the array size is 0, false otherwise.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = string<8>("");
|
||||
static_assert(input.empty(), "input is empty.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| Recursive function invocations in *O(1)* (constant) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
39
source/libs/string/basic_string/end.rst
Normal file
39
source/libs/string/basic_string/end.rst
Normal file
|
@ -0,0 +1,39 @@
|
|||
.. _sprout-string-basic_string-end:
|
||||
###############################################################################
|
||||
end
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
iterator end() SPROUT_NOEXCEPT;
|
||||
|
||||
SPROUT_CONSTEXPR const_iterator end() const SPROUT_NOEXCEPT;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| iterator for position after the last element.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = string<8>("homuhomu");
|
||||
static_assert(*(input.end() - 1) == 'u', "input last element is u.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| Recursive function invocations in *O(1)* (constant) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
39
source/libs/string/basic_string/front.rst
Normal file
39
source/libs/string/basic_string/front.rst
Normal file
|
@ -0,0 +1,39 @@
|
|||
.. _sprout-string-basic_string-front:
|
||||
###############################################################################
|
||||
front
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
reference front();
|
||||
|
||||
SPROUT_CONSTEXPR const_reference front() const;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| A reference to the first element in the string.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = string<8>("homuhomu");
|
||||
static_assert(input.front() == 'h', "a first element is h.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| Recursive function invocations in *O(1)* (constant) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
|
@ -303,8 +303,8 @@ Interface of all
|
|||
basic_string& assign(value_type const* s, size_type n);
|
||||
basic_string& assign(value_type const* s);
|
||||
basic_string& assign(size_type n, value_type c);
|
||||
template<typename Iterator>
|
||||
basic_string& assign(Iterator first, Iterator last);
|
||||
template<typename InputIterator>
|
||||
basic_string& assign(InputIterator first, InputIterator last);
|
||||
void swap(basic_string& other) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::swap(std::declval<T&>(), std::declval<T&>())));
|
||||
|
||||
// string operations:
|
||||
|
|
37
source/libs/string/basic_string/max_size.rst
Normal file
37
source/libs/string/basic_string/max_size.rst
Normal file
|
@ -0,0 +1,37 @@
|
|||
.. _sprout-string-basic_string-max_size:
|
||||
###############################################################################
|
||||
max_size
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
SPROUT_CONSTEXPR size_type max_size() const SPROUT_NOEXCEPT;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| The number of elements contained in the string.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = string<8>("homuhomu");
|
||||
static_assert(input.max_size() == 8, "input max size is 8.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| Recursive function invocations in *O(1)* (constant) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
44
source/libs/string/basic_string/operator-subscript.rst
Normal file
44
source/libs/string/basic_string/operator-subscript.rst
Normal file
|
@ -0,0 +1,44 @@
|
|||
.. _sprout-string-basic_string-operator-subscript:
|
||||
###############################################################################
|
||||
operator[]
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
reference operator[](size_type n);
|
||||
|
||||
SPROUT_CONSTEXPR const_reference operator[](size_type n) const;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| The element at the specified position in the string.
|
||||
|
||||
Remarks
|
||||
========================================
|
||||
|
||||
| It causes undefined behavior if n is out of bounds.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = string<8>("homuhomu");
|
||||
static_assert(input[4] == 'h', "an element at position 4 is h.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| Recursive function invocations in *O(1)* (constant) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
39
source/libs/string/basic_string/rbegin.rst
Normal file
39
source/libs/string/basic_string/rbegin.rst
Normal file
|
@ -0,0 +1,39 @@
|
|||
.. _sprout-string-basic_string-rbegin:
|
||||
###############################################################################
|
||||
rbegin
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
reverse_iterator rbegin() SPROUT_NOEXCEPT;
|
||||
|
||||
SPROUT_CONSTEXPR const_reverse_iterator rbegin() const SPROUT_NOEXCEPT;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| reverse iterator for the first element of reverse iteration.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = string<8>("homuhomu");
|
||||
static_assert(*input.rbegin() == 'u', "input first element of reverse iteration is u.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| Recursive function invocations in *O(1)* (constant) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
39
source/libs/string/basic_string/rend.rst
Normal file
39
source/libs/string/basic_string/rend.rst
Normal file
|
@ -0,0 +1,39 @@
|
|||
.. _sprout-string-basic_string-rend:
|
||||
###############################################################################
|
||||
rend
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
reverse_iterator rend() SPROUT_NOEXCEPT;
|
||||
|
||||
SPROUT_CONSTEXPR const_reverse_iterator rend() const SPROUT_NOEXCEPT;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| reverse iterator for position after the last element in reverse iteration.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = string<8>("homuhomu");
|
||||
static_assert(*(input.rend() - 1) == 'h', "input last element of reverse iteration is h.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| Recursive function invocations in *O(1)* (constant) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
37
source/libs/string/basic_string/size.rst
Normal file
37
source/libs/string/basic_string/size.rst
Normal file
|
@ -0,0 +1,37 @@
|
|||
.. _sprout-string-basic_string-size:
|
||||
###############################################################################
|
||||
size
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
SPROUT_CONSTEXPR size_type size() const SPROUT_NOEXCEPT;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| The number of elements contained in the string.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = string<8>("homuhomu");
|
||||
static_assert(input.size() == 8, "input size is 8.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| Recursive function invocations in *O(1)* (constant) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
45
source/libs/string/basic_string/swap.rst
Normal file
45
source/libs/string/basic_string/swap.rst
Normal file
|
@ -0,0 +1,45 @@
|
|||
.. _sprout-string-basic_string-swap:
|
||||
###############################################################################
|
||||
swap
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
void swap(basic_string& s) SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::swap(std::declval<T&>(), std::declval<T&>())));
|
||||
|
||||
Postcondition
|
||||
========================================
|
||||
|
||||
| ``*this`` contains the same sequence of characters that was in s, s contains the same sequence of characters that was in ``*this``.
|
||||
|
||||
Throws
|
||||
========================================
|
||||
|
||||
| Nothing unless one of the element-wise swap calls throws an exception.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
#include <sprout/assert.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
auto x = string<8>("homuhomu");
|
||||
auto y = string<8>("madocchi");
|
||||
swap(x, y);
|
||||
SPROUT_ASSERT_MSG(x == "madocchi" && y == "homuhomu", "each element are swapped.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| linear.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue