Namespaces
Variants

std::bad_optional_access

cppreference.net에서
 
 
유틸리티 라이브러리
일반 유틸리티
관계 연산자 (C++20에서 폐지됨)
정수 비교 함수
(C++20)(C++20)(C++20)    
(C++20)
교체(Swap) 및
ranges::swap
exchange
declval
to_underlying
forward
forward_like
move_if_noexcept
as_const
(C++17)
tuple_size
tuple_element
apply
make_from_tuple
expected



 
 
in_place<optional>
class bad_optional_access;
헤더

(C++17부터)에 정의됨값을 포함하지 않는 optional 객체에 접근할 때 std::optional::value

cpp/error/exception

에 의해 던져질 객체의 타입을 정의합니다.

멤버 함수

멤버 함수
(생성자)bad_optional_access새
객체를 생성합니다
(공개 멤버 함수)
operator=bad_optional_access
객체를 대체합니다
(공개 멤버 함수)
what
설명 문자열을 반환합니다

(공개 멤버 함수)std::bad_optional_access::

bad_optional_access() noexcept;
bad_optional_access (1)
bad_optional_access( const bad_optional_access& other ) noexcept;
(C++17부터) (2)

(C++17부터)bad_optional_access 구현 정의된 널 종료 바이트 문자열을 사용하여 새 객체를 생성하며, 이 문자열은 what()

을 통해 접근할 수 있습니다. 1)
기본 생성자.2)*this 복사 생성자. other와 std::bad_optional_access의 동적 타입이 모두 std::strcmp(what(), other.what()) == 0이면

입니다.

매개변수 other -

복사할 다른 예외 객체 std::bad_optional_access::

bad_optional_access& operator=( const bad_optional_access& other ) noexcept;
operator=

(C++17부터)other의 내용을 할당합니다. *this와 other의 동적 타입이 모두 std::bad_optional_access이면 할당 후 std::strcmp(what(), other.what()) == 0입니다.

매개변수

other - 할당할 다른 예외 객체

반환값

*this

std::bad_optional_access::what

virtual const char* what() const noexcept;
(C++17부터)

설명 문자열을 반환합니다.

반환값

설명 정보가 포함된 구현 정의된 널 종료 문자열에 대한 포인터입니다. 이 문자열은 std::wstring으로 변환 및 표시하기에 적합합니다. 포인터는 적어도 이를 얻은 예외 객체가 소멸되거나 예외 객체에 대해 비-const 멤버 함수(예: 복사 할당 연산자)가 호출될 때까지 유효함이 보장됩니다.

반환된 문자열은 상수 평가 동안 일반 리터럴 인코딩으로 인코딩됩니다.

(C++26부터)

참고

구현은 what()를 재정의할 수 있지만 필수는 아닙니다.

상속됨: std::exception

멤버 함수

[virtual]
예외 객체를 소멸시킵니다
( std::exception의 가상 공개 멤버 함수)
[virtual]
설명 문자열을 반환합니다
( std::exception의 가상 공개 멤버 함수)