types_is_implicit_lifetime

types_is_implicit_lifetime (암묵적 수명 타입 판별)

이 페이지는 C++ 표준 라이브러리의 std::is_implicit_lifetime 타입 특성에 대해 설명해요. 주어진 타입이 암묵적 수명(implicit-lifetime) 타입인지 컴파일 타임에 판별하는 데 사용돼요. C++23부터 사용할 수 있어요.

출처: cppreference

본문

개요

<type_traits> 헤더에 정의되어 있어요.

정의 헤더
<type_traits>
템플릿 정의
template < class T > struct is_implicit_lifetime ; (C++23부터)

std::is_implicit_lifetime는 UnaryTypeTrait예요.

T가 암묵적 수명 타입이면 멤버 상수 valuetrue가 돼요. 그 외의 모든 타입에 대해서는 valuefalse예요.

T가 배열 타입이나 (cv-qualified된) void가 아닌 불완전 타입이면 동작이 정의되지 않아요.

프로그램에서 std::is_implicit_lifetime 또는 std::is_implicit_lifetime_v에 대한 특수화를 추가하면 동작이 정의되지 않아요.

템플릿 매개변수

T - 확인할 타입

헬퍼 변수 템플릿

템플릿 정의
template < class T > constexpr bool is_implicit_lifetime_v = is_implicit_lifetime < T >:: value ; (C++23부터)

std::integral_constant에서 상속됨

멤버 상수

value [static] T가 암묵적 수명 타입이면 true, 아니면 false (공용 정적 멤버 상수)

멤버 함수

operator bool 객체를 bool로 변환하고 value를 반환해요 (공용 멤버 함수)
operator() (C++14) value를 반환해요 (공용 멤버 함수)

멤버 타입

타입 정의
value_type bool
type std :: integral_constant < bool , value >

참고 사항

기능 테스트 매크로 표준 기능
__cpp_lib_is_implicit_lifetime 202302L (C++23) std::is_implicit_lifetime

예제

// The following types are collectively called implicit-lifetime types:
// * scalar types:
//     * arithmetic types
//     * enumeration types
//     * pointer types
//     * pointer-to-member types
//     * std::nullptr_t
// * implicit-lifetime class types
//     * is an aggregate whose destructor is not user-provided
//     * has at least one trivial eligible constructor and a trivial,
//       non-deleted destructor
// * array types
// * cv-qualified versions of these types.
#include <type_traits>

static_assert(std::is_implicit_lifetime_v<int>); // arithmetic type is a scalar type
static_assert(std::is_implicit_lifetime_v<const int>); // cv-qualified a scalar type

enum E { e };
static_assert(std::is_implicit_lifetime_v<E>); // enumeration type is a scalar type
static_assert(std::is_implicit_lifetime_v<int*>); // pointer type is a scalar type
static_assert(std::is_implicit_lifetime_v<std::nullptr_t>); // scalar type

struct S { int x, y; };
// S is an implicit-lifetime class: an aggregate without user-provided destructor
static_assert(std::is_implicit_lifetime_v<S>);

static_assert(std::is_implicit_lifetime_v<int S::*>); // pointer-to-member

struct X
{
    X(){}
    ~X() = delete;
};
// X is not implicit-lifetime class due to deleted destructor
static_assert(!std::is_implicit_lifetime_v<X>);

static_assert(std::is_implicit_lifetime_v<int[8]>); // array type
static_assert(std::is_implicit_lifetime_v<volatile int[8]>); // cv-qualified array type

int main() {}

같이 보기

is_scalar (C++11) 타입이 스칼라 타입인지 확인해요 (클래스 템플릿)
is_array (C++11) 타입이 배열 타입인지 확인해요 (클래스 템플릿)
is_aggregate (C++17) 타입이 집계 타입인지 확인해요 (클래스 템플릿)
start_lifetime_as, start_lifetime_as_array (C++23) 객체 표현을 재사용하여 주어진 저장 공간에 객체를 암묵적으로 생성해요 (함수 템플릿)
is_implicit_lifetime_type (C++26) 반영된 타입이 암묵적 수명 타입인지 확인해요 (함수)

더 알아보기 (Learn more)

cppreference