Namespaces
Variants

std::meta::annotations_of_with_type

cppreference.net에서
< cpp | meta
 
 
 
리플렉션 라이브러리
 
리플렉션 타입 및 쿼리
리플렉션 쿼리
리플렉션 레이아웃 쿼리
타입 속성
타입 속성 쿼리
 
헤더에 정의됨 <meta>
consteval std::vector<std::meta::info>
    annotations_of_with_type( std::meta::info item, std::meta::info type );
(C++26부터)

다음의 결과를 반환합니다: std::meta::annotations_of(item) 로 표현되는 타입에 따라 필터링한 결과type.

매개변수

item - 리플렉션 값
type - 타입 또는 타입 별칭의 리플렉션

반환값

각 요소 e 를 std::meta::annotations_of(item) 에서 포함하는 벡터, 여기서 std::meta::remove_const(std::meta::type_of(e)) 가 std::meta::remove_const(type) 과(와) 같으며, 순서가 유지됩니다.

예외

다음 경우에 예외 발생: std::meta::exception 만약 std::meta::annotations_of(item) 가 예외를 발생시키거나, 또는

  • std::meta::dealias(type) 가 타입을 나타내지 않거나, 또는
  • std::meta::is_complete_type(type) 가 false.

예제

#include <meta>

struct Option { bool value; };

struct C {
    [[=Option{true}]] int a;
    [[=Option{false}]] int b;
};

static_assert([:annotations_of_with_type(^^C::a, ^^Option)[0]:].value);
static_assert(![:annotations_of_with_type(^^C::b, ^^Option)[0]:].value);

int main() {}

참고 항목

리플렉션된 엔티티에 적용되는 어노테이션을 얻습니다
(함수)
리플렉션이 다음을 나타내는지 확인합니다: 어노테이션
(함수)
리플렉션된 엔티티의 상수 값의 리플렉션을 얻습니다
(함수)
(C++26)
리플렉션된 엔티티의 타입의 리플렉션을 얻습니다
(함수)