mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-07-02 14:04:09 +00:00
fix Issue #49
This commit is contained in:
parent
350e883d35
commit
88ee58bcf4
80 changed files with 1547 additions and 164 deletions
|
@ -40,8 +40,10 @@ Examples
|
|||
|
||||
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.");
|
||||
int main() {
|
||||
x.assign(y.begin(), 8);
|
||||
SPROUT_ASSERT_MSG(x == y, "y is assigned to x.");
|
||||
}
|
||||
|
||||
----
|
||||
|
||||
|
|
|
@ -30,8 +30,10 @@ Examples
|
|||
|
||||
auto x = string<8>("homuhomu");
|
||||
SPROUT_STATIC_CONSTEXPR auto y = string<8>("madocchi");
|
||||
x.assign(y);
|
||||
SPROUT_ASSERT_MSG(x == y, "y is assigned to x.");
|
||||
int main() {
|
||||
x.assign(y);
|
||||
SPROUT_ASSERT_MSG(x == y, "y is assigned to x.");
|
||||
}
|
||||
|
||||
----
|
||||
|
||||
|
|
|
@ -23,8 +23,10 @@ Examples
|
|||
using namespace sprout;
|
||||
|
||||
auto x = string<8>("homuhomu");
|
||||
x.clear();
|
||||
SPROUT_ASSERT_MSG(x.size() == 0 && x == "", "string is cleared.");
|
||||
int main() {
|
||||
x.clear();
|
||||
SPROUT_ASSERT_MSG(x.size() == 0 && x == "", "string is cleared.");
|
||||
}
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
|
66
source/libs/string/basic_string/compare-iterator.rst
Normal file
66
source/libs/string/basic_string/compare-iterator.rst
Normal file
|
@ -0,0 +1,66 @@
|
|||
.. _sprout-string-basic_string-compare-iterator:
|
||||
###############################################################################
|
||||
compare
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<typename StringConstIterator>
|
||||
SPROUT_CONSTEXPR int compare(StringConstIterator s) const;
|
||||
|
||||
Requires
|
||||
========================================
|
||||
|
||||
| ``std::is_same<StringConstIterator, const_iterator>::value || std::is_same<StringConstIterator, iterator>::value``.
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| ``compare(basic_string(s))``.
|
||||
|
||||
----
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<typename StringConstIterator>
|
||||
SPROUT_CONSTEXPR int compare(size_type pos1, size_type n1, StringConstIterator s) const;
|
||||
|
||||
Requires
|
||||
========================================
|
||||
|
||||
| ``std::is_same<StringConstIterator, const_iterator>::value || std::is_same<StringConstIterator, iterator>::value``.
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| ``basic_string(*this, pos, n1).compare(basic_string(s))``.
|
||||
|
||||
----
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<typename StringConstIterator>
|
||||
SPROUT_CONSTEXPR int compare(size_type pos1, size_type n1, StringConstIterator s, size_type n2) const;
|
||||
|
||||
Requires
|
||||
========================================
|
||||
|
||||
| ``std::is_same<StringConstIterator, const_iterator>::value || std::is_same<StringConstIterator, iterator>::value``.
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| ``basic_string(*this, pos, n1).compare(basic_string(s, n2))``.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
111
source/libs/string/basic_string/compare.rst
Normal file
111
source/libs/string/basic_string/compare.rst
Normal file
|
@ -0,0 +1,111 @@
|
|||
.. _sprout-string-basic_string-compare:
|
||||
###############################################################################
|
||||
compare
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<std::size_t N2>
|
||||
SPROUT_CONSTEXPR int compare(basic_string<T, N2, Traits> const& str) const;
|
||||
|
||||
Effects
|
||||
========================================
|
||||
|
||||
| Determines the effective length rlen of the strings to compare as the smallest of ``size()`` and ``str.size()``.
|
||||
| The function then compares the two strings by calling ``traits_type::compare(data(), str.data(), rlen)``.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto x = string<8>("homuhomu");
|
||||
SPROUT_STATIC_CONSTEXPR auto y = string<8>("madocchi");
|
||||
SPROUT_STATIC_CONSTEXPR auto result = x.compare(y);
|
||||
static_assert(result < 0, "x is less than y.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| Recursive function invocations in *O(logN)* (logarithmic) depth.
|
||||
|
||||
.. note::
|
||||
The current implementation is incomplete. *O(N)* (linear) depth.
|
||||
|
||||
----
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<std::size_t N2>
|
||||
SPROUT_CONSTEXPR int compare(size_type pos1, size_type n1, basic_string<T, N2, Traits> const& str) const;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| ``basic_string(*this, pos1, n1).compare(str)``.
|
||||
|
||||
----
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<std::size_t N2>
|
||||
SPROUT_CONSTEXPR int compare(size_type pos1, size_type n1, basic_string<T, N2, Traits> const& str, size_type pos2, size_type n2) const;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| ``basic_string(*this, pos1, n1).compare(basic_string<T, N2, Traits>(str, pos2, n2))``.
|
||||
|
||||
----
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
SPROUT_CONSTEXPR int compare(value_type const* s) const;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| ``compare(basic_string(s))``.
|
||||
|
||||
----
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
SPROUT_CONSTEXPR int compare(size_type pos1, size_type n1, value_type const* s) const;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| ``basic_string(*this, pos, n1).compare(basic_string(s))``.
|
||||
|
||||
----
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
SPROUT_CONSTEXPR int compare(size_type pos1, size_type n1, value_type const* s, size_type n2) const;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| ``basic_string(*this, pos, n1).compare(basic_string(s, n2))``.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
94
source/libs/string/basic_string/find.rst
Normal file
94
source/libs/string/basic_string/find.rst
Normal file
|
@ -0,0 +1,94 @@
|
|||
.. _sprout-string-basic_string-find:
|
||||
###############################################################################
|
||||
find
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<std::size_t N2>
|
||||
SPROUT_CONSTEXPR size_type find(basic_string<T, N2, Traits> const& str, size_type pos = 0) const SPROUT_NOEXCEPT;
|
||||
|
||||
Effects
|
||||
========================================
|
||||
|
||||
| Determines the lowest position xpos, if possible, such that both of the following conditions obtain:
|
||||
|
||||
* ``pos <= xpos and xpos + str.size() <= size();``
|
||||
* ``traits_type::eq(at(xpos + I), str.at(I))`` for all elements I of the string controlled by str.
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| xpos if the function can determine such a value for xpos. Otherwise, returns npos.
|
||||
|
||||
Remarks
|
||||
========================================
|
||||
|
||||
| Uses ``traits_type::eq()``.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = string<8>("madocchi");
|
||||
SPROUT_STATIC_CONSTEXPR auto result = input.find("cchi");
|
||||
static_assert(result == 4, "a found position is 4.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| Recursive function invocations in *O(logN)* (logarithmic) depth.
|
||||
|
||||
.. note::
|
||||
The current implementation is incomplete. *O(N)* (linear) depth.
|
||||
|
||||
----
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
SPROUT_CONSTEXPR size_type find(value_type const* s, size_type pos, size_type n) const;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
|
|
||||
|
||||
----
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
SPROUT_CONSTEXPR size_type find(value_type const* s, size_type pos = 0) const;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
|
|
||||
|
||||
----
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
SPROUT_CONSTEXPR size_type find(value_type c, size_type pos = 0) const;
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
|
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/string.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
|
@ -35,8 +35,10 @@ Examples
|
|||
|
||||
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.");
|
||||
int main() {
|
||||
x = y.begin();
|
||||
SPROUT_ASSERT_MSG(x == y, "y is assigned to x.");
|
||||
}
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
|
|
@ -34,8 +34,10 @@ Examples
|
|||
|
||||
auto x = string<8>("homuhomu");
|
||||
SPROUT_STATIC_CONSTEXPR auto y = string<8>("madocchi");
|
||||
x = y;
|
||||
SPROUT_ASSERT_MSG(x == y, "y is assigned to x.");
|
||||
int main() {
|
||||
x = y;
|
||||
SPROUT_ASSERT_MSG(x == y, "y is assigned to x.");
|
||||
}
|
||||
|
||||
----
|
||||
|
||||
|
|
|
@ -39,8 +39,10 @@ Examples
|
|||
using namespace sprout;
|
||||
|
||||
auto x = string<8>("homuhomu");
|
||||
x.resize(4);
|
||||
SPROUT_ASSERT_MSG(x.size() == 4 && x == "homu", "string is resized to 4.");
|
||||
int main() {
|
||||
x.resize(4);
|
||||
SPROUT_ASSERT_MSG(x.size() == 4 && x == "homu", "string is resized to 4.");
|
||||
}
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
|
|
@ -33,8 +33,8 @@ Examples
|
|||
using namespace sprout;
|
||||
|
||||
using type = string<8>;
|
||||
SPROUT_STATIC_CONSTEXPR auto size = std::tuple_size<type>::value;
|
||||
static_assert(size == 8, "tuple size of string is 8.");
|
||||
SPROUT_STATIC_CONSTEXPR auto n = std::tuple_size<type>::value;
|
||||
static_assert(n == 8, "tuple size of string is 8.");
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
|
|
@ -32,8 +32,10 @@ Examples
|
|||
|
||||
auto x = string<8>("homuhomu");
|
||||
auto y = string<8>("madocchi");
|
||||
swap(x, y);
|
||||
SPROUT_ASSERT_MSG(x == "madocchi" && y == "homuhomu", "each element are swapped.");
|
||||
int main() {
|
||||
swap(x, y);
|
||||
SPROUT_ASSERT_MSG(x == "madocchi" && y == "homuhomu", "each element are swapped.");
|
||||
}
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
|
|
@ -29,8 +29,10 @@ Examples
|
|||
|
||||
auto x = string<8>("homuhomu");
|
||||
auto y = string<8>("madocchi");
|
||||
swap(x, y);
|
||||
SPROUT_ASSERT_MSG(x == "madocchi" && y == "homuhomu", "each element are swapped.");
|
||||
int main() {
|
||||
swap(x, y);
|
||||
SPROUT_ASSERT_MSG(x == "madocchi" && y == "homuhomu", "each element are swapped.");
|
||||
}
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue