Namespaces
Variants

std:: is_literal_type

From cppreference.net
Metaprogramming library
Type traits
Type categories
(C++11)
(C++11) ( DR* )
Type properties
(C++11)
(C++11)
(C++14)
(C++11) (deprecated in C++26)
is_literal_type
(C++11) ( until C++20* )
(C++11) (deprecated in C++20)
(C++11)
Type trait constants
Metafunctions
(C++17)
Supported operations
Relationships and property queries
Type modifications
Type transformations
(C++11) (deprecated in C++23)
(C++11) (deprecated in C++23)
(C++11)
(C++11) ( until C++20* ) (C++17)

Compile-time rational arithmetic
Compile-time integer sequences
헤더 파일에 정의됨 <type_traits>
template < class T >
struct is_literal_type ;
(C++11부터)
(C++17에서 사용 중단됨)
(C++20에서 제거됨)

std::is_literal_type UnaryTypeTrait 입니다.

(이 형식 특성은 사용 중단되었으며 [1] 제거되었습니다 [2] 제네릭 코드에 거의 가치를 제공하지 않기 때문입니다.)

만약 T LiteralType 의 모든 요구사항을 만족한다면, 멤버 상수 value true 로 제공합니다. 다른 모든 타입에 대해서는 value false 입니다.

만약 std:: remove_all_extents_t < T > 가 불완전한 타입이고 (가능한 cv 한정자를 포함하지 않은) void 가 아닌 경우, 동작은 정의되지 않습니다.

프로그램이 std::is_literal_type 또는 std::is_literal_type_v 에 대한 특수화를 추가하는 경우, 그 동작은 정의되지 않습니다.

목차

템플릿 매개변수

T - 확인할 타입

헬퍼 변수 템플릿

template < class T >
constexpr bool is_literal_type_v = is_literal_type < T > :: value ;
(C++17부터)
(사용 중단됨)
(C++20에서 제거됨)

std:: integral_constant 로부터 상속됨

멤버 상수

value
[static]
true 만약 T 가 리터럴 타입인 경우, false 그렇지 않은 경우
(public static member constant)

멤버 함수

operator bool
객체를 bool 로 변환, value 반환
(public member function)
operator()
(C++14)
value 반환
(public member function)

멤버 타입

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

참고 사항

리터럴 타입만이 constexpr 함수 의 매개변수로 사용되거나 반환될 수 있습니다. 리터럴 클래스만이 constexpr 멤버 함수를 가질 수 있습니다.

예제

#include <type_traits>
struct A { int m; };
static_assert(std::is_literal_type_v<A> == true);
struct B { virtual ~B(); };
static_assert(std::is_literal_type_v<B> == false);
int main() {}

결함 보고서

다음의 동작 변경 결함 보고서들은 이전에 발표된 C++ 표준에 소급 적용되었습니다.

DR 적용 대상 게시된 동작 올바른 동작
LWG 2015 C++11 T 는 경계를 알 수 없는 불완전
클래스 타입의 배열일 수 있음
이 경우 동작은
정의되지 않음

외부 링크

  1. Alisdair Meredith. " is_literal 특성의 사용 중단" . C++17에서 남은 라이브러리 부분의 사용 중단 . " is_literal 타입 특성은 제네릭 코드에 거의 가치를 제공하지 않으며, 실제로 필요한 것은 특정 생성이 상수 초기화를 생성할 수 있는지 여부를 알 수 있는 능력입니다."
  2. Alisdair Meredith, Stephan T. Lavavej, Tomasz Kamiński. "사용 중단된 타입 특성" . C++20을 위한 C++17의 사용 중단된 기능 검토 . " 강력한 권고: 좀비로 계속 존재할 수 있는 특성들을 제거하십시오. [...] 토론토 검토: 강력한 권고를 수락하고 C++20에서 삭제합니다."