std::optional<T>:: end
From cppreference.net
C++
Utilities library
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
std::optional
| Member functions | ||||
| Observers | ||||
| Iterators | ||||
|
(C++26)
|
||||
|
optional::end
(C++26)
|
||||
| Monadic operations | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
| Modifiers | ||||
| Non-member functions | ||||
| Deduction guides | ||||
| Helper classes | ||||
| Helper objects | ||||
|
constexpr
iterator end
(
)
noexcept
;
|
(C++26부터) | |
|
constexpr
const_iterator end
(
)
const
noexcept
;
|
(C++26부터) | |
끝 다음(past-the-end) 반복자를 반환합니다. 다음 코드와 동일합니다: return begin ( ) + has_value ( ) ; .
목차 |
반환값
끝 다음 반복자
복잡도
상수.
참고 사항
| 기능 테스트 매크로 | 값 | 표준 | 기능 |
|---|---|---|---|
__cpp_lib_optional_range_support
|
202406L
|
(C++26) | std::optional 에 대한 범위 지원 |
예제
이 코드 실행
#include <optional> #include <print> int main() { constexpr std::optional<int> none{std::nullopt}; // optional @1 constexpr std::optional<int> some{42}; // optional @2 static_assert(none.begin() == none.end()); static_assert(some.begin() != some.end()); // 범위 기반 for 루프 지원 for (int i : none) std::println("Optional @1 has a value of {}", i); for (int i : some) std::println("Optional @2 has a value of {}", i); }
출력:
Optional @2 has a value of 42
참고 항목
|
(C++26)
|
시작 부분을 가리키는 반복자를 반환합니다
(public member function) |