aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/array_size.h
blob: a56944b4aece3d2b898b88c4711ed775074ee4f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#pragma once

#include <cstddef>

namespace NArraySizePrivate {
    template <class T>
    struct TArraySize;

    template <class T, size_t N>
    struct TArraySize<T[N]> {
        enum {
            Result = N
        };
    };

    template <class T, size_t N>
    struct TArraySize<T (&)[N]> {
        enum {
            Result = N
        };
    };
}

#define Y_ARRAY_SIZE(arr) ((size_t)::NArraySizePrivate::TArraySize<decltype(arr)>::Result)