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

Chao Liu's avatar
Chao Liu committed
4
#include <type_traits>
5

Chao Liu's avatar
Chao Liu committed
6
namespace ck {
7

Chao Liu's avatar
Chao Liu committed
8
9
template <class T, T v>
using integral_constant = std::integral_constant<T, v>;
10

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
19
20
21
22
template <class T, T X, T Y>
__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
23
24
template <index_t N>
using Number = integral_constant<index_t, N>;
25
26
27

} // namespace ck
#endif