mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-07-02 14:04:09 +00:00
add doc: char_traits character operations
This commit is contained in:
parent
55eba4ae71
commit
b7d68b357d
23 changed files with 1569 additions and 25 deletions
40
source/libs/string/char_traits/assign.rst
Normal file
40
source/libs/string/char_traits/assign.rst
Normal file
|
@ -0,0 +1,40 @@
|
|||
.. _sprout-string-char_traits-assign:
|
||||
###############################################################################
|
||||
assign
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
static void assign(char_type& c1, char_type const& c2);
|
||||
|
||||
Effects
|
||||
========================================
|
||||
|
||||
| Equivalent to ``std::char_traits<Char>::assign(c1, c2)``.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
#include <sprout/assert.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
char x = 'H';
|
||||
SPROUT_STATIC_CONSTEXPR char y = 'M';
|
||||
char_traits<char>::assign(x, y);
|
||||
SPROUT_ASSERT_MSG(x == y, "y is assigned to x.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| constant.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/char_traits.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
40
source/libs/string/char_traits/compare.rst
Normal file
40
source/libs/string/char_traits/compare.rst
Normal file
|
@ -0,0 +1,40 @@
|
|||
.. _sprout-string-char_traits-compare:
|
||||
###############################################################################
|
||||
compare
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
static SPROUT_CONSTEXPR int compare(char_type const* s1, char_type const* s2, std::size_t n);
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| Equivalent to ``std::char_traits<Char>::compare(s1, s2, n)`` in constant expression.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR char const* x = "homuhomu";
|
||||
SPROUT_STATIC_CONSTEXPR char const* y = "madocchi";
|
||||
SPROUT_STATIC_CONSTEXPR auto result = char_traits<char>::compare(x, y, 8);
|
||||
static_assert(result < 0, "x is less than y.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| linear.
|
||||
| Recursive function invocations in *O(logN)* (logarithmic) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/char_traits.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
40
source/libs/string/char_traits/eq.rst
Normal file
40
source/libs/string/char_traits/eq.rst
Normal file
|
@ -0,0 +1,40 @@
|
|||
.. _sprout-string-char_traits-eq:
|
||||
###############################################################################
|
||||
eq
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
static SPROUT_CONSTEXPR bool eq(char_type c1, char_type c2) SPROUT_NOEXCEPT;
|
||||
|
||||
Effects
|
||||
========================================
|
||||
|
||||
| Equivalent to ``std::char_traits<Char>::eq(c1, c2)``.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR char x = 'H';
|
||||
SPROUT_STATIC_CONSTEXPR char y = 'H';
|
||||
SPROUT_STATIC_CONSTEXPR auto result = char_traits<char>::eq(x, y);
|
||||
static_assert(result, "x is equal to y.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| constant.
|
||||
| Recursive function invocations in *O(1)* (constant) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/char_traits.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
40
source/libs/string/char_traits/find.rst
Normal file
40
source/libs/string/char_traits/find.rst
Normal file
|
@ -0,0 +1,40 @@
|
|||
.. _sprout-string-char_traits-find:
|
||||
###############################################################################
|
||||
find
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
static SPROUT_CONSTEXPR char_type const* find(char_type const* s, std::size_t n, char_type const& a);
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| Equivalent to ``std::char_traits<Char>::find(s, n, a)`` in constant expression.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
#include <sprout/iterator.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR char const* x = "homuhomu";
|
||||
SPROUT_STATIC_CONSTEXPR auto result = char_traits<char>::find(x, 8, 'm');
|
||||
static_assert(sprout::distance(x, result) == 2, "a found position is 2.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| linear.
|
||||
| Recursive function invocations in *O(logN)* (logarithmic) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/char_traits.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
|
@ -6,6 +6,13 @@ char_traits
|
|||
.. toctree::
|
||||
:hidden:
|
||||
|
||||
assign
|
||||
rq
|
||||
lt
|
||||
compare
|
||||
length
|
||||
find
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
@ -74,7 +81,7 @@ pos_type std::char_traits<Char>::pos_type
|
|||
state_type std::char_traits<Char>::state_type
|
||||
======================================== =============================================================================== =======================================
|
||||
|
||||
Static Member functions
|
||||
Static member functions
|
||||
----------------------------------------
|
||||
|
||||
character operations
|
||||
|
@ -95,11 +102,11 @@ string operations
|
|||
function
|
||||
======================================== ===============================================================================
|
||||
:doc:`compare <./compare>`
|
||||
:doc:`eqlength<./length>`
|
||||
:doc:`length<./length>`
|
||||
:doc:`find <./find>`
|
||||
:doc:`move <./move>`
|
||||
:doc:`copy <./copy>`
|
||||
:doc:`assign <./assign>`
|
||||
:doc:`assign <./assign-string>`
|
||||
======================================== ===============================================================================
|
||||
|
||||
integer type operations
|
||||
|
|
39
source/libs/string/char_traits/length.rst
Normal file
39
source/libs/string/char_traits/length.rst
Normal file
|
@ -0,0 +1,39 @@
|
|||
.. _sprout-string-char_traits-length:
|
||||
###############################################################################
|
||||
length
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
static SPROUT_CONSTEXPR std::size_t length(char_type const* s);
|
||||
|
||||
Returns
|
||||
========================================
|
||||
|
||||
| Equivalent to ``std::char_traits<Char>::length(s)`` in constant expression.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR char const* x = "homuhomu";
|
||||
SPROUT_STATIC_CONSTEXPR auto result = char_traits<char>::length(x);
|
||||
static_assert(result == 8, "length of x is 8.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| linear.
|
||||
| Recursive function invocations in *O(logN)* (logarithmic) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/char_traits.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
40
source/libs/string/char_traits/lt.rst
Normal file
40
source/libs/string/char_traits/lt.rst
Normal file
|
@ -0,0 +1,40 @@
|
|||
.. _sprout-string-char_traits-lt:
|
||||
###############################################################################
|
||||
lt
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
static SPROUT_CONSTEXPR bool lt(char_type c1, char_type c2) SPROUT_NOEXCEPT;
|
||||
|
||||
Effects
|
||||
========================================
|
||||
|
||||
| Equivalent to ``std::char_traits<Char>::lt(c1, c2)``.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/string.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR char x = 'H';
|
||||
SPROUT_STATIC_CONSTEXPR char y = 'M';
|
||||
SPROUT_STATIC_CONSTEXPR auto result = char_traits<char>::lt(x, y);
|
||||
static_assert(result, "x is less than y.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| constant.
|
||||
| Recursive function invocations in *O(1)* (constant) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/string/char_traits.hpp``
|
||||
| Convenience header: ``sprout/string.hpp``
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue