optional_nullopt_t
optional_nullopt_t (빈 optional 상태를 나타내는 타입)
std::nullopt_t는 std::optional이 값을 포함하지 않음을 나타내는 데 사용되는 빈 클래스 타입이에요. C++17부터 <optional> 헤더에서 정의되며, std::nullopt 상수 객체의 타입으로 잘 알려져 있죠. 이 타입을 활용하면 optional 객체를 빈 상태로 초기화하거나 해제할 수 있어요.
출처: cppreference
본문
정의
<optional> 헤더에 정의됨 |
||
|---|---|---|
struct nullopt_t; |
(C++17부터) |
std::nullopt_t는 빈 클래스 타입(empty class type)으로, std::optional이 값을 보유하고 있지 않음을 나타내는 데 사용돼요.
std::nullopt_t는 비-집합체(non-aggregate) LiteralType이에요. 기본 생성자(default constructor)도 없고, 초기화 리스트 생성자(initializer-list constructor)도 없지만, 구현 정의 리터럴 타입(implementation-defined literal type)을 받는 constexpr 생성자는 하나 갖고 있어요.
Notes (참고 사항)
nullopt_t의 생성자에 대한 제약은 op = {};와 op = nullopt; 두 가지 문법 모두를 optional 객체를 해제(disengage)하는 구문으로 지원하기 위해 존재해요.
이 클래스의 가능한 구현 중 하나는 다음과 같아요:
struct nullopt_t {
constexpr explicit nullopt_t(int) {}
};
See also (함께 보기)
nullopt (C++17) |
nullopt_t 타입의 객체 (상수) |
|---|