1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00
Sprout/source/libs/string/char_traits/find-iterator.rst

47 lines
1.3 KiB
ReStructuredText
Raw Normal View History

.. _sprout-string-char_traits-find-iterator:
###############################################################################
find
###############################################################################
Interface
========================================
.. sourcecode:: c++
template<typename ConstInputIterator>
static SPROUT_CONSTEXPR ConstInputIterator find(ConstInputIterator s, std::size_t n, char_type const& a);
Returns
========================================
| The smallest q in [s,s+n) such that ``eq(*q, a)`` is true, ``s + n`` otherwise.
Remarks
========================================
| Pointer version returns 0 when it not found, but this function returns ``s + n``.
Examples
========================================
.. sourcecode:: c++
#include <sprout/string.hpp>
#include <sprout/iterator.hpp>
using namespace sprout;
SPROUT_STATIC_CONSTEXPR auto x = string<8>("homuhomu");
SPROUT_STATIC_CONSTEXPR auto result = char_traits<char>::find(x.begin(), 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``