forked from cms-patatrack/pixeltrack-standalone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cuda_cxx17.h
63 lines (48 loc) · 1.48 KB
/
cuda_cxx17.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#ifndef HeterogeneousCore_CUDAUtilities_cuda_cxx17_h
#define HeterogeneousCore_CUDAUtilities_cuda_cxx17_h
#include <initializer_list>
// CUDA does not support C++17 yet, so we define here some of the missing library functions
#if __cplusplus <= 201402L
namespace std {
// from https://en.cppreference.com/w/cpp/iterator/size
template <class C>
constexpr auto size(const C& c) -> decltype(c.size()) {
return c.size();
}
template <class T, std::size_t N>
constexpr std::size_t size(const T (&array)[N]) noexcept {
return N;
}
// from https://en.cppreference.com/w/cpp/iterator/empty
template <class C>
constexpr auto empty(const C& c) -> decltype(c.empty()) {
return c.empty();
}
template <class T, std::size_t N>
constexpr bool empty(const T (&array)[N]) noexcept {
return false;
}
template <class E>
constexpr bool empty(std::initializer_list<E> il) noexcept {
return il.size() == 0;
}
// from https://en.cppreference.com/w/cpp/iterator/data
template <class C>
constexpr auto data(C& c) -> decltype(c.data()) {
return c.data();
}
template <class C>
constexpr auto data(const C& c) -> decltype(c.data()) {
return c.data();
}
template <class T, std::size_t N>
constexpr T* data(T (&array)[N]) noexcept {
return array;
}
template <class E>
constexpr const E* data(std::initializer_list<E> il) noexcept {
return il.begin();
}
} // namespace std
#endif
#endif // HeterogeneousCore_CUDAUtilities_cuda_cxx17_h