Namespaces
Variants

std::meta::is_enumerable_type

cppreference.net에서
< cpp | meta
 
 
 
리플렉션 라이브러리
 
리플렉션 유형 및 쿼리
리플렉션 쿼리
리플렉션 레이아웃 쿼리
유형 속성
유형 속성 쿼리
 
헤더 <meta>
consteval bool is_enumerable_type( std::meta::info r );
(C++26부터)

에서 정의됨r 완전한 클래스 유형 또는 열거자 목록이 완전히 정의된 열거형 유형, 또는 그 유형 별칭을 나타내는지 결정합니다.

공식적으로, 유형 T은 지점 P에서 열거 가능합니다:

  • T 지점 P에서 완전한 클래스 유형이거나
  • T 선언 D에 의해 정의된 열거형 유형이며, D이 P에서 도달 가능하고 P가 열거형-지정자 D 내에 발생하지 않는 경우.

매개변수

r - 리플렉션 값

반환값

true std::meta::dealias(r)이 평가 컨텍스트의 어떤 지점에서 열거 가능한 유형을 나타내면 false, 그렇지 않으면

참고

표준 리플렉션 함수는 기반, 멤버 또는 열거자 목록을 얻기 위해 유형이 열거 가능해야 합니다.

예제

#include <meta>

struct A; // incomplete type
static_assert(std::meta::is_enumerable_type(^^A) == false);

struct B {}; // complete type
static_assert(std::meta::is_enumerable_type(^^B) == true);

template <typename>
struct C; // incomplete class template
static_assert(std::meta::is_enumerable_type(^^C<long>) == false);

template <>
struct C<int> {}; // complete explicit template specialization
static_assert(std::meta::is_enumerable_type(^^C<int>) == true);

template <>
struct C<long>; // incomplete explicit template specialization
static_assert(std::meta::is_enumerable_type(^^C<long>) == false);

enum class E;
static_assert(std::meta::is_enumerable_type(^^E) == false);

enum class E { e };
static_assert(std::meta::is_enumerable_type(^^E) == true);
static_assert(std::meta::is_enumerable_type(^^E::e) == false);

union U;
static_assert(std::meta::is_enumerable_type(^^U) == false);

union U { int i; short j; };
static_assert(std::meta::is_enumerable_type(^^U) == true);

int main() {}

같이 보기

리플렉션이 완전한 유형을 나타내는지 확인
(함수)