1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-07-02 14:04:09 +00:00

add doc: string tupele support, hash support

This commit is contained in:
Bolero-MURAKAMI 2013-09-04 18:37:01 +09:00
parent 4e71ab19c4
commit 794666afac
22 changed files with 1752 additions and 42 deletions

View file

@ -0,0 +1,47 @@
.. _sprout-string-basic_string-hash_value:
###############################################################################
hash_value
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename T, std::size_t N, typename Traits>
inline SPROUT_CONSTEXPR std::size_t
hash_value(sprout::basic_string<T, N, Traits> const& v);
Returns
========================================
| Equivalent to ``sprout::hash_range(v)``.
Notes
========================================
| ``sprout::to_hash(v)`` is a valid call, because ``hash_value(v)`` ADL callable is defined.
Examples
========================================
.. sourcecode:: c++
#include <sprout/string.hpp>
using namespace sprout;
using type = string<8>;
SPROUT_STATIC_CONSTEXPR auto input = type("homuhomu");
SPROUT_STATIC_CONSTEXPR auto h = sprout::to_hash(input);
static_assert(h, "hash value generated from string.");
Complexity
========================================
| linear in N.
| Recursive function invocations in *O(logN)* (logarithmic) depth.
Header
========================================
| ``sprout/string/hash.hpp``
| Convenience header: ``sprout/string.hpp``

View file

@ -0,0 +1,46 @@
.. _sprout-string-basic_string-std-hash:
###############################################################################
std::hash
###############################################################################
Interface
========================================
.. sourcecode:: c++
namespace std {
template<typename T, std::size_t N, typename Traits>
struct hash<sprout::basic_string<T, N, Traits> >;
}
Description
========================================
| Meet the requirements of class template hash.
Member functions
----------------------------------------
======================================== ===============================================================================
function definition
======================================== ===============================================================================
operator() Equivalent to ``sprout::hash_range(v)``.
======================================== ===============================================================================
Examples
========================================
.. sourcecode:: c++
#include <sprout/string.hpp>
using namespace sprout;
using type = string<8>;
SPROUT_STATIC_CONSTEXPR auto input = type("homuhomu");
SPROUT_STATIC_CONSTEXPR auto h = std::hash<type>()(input);
static_assert(h, "hash value generated from string.");
Header
========================================
| ``sprout/string/hash.hpp``
| Convenience header: ``sprout/string.hpp``

View file

@ -0,0 +1,45 @@
.. _sprout-string-basic_string-std-tuple_element:
###############################################################################
std::tuple_element
###############################################################################
Interface
========================================
.. sourcecode:: c++
namespace std {
template<std::size_t I, typename T, std::size_t N, typename Traits>
struct tuple_element<I, sprout::basic_string<T, N, Traits> >;
}
// syntax
std::tuple_element<I, basic_string<T, N, Traits> >::type
Requires
========================================
| ``I < N``. The program is ill-formed if I is out of bounds.
Value
========================================
| The type T.
Examples
========================================
.. sourcecode:: c++
#include <sprout/string.hpp>
#include <type_traits>
using namespace sprout;
using type = string<8>;
using element_type = std::tuple_element<0, type>::type;
static_assert(std::is_same<element_type, char>::value, "tuple element type of string is char.");
Header
========================================
| ``sprout/string/tuple.hpp``
| Convenience header: ``sprout/string.hpp``

View file

@ -0,0 +1,44 @@
.. _sprout-string-basic_string-std-tuple_size:
###############################################################################
std::tuple_size
###############################################################################
Interface
========================================
.. sourcecode:: c++
namespace std {
template<typename T, std::size_t N, typename Traits>
struct tuple_size<sprout::basic_string<T, N, Traits> >;
}
// syntax
std::tuple_size<basic_string<T, N, Traits> >::value
Return type
========================================
| integral constant expression.
Value
========================================
| N.
Examples
========================================
.. sourcecode:: c++
#include <sprout/string.hpp>
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.");
Header
========================================
| ``sprout/string/tuple.hpp``
| Convenience header: ``sprout/string.hpp``

View file

@ -0,0 +1,48 @@
.. _sprout-string-basic_string-swap-global:
###############################################################################
swap
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename T, std::size_t N, typename Traits>
inline void
swap(sprout::basic_string<T, N, Traits>& lhs, sprout::basic_string<T, N, Traits>& rhs)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(lhs.swap(rhs)));
Effects
========================================
| ``lhs.swap(rhs)``.
Throws
========================================
| Nothing unless ``lhs.swap(rhs)`` 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 in N.
Header
========================================
| ``sprout/string/array.hpp``
| Convenience header: ``sprout/string.hpp``

View file

@ -0,0 +1,61 @@
.. _sprout-string-basic_string-tuple_get:
###############################################################################
tuple_get
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<std::size_t I, typename T, std::size_t N, typename Traits>
inline SPROUT_CONSTEXPR T&
tuple_get(sprout::basic_string<T, N, Traits>& t) SPROUT_NOEXCEPT;
template<std::size_t I, typename T, std::size_t N, typename Traits>
inline SPROUT_CONSTEXPR T const&
tuple_get(sprout::basic_string<T, N, Traits> const& t) SPROUT_NOEXCEPT;
template<std::size_t I, typename T, std::size_t N, typename Traits>
inline SPROUT_CONSTEXPR T&&
tuple_get(sprout::basic_string<T, N, Traits>&& t) SPROUT_NOEXCEPT;
Requires
========================================
| ``I < N``. The program is ill-formed if I is out of bounds.
Returns
========================================
| A reference to the Ith element of a, where indexing is zero-based.
| or
| A const reference to the Ith element of a, where indexing is zero-based.
| or
| Equivalent to ``return move(tuple_get<I>(t));``
Notes
========================================
| ``sprout::get<I>(t)`` (same as sprout::tuples::get) is a valid call, because ``tuple_get<I>(t)`` ADL callable is defined.
Examples
========================================
.. sourcecode:: c++
#include <sprout/string.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto input = string<8>("homuhomu");
static_assert(sprout::get<4>(input) == 'h', "an element at position 4 is h.");
Complexity
========================================
| Recursive function invocations in *O(1)* (constant) depth.
Header
========================================
| ``sprout/string/tuple.hpp``
| Convenience header: ``sprout/string.hpp``