mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-04 14:14:09 +00:00
add doc: array tuple support, hash support
This commit is contained in:
parent
bf12021ae6
commit
a2580d4926
24 changed files with 1442 additions and 21 deletions
|
@ -3,6 +3,8 @@
|
|||
Sprout C++ Libraries
|
||||
###############################################################################
|
||||
|
||||
Contents:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
|
@ -21,7 +23,6 @@ Library Documentation
|
|||
*******************************************************************************
|
||||
|
||||
| The starting point for the documentation of individual libraries is the :doc:`Libraries page <./libs/index>`, which gives a brief description of each library and links to its documentation.
|
||||
|
|
||||
|
||||
.. _sprout-project:
|
||||
*******************************************************************************
|
||||
|
@ -56,7 +57,7 @@ Author
|
|||
*******************************************************************************
|
||||
|
||||
| Bolero MURAKAMI `(Mail) <contact-lib@boleros.x0.com>`_
|
||||
| `[Website] <http://bolero-murakami.github.io/>`_ `[Twitter] <https://twitter.com/bolero_murakami>`_ `[Facebook] <http://www.facebook.com/genya.murakami>`_ `[Blog] <http://d.hatena.ne.jp/boleros/>`_ `[Github] <https://github.com/bolero-MURAKAMI>`_ `[SlideShare] <http://www.slideshare.net/GenyaMurakami>`_
|
||||
| `Website <http://bolero-murakami.github.io/>`_ | `Twitter <https://twitter.com/bolero_murakami>`_ | `Facebook <http://www.facebook.com/genya.murakami>`_ | `Blog <http://d.hatena.ne.jp/boleros/>`_ | `Github <https://github.com/bolero-MURAKAMI>`_ | `SlideShare <http://www.slideshare.net/GenyaMurakami>`_
|
||||
|
||||
.. _sprout-copyrights:
|
||||
*******************************************************************************
|
||||
|
|
47
source/libs/array/array/hash_value.rst
Normal file
47
source/libs/array/array/hash_value.rst
Normal file
|
@ -0,0 +1,47 @@
|
|||
.. _sprout-array-array-hash_value:
|
||||
###############################################################################
|
||||
hash_value
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR std::size_t
|
||||
hash_value(sprout::array<T, N> 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/array.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
using type = array<int, 10>;
|
||||
SPROUT_STATIC_CONSTEXPR auto input = type{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
|
||||
SPROUT_STATIC_CONSTEXPR auto h = sprout::to_hash(input);
|
||||
static_assert(h, "hash value generated from array.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| linear in N.
|
||||
| Recursive function invocations in *O(logN)* (logarithmic) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/array/tuple.hpp``
|
||||
| Convenience header: ``sprout/array.hpp``
|
||||
|
46
source/libs/array/array/std-hash.rst
Normal file
46
source/libs/array/array/std-hash.rst
Normal file
|
@ -0,0 +1,46 @@
|
|||
.. _sprout-array-array-std-hash:
|
||||
###############################################################################
|
||||
std::hash
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
namespace std {
|
||||
template<typename T, std::size_t N>
|
||||
struct hash<sprout::array<T, N> >;
|
||||
}
|
||||
|
||||
Description
|
||||
========================================
|
||||
|
||||
| Meet the requirements of class template hash.
|
||||
|
||||
Member functions
|
||||
----------------------------------------
|
||||
|
||||
======================================== ===============================================================================
|
||||
function definition
|
||||
======================================== ===============================================================================
|
||||
operator() Equivalent to ``sprout::hash_range(v)``.
|
||||
======================================== ===============================================================================
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/array.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
using type = array<int, 10>;
|
||||
SPROUT_STATIC_CONSTEXPR auto input = type{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
|
||||
SPROUT_STATIC_CONSTEXPR auto h = std::hash<type>()(input);
|
||||
static_assert(h, "hash value generated from array.");
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/array/hash.hpp``
|
||||
| Convenience header: ``sprout/array.hpp``
|
||||
|
45
source/libs/array/array/std-tuple_element.rst
Normal file
45
source/libs/array/array/std-tuple_element.rst
Normal file
|
@ -0,0 +1,45 @@
|
|||
.. _sprout-array-array-std-tuple_element:
|
||||
###############################################################################
|
||||
std::tuple_element
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
namespace std {
|
||||
template<std::size_t I, typename T, std::size_t N>
|
||||
struct tuple_element<I, sprout::array<T, N> >;
|
||||
}
|
||||
|
||||
// syntax
|
||||
std::tuple_element<I, array<T, N> >::type
|
||||
|
||||
Requires
|
||||
========================================
|
||||
|
||||
| ``I < N``. The program is ill-formed if I is out of bounds.
|
||||
|
||||
Value
|
||||
========================================
|
||||
|
||||
| The type T.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/array.hpp>
|
||||
#include <type_traits>
|
||||
using namespace sprout;
|
||||
|
||||
using type = array<int, 10>;
|
||||
using element_type = std::tuple_element<0, type>::type;
|
||||
static_assert(std::is_same<element_type, int>::value, "tuple element type of array is int.");
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/array/tuple.hpp``
|
||||
| Convenience header: ``sprout/array.hpp``
|
||||
|
44
source/libs/array/array/std-tuple_size.rst
Normal file
44
source/libs/array/array/std-tuple_size.rst
Normal file
|
@ -0,0 +1,44 @@
|
|||
.. _sprout-array-array-std-tuple_size:
|
||||
###############################################################################
|
||||
std::tuple_size
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
namespace std {
|
||||
template<typename T, std::size_t N>
|
||||
struct tuple_size<sprout::array<T, N> >;
|
||||
}
|
||||
|
||||
// syntax
|
||||
std::tuple_size<array<T, N> >::value
|
||||
|
||||
Return type
|
||||
========================================
|
||||
|
||||
| integral constant expression.
|
||||
|
||||
Value
|
||||
========================================
|
||||
|
||||
| N.
|
||||
|
||||
Examples
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
#include <sprout/array.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
using type = array<int, 10>;
|
||||
SPROUT_STATIC_CONSTEXPR auto size = std::tuple_size<type>::value;
|
||||
static_assert(size == 10, "tuple size of array is 10.");
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/array/tuple.hpp``
|
||||
| Convenience header: ``sprout/array.hpp``
|
||||
|
61
source/libs/array/array/tuple_get.rst
Normal file
61
source/libs/array/array/tuple_get.rst
Normal file
|
@ -0,0 +1,61 @@
|
|||
.. _sprout-array-array-tuple_get:
|
||||
###############################################################################
|
||||
tuple_get
|
||||
###############################################################################
|
||||
|
||||
Interface
|
||||
========================================
|
||||
.. sourcecode:: c++
|
||||
|
||||
template<std::size_t I, typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR T&
|
||||
tuple_get(sprout::array<T, N>& t) SPROUT_NOEXCEPT;
|
||||
|
||||
template<std::size_t I, typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR T const&
|
||||
tuple_get(sprout::array<T, N> const& t) SPROUT_NOEXCEPT;
|
||||
|
||||
template<std::size_t I, typename T, std::size_t N>
|
||||
inline SPROUT_CONSTEXPR T&&
|
||||
tuple_get(sprout::array<T, N>&& 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/array.hpp>
|
||||
using namespace sprout;
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto input = array<int, 10>{{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}};
|
||||
static_assert(sprout::get<5>(input) == 6, "an element at position 5 is 6.");
|
||||
|
||||
Complexity
|
||||
========================================
|
||||
|
||||
| Recursive function invocations in *O(1)* (constant) depth.
|
||||
|
||||
Header
|
||||
========================================
|
||||
|
||||
| ``sprout/array/tuple.hpp``
|
||||
| Convenience header: ``sprout/array.hpp``
|
||||
|
|
@ -17,6 +17,11 @@ Sprout.Array
|
|||
to_array
|
||||
make_array
|
||||
make_common_array
|
||||
array/std-tuple_size
|
||||
array/std-tuple_element
|
||||
array/tuple_get
|
||||
array/std-hash
|
||||
array/hash_value
|
||||
|
||||
Description
|
||||
========================================
|
||||
|
@ -86,6 +91,12 @@ function
|
|||
Hash support
|
||||
----------------------------------------
|
||||
|
||||
============================================================ ===============================================================================
|
||||
class
|
||||
============================================================ ===============================================================================
|
||||
:doc:`std::hash <./array/std-hash>`
|
||||
============================================================ ===============================================================================
|
||||
|
||||
======================================== ===============================================================================
|
||||
function
|
||||
======================================== ===============================================================================
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue