integral_constant.hpp 499 Bytes
Newer Older
1
2
3
4
#ifndef CK_INTEGRAL_CONSTANT_HPP
#define CK_INTEGRAL_CONSTANT_HPP

namespace ck {
5
6
7
8
9
10
11
12
13

template <class T, T N>
struct integral_constant
{
    static const T value = N;

    __host__ __device__ constexpr T Get() const { return value; }
};

Chao Liu's avatar
Chao Liu committed
14
template <class T, T X, T Y>
Chao Liu's avatar
Chao Liu committed
15
16
17
18
19
__host__ __device__ constexpr auto operator+(integral_constant<T, X>, integral_constant<T, Y>)
{
    return integral_constant<T, X + Y>{};
}

Chao Liu's avatar
Chao Liu committed
20
21
template <index_t N>
using Number = integral_constant<index_t, N>;
22
23
24

} // namespace ck
#endif