std::ranges::split_view<V,Pattern>:: begin
|
||||||||||||||||||||||
| Range primitives | |||||||
|
|||||||
| Range concepts | |||||||||||||||||||
|
|||||||||||||||||||
| Range factories | |||||||||
|
|||||||||
| Range adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||
| Helper items | |||||||||||||||||
|
|
||||||||||||||||
|
constexpr
/*iterator*/
begin
(
)
;
|
(desde C++20) | |
Devuelve un iterator al primer subrango encontrado.
Para proporcionar la complejidad temporal amortizada constante requerida por el concepto
range
, esta función almacena en caché el resultado dentro del
split_view
(mediante el miembro
cached_begin_
) para su uso en llamadas posteriores.
Sea
base_
el miembro de datos subyacente. Equivalente a:
constexpr /*iterator*/ begin() { if (!cached_begin_.has_value()) cached_begin_ = this->find_next(ranges::begin(base_)); return {*this, ranges::begin(base_), cached_begin_.value()}; }
Contenidos |
Valor de retorno
Un iterator .
Complejidad
Amortizado \(\scriptsize \mathcal{O}(1)\) O(1) .
Ejemplo
#include <iomanip> #include <iostream> #include <ranges> #include <string_view> int main() { constexpr std::string_view sentence{"Keep..moving..forward.."}; constexpr std::string_view delim{".."}; std::ranges::split_view words{sentence, delim}; std::cout << "begin(): " << std::quoted(std::string_view{*words.begin()}) << "\nSubstrings: "; for (auto word : words) std::cout << std::quoted(std::string_view(word)) << ' '; std::ranges::split_view letters{sentence, std::string_view{""}}; std::cout << "\nbegin(): " << std::quoted(std::string_view{*letters.begin()}) << "\nLetters: "; for (auto letter : letters) std::cout << std::string_view(letter) << ' '; std::cout << '\n'; }
Salida:
begin(): "Keep" Substrings: "Keep" "moving" "forward" "" begin(): "K" Letters: K e e p . . m o v i n g . . f o r w a r d . .
Véase también
|
devuelve un iterador o un centinela al final
(función miembro pública) |
|
|
devuelve un iterador al inicio
(función miembro pública de
std::ranges::lazy_split_view<V,Pattern>
)
|
|
|
(C++20)
|
devuelve un iterador al inicio de un rango
(objeto de punto de personalización) |