Namespaces
Variants

std::expected<T,E>:: error

From cppreference.net
Utilities library
constexpr const E & error ( ) const & noexcept ;
(1) (C++23부터)
constexpr E & error ( ) & noexcept ;
(2) (C++23부터)
constexpr const E && error ( ) const && noexcept ;
(3) (C++23부터)
constexpr E && error ( ) && noexcept ;
(4) (C++23부터)

* this 에 포함된 예상치 못한 값에 접근합니다.

만약 has_value() true 라면, 동작은 정의되지 않습니다.

(C++26까지)

만약 has_value() true 라면:

  • 구현이 hardened 된 경우, contract violation 이 발생합니다. 또한 계약 위반 핸들러가 "observe" 평가 의미론 하에 반환한다면, 동작은 정의되지 않습니다.
  • 구현이 hardened되지 않은 경우, 동작은 정의되지 않습니다.
(C++26부터)

반환값

1,2) unex
3,4) std :: move ( unex  )

예제

참고 항목

예상치 못한 값이 있으면 해당 값을 반환하고, 그렇지 않으면 다른 값을 반환합니다
(public member function)
예상된 값에 접근합니다
(public member function)
예상된 값을 반환합니다
(public member function)
객체가 예상된 값을 포함하는지 확인합니다
(public member function)