tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
find.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_STRINGS_FIND_HPP
4#define TETL_STRINGS_FIND_HPP
5
7
8namespace etl::strings {
9
10template <typename Char, typename Traits>
11[[nodiscard]] constexpr auto find(
15) noexcept -> typename basic_string_view<Char, Traits>::size_type
16{
17 if (needle.size() == 0 and pos <= haystack.size()) {
18 return pos;
19 }
20
21 if (pos <= haystack.size() - needle.size()) {
22 return haystack.find(needle, pos);
23 }
24
26}
27
28} // namespace etl::strings
29
30#endif // TETL_STRINGS_FIND_HPP
Definition find.hpp:8
constexpr auto find(basic_string_view< Char, Traits > haystack, basic_string_view< Char, Traits > needle, typename basic_string_view< Char, Traits >::size_type pos=0) noexcept -> typename basic_string_view< Char, Traits >::size_type
Definition find.hpp:11
The class template basic_string_view describes an object that can refer to a constant contiguous sequ...
Definition basic_string_view.hpp:34
static constexpr size_type npos
This is a special value equal to the maximum value representable by the type size_type.
Definition basic_string_view.hpp:693
etl::size_t size_type
Definition basic_string_view.hpp:43
constexpr auto find(basic_string_view v, size_type pos=0) const noexcept -> size_type
Finds the first substring equal to the given character sequence. Finds the first occurence of v in th...
Definition basic_string_view.hpp:335
constexpr auto size() const noexcept -> size_type
Returns the number of Char elements in the view, i.e. etl::distance(begin(), end()).
Definition basic_string_view.hpp:174