forward_list_begin
forward_list_begin (std::forward_list::begin — 시작 이터레이터)
std::forward_list의 첫 번째 원소를 가리키는 이터레이터를 반환하는 멤버 함수예요. 컨테이너가 비어 있으면 end()와 같아요.
출처: cppreference
본문
시그니처는 다음과 같아요.
iterator begin() noexcept; // (1) (since C++11)
const_iterator begin() const noexcept; // (2) (since C++11)
const_iterator cbegin() const noexcept; // (3) (since C++11)
forward_list의 첫 번째 원소를 가리키는 이터레이터를 반환해요. forward_list가 비어 있으면 반환된 이터레이터는 end()와 같아요.
반환값
첫 번째 원소를 가리키는 이터레이터.
복잡도
상수(constant)예요.
예제
#include <algorithm>
#include <cassert>
#include <iostream>
#include <forward_list>
int main()
{
std::forward_list<int> nums{1, 2, 4, 8, 16};
std::cout << *nums.begin() << '\n'; // 1
}