Namespaces
Variants

std:: tuple_size <std::array>

From cppreference.net
헤더에 정의됨 <array>
template < class T, std:: size_t N >

struct tuple_size < std:: array < T, N > > :
std:: integral_constant < std:: size_t , N >

{ } ;
(C++11부터)

std::array 의 요소 개수에 컴파일 타임 상수 표현식으로 접근할 수 있도록 합니다.

목차

헬퍼 변수 템플릿

template < class T >
constexpr std:: size_t tuple_size_v = tuple_size < T > :: value ;
(C++17부터)

std:: integral_constant 에서 상속됨

멤버 상수

value
[static]
N , 배열의 요소 개수
(public static member constant)

멤버 함수

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

멤버 타입

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

예제

#include <array>
int main()
{
    auto arr = std::to_array("ABBA");
    static_assert(std::tuple_size<decltype(arr)>{} == 5);
}

참고 항목

Structured binding (C++17) 지정된 이름들을 초기화자의 하위 객체나 튜플 요소에 바인딩합니다
(C++11)
튜플과 유사한 타입의 요소 개수를 얻습니다
(클래스 템플릿)
tuple 의 크기를 얻습니다


(클래스 템플릿 특수화)

pair 의 크기를 얻습니다
(클래스 템플릿 특수화)
std::ranges::subrange 의 크기를 얻습니다
(클래스 템플릿 특수화)