mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-07-02 14:04:09 +00:00
add doc: substr
This commit is contained in:
parent
5f453b10f6
commit
8abdca1749
16 changed files with 1187 additions and 15 deletions
75
source/libs/string/basic_string/assign-iterator.rst
Normal file
75
source/libs/string/basic_string/assign-iterator.rst
Normal file
|
@ -0,0 +1,75 @@
|
|||
.. _sprout-string-basic_string-assign-iterator:
|
||||
###############################################################################
|
||||
assign
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<typename StringConstIterator>
|
||||
basic_string& assign(StringConstIterator s, size_type n);
|
||||
|
||||
Requires
|
||||
========================================
|
||||
|
||||
| s points to an array of at least n elements of value_type.
|
||||
|
||||
Effects
|
||||
========================================
|
||||
|
||||
| Replaces the string controlled by *this with a string of length n whose elements are a copy of those pointed to by s.
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| ``*this``.
|
||||
|
||||
Throws
|
||||
========================================
|
||||
|
||||
| std::length_error if ``n > max_size()``.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
#include <sprout/assert.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
auto x = string<8>("homuhomu");
|
||||
SPROUT_STATIC_CONSTEXPR auto y = string<8>("madocchi");
|
||||
x.assign(y.begin(), 8);
|
||||
SPROUT_ASSERT_MSG(x == y, "y is assigned to x.");
|
||||
|
||||
----
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<typename StringConstIterator>
|
||||
basic_string& assign(StringConstIterator s);
|
||||
|
||||
Requires
|
||||
========================================
|
||||
|
||||
| s points to an array of at least ``traits_type::length(s) + 1`` elements of value_type.
|
||||
|
||||
Effects
|
||||
========================================
|
||||
|
||||
| Calls ``assign(s, traits_type::length(s))``.
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| ``*this``.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
46
source/libs/string/basic_string/operator-assign-iterator.rst
Normal file
46
source/libs/string/basic_string/operator-assign-iterator.rst
Normal file
|
@ -0,0 +1,46 @@
|
|||
.. _sprout-string-basic_string-operator-assign-iterator:
|
||||
###############################################################################
|
||||
operator=
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<typename StringConstIterator>
|
||||
basic_string& operator=(StringConstIterator rhs);
|
||||
|
||||
Requires
|
||||
========================================
|
||||
|
||||
| ``std::is_same<StringConstIterator, const_iterator>::value || std::is_same<StringConstIterator, iterator>::value``.
|
||||
|
||||
Effects
|
||||
========================================
|
||||
|
||||
| Equivalent to ``assign(rhs)``.
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| ``*this``.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/array.hpp>
|
||||
#include <sprout/assert.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
auto x = string<8>("homuhomu");
|
||||
SPROUT_STATIC_CONSTEXPR auto y = string<8>("madocchi");
|
||||
x = y.begin();
|
||||
SPROUT_ASSERT_MSG(x == y, "y is assigned to x.");
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
.. _sprout-string-basic_string-operator-std-basic_string:
|
||||
###############################################################################
|
||||
operator std::basic_string
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<typename Allocator>
|
||||
SPROUT_EXPLICIT_CONVERSION operator std::basic_string<T, Traits, Allocator>() const;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| conversion to std::basic_string.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
#include <sprout/assert.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto x = string<8>("homuhomu");
|
||||
auto y = static_cast<std::string>(x);
|
||||
SPROUT_ASSERT_MASG(x == y.c_str(), "y is converted from x.");
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
44
source/libs/string/basic_string/substr.rst
Normal file
44
source/libs/string/basic_string/substr.rst
Normal file
|
@ -0,0 +1,44 @@
|
|||
.. _sprout-string-basic_string-substr:
|
||||
###############################################################################
|
||||
substr
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
SPROUT_CONSTEXPR basic_string substr(size_type pos = 0, size_type n = npos) const;
|
||||
|
||||
Requires
|
||||
========================================
|
||||
|
||||
| ``pos <= size()``.
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| ``basic_string(data() + pos, rlen)`` when rlen is the smaller of n and ``size() - pos``.
|
||||
|
||||
Throws
|
||||
========================================
|
||||
|
||||
| std::out_of_range if ``pos > size()``.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
#include <sprout/assert.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto x = string<8>("homuhomu");
|
||||
SPROUT_STATIC_CONSTEXPR auto y = x.substr(4, 4);
|
||||
SPROUT_ASSERT_MASG(y == "homu", "y is substring of x.");
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue