types_is_unbounded_array (std::is_unbounded_array - 무경계 배열 타입 판별)
std::is_unbounded_array는 주어진 타입이 경계가 알려지지 않은 배열(array of unknown bound)인지 확인하는 타입 특성(type trait)이에요. 이 특성은 C++20부터 사용할 수 있으며, 컴파일 타임에 타입의 속성을 검사하는 데 유용해요. 만약 타입 T가 T[] 형태의 무경계 배열이라면 value가 true가 되고, 그 외의 경우에는 false가 돼요.
출처: cppreference
본문
std::is_unbounded_array는 <type_traits> 헤더에 정의되어 있어요. 이 타입 특성은 std::integral_constant를 상속받아서 value라는 정적 상수 멤버를 제공하며, 이를 통해 컴파일 타임에 타입이 무경계 배열인지 판별할 수 있어요.
정의
| 헤더 |
<type_traits> |
|
| 템플릿 |
template < class T > struct is_unbounded_array ; |
(C++20부터) |
T가 알려지지 않은 경계의 배열 타입인지 검사해요. T가 무경계 배열 타입이면 value는 true이고, 그렇지 않으면 false예요.
프로그램에서 std::is_unbounded_array 또는 std::is_unbounded_array_v에 대한 특수화를 추가하는 경우, 그 동작은 정의되지 않아요(undefined behavior).
템플릿 매개변수
헬퍼 변수 템플릿
template < class T > constexpr bool is_unbounded_array_v = is_unbounded_array < T >:: value ; |
(C++20부터) |
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 > |
가능한 구현
template < class T > struct is_unbounded_array : std :: false_type {};
template < class T > struct is_unbounded_array < T [] > : std :: true_type {};
참고 사항
| 기능 테스트 매크로 |
값 |
표준 |
기능 |
__cpp_lib_bounded_array_traits |
201902L |
(C++20) |
std::is_bounded_array, std::is_unbounded_array |
예제
#include <type_traits>
class A {};
static_assert
(""
&& std::is_unbounded_array_v<A> == false
&& std::is_unbounded_array_v<A[]> == true
&& std::is_unbounded_array_v<A[3]> == false
&& std::is_unbounded_array_v<float> == false
&& std::is_unbounded_array_v<int> == false
&& std::is_unbounded_array_v<int[]> == true
&& std::is_unbounded_array_v<int[3]> == false
);
int main() {}
같이 보기
is_array (C++11) |
타입이 배열 타입인지 확인해요 (클래스 템플릿) [edit] |
is_bounded_array (C++20) |
타입이 경계가 알려진 배열 타입인지 확인해요 (클래스 템플릿) [edit] |
extent (C++11) |
배열 타입의 특정 차원 크기를 얻어요 (클래스 템플릿) [edit] |
is_unbounded_array_type (C++26) |
리플렉션이 무경계 배열 타입을 나타내는지 확인해요 (함수) [edit] |
더 알아보기 (Learn more)
cppreference