"sgl-router/vscode:/vscode.git/clone" did not exist on "7c94eaeeb0f4d57f0379944c19e831c74b742e54"
integral_constant.hpp 404 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
#pragma once

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
11
template <class T, T X, T Y>
Chao Liu's avatar
Chao Liu committed
12
13
14
15
16
__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
17
18
template <index_t N>
using Number = integral_constant<index_t, N>;