std::meta::can_substitute
ko.cppreference.net 에서 발췌
| 헤더 <meta>
|
||
template< std::meta::reflection_range R = std::initializer_list<std::meta::info> >
consteval bool can_substitute( std::meta::info templ, R&& arguments );
|
(C++26 이후) | |
에 정의됨Ztempl이 나타내는 템플릿을, Args...은 arguments의 연속적인 요소들이 나타내는 값, 타입, 또는 템플릿이라고 할 때, Z<Args...>이 유효한 template-id인지 여부를 결정합니다.
true이 유효하고, 미확정 자리 반환 타입을 가진 함수를 지칭하지 않는 경우 Z<Args...>를 반환합니다. 그렇지 않으면 false를 반환합니다.
매개변수
| templ | - | 템플릿의 리플렉션 |
| arguments | - | 리플렉션의 범위 |
반환값
치환이 유효한지 여부를 나타내는 부울 값입니다.
예외
이 템플릿을 나타내지 않고, templ의 각 요소가 템플릿 인수로 적합한 구성을 나타내지 않는 경우 argumentsstd::meta::exception
을 던집니다.
참고 사항Z<Args...>즉시 컨텍스트 외부에서 형성
에 실패하면 프로그램은 ill-formed입니다.
예제
#include <meta>
#include <tuple>
static_assert(std::meta::can_substitute(^^std::tuple, {^^void}));
static_assert(can_substitute(^^std::tuple, {^^int, ^^int})); // using argument-dependent lookup
static_assert(!can_substitute(^^std::tuple, {std::meta::reflect_constant(42)}));
consteval
{
try
{
can_substitute(^^std::tuple, {^^::}); // Throws std::meta::exception
// the global namespace cannot be a template arg
} catch (std::meta::exception&) {}
}
int main() {}
이 코드 실행하기
substitute |
(C++26) 리플렉션된 템플릿에 리플렉션된 인수를 치환한 결과의 리플렉션을 얻습니다 (함수 템플릿) |
(C++26) |
값 또는 템플릿 매개변수 객체를 나타내며, 상수 템플릿 인수로 사용하기에 적합한 리플렉션을 반환합니다 (함수 템플릿) |
(C++26) |
객체를 나타내며, 상수 템플릿 인수로 사용하기에 적합한 리플렉션을 반환합니다 (함수 템플릿) |
(C++26) |
함수를 나타내며, 상수 템플릿 인수로 사용하기에 적합한 리플렉션을 반환합니다 (함수 템플릿) |