Skip to content

Commit a6b8e77

Browse files
committed
Fix tuple
1 parent 77f8f04 commit a6b8e77

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

include/gridtools/common/tuple.hpp

+25-25
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ namespace gridtools {
3030
tuple_leaf &operator=(tuple_leaf const &) = default;
3131
tuple_leaf &operator=(tuple_leaf &&) = default;
3232

33-
constexpr GT_FUNCTION tuple_leaf() noexcept : m_value() {}
33+
GT_CONSTEXPR GT_FUNCTION tuple_leaf() noexcept : m_value() {}
3434

3535
template <class Arg, enable_if_t<std::is_constructible<T, Arg &&>::value, int> = 0>
36-
constexpr GT_FUNCTION tuple_leaf(Arg &&arg) noexcept : m_value(wstd::forward<Arg>(arg)) {}
36+
GT_CONSTEXPR GT_FUNCTION tuple_leaf(Arg &&arg) noexcept : m_value(wstd::forward<Arg>(arg)) {}
3737
};
3838

3939
template <size_t I, class T>
@@ -45,12 +45,12 @@ namespace gridtools {
4545
tuple_leaf &operator=(tuple_leaf &&) = default;
4646

4747
template <class Arg, enable_if_t<std::is_constructible<T, Arg &&>::value, int> = 0>
48-
constexpr GT_FUNCTION tuple_leaf(Arg &&arg) noexcept : T(wstd::forward<Arg>(arg)) {}
48+
GT_CONSTEXPR GT_FUNCTION tuple_leaf(Arg &&arg) noexcept : T(wstd::forward<Arg>(arg)) {}
4949
};
5050

5151
struct tuple_leaf_getter {
5252
template <size_t I, class T>
53-
static constexpr GT_FUNCTION T const &get(tuple_leaf<I, T, false> const &obj) noexcept {
53+
static GT_CONSTEXPR GT_FUNCTION T const &get(tuple_leaf<I, T, false> const &obj) noexcept {
5454
return obj.m_value;
5555
}
5656

@@ -60,12 +60,12 @@ namespace gridtools {
6060
}
6161

6262
template <size_t I, class T>
63-
static constexpr GT_FUNCTION T &&get(tuple_leaf<I, T, false> &&obj) noexcept {
64-
return static_cast<T &&>(obj.m_value);
63+
static GT_CONSTEXPR GT_FUNCTION T &&get(tuple_leaf<I, T, false> &&obj) noexcept {
64+
return static_cast<T &&>(get<I>(obj));
6565
}
6666

6767
template <size_t I, class T>
68-
static constexpr GT_FUNCTION T const &get(tuple_leaf<I, T, true> const &obj) noexcept {
68+
static GT_CONSTEXPR GT_FUNCTION T const &get(tuple_leaf<I, T, true> const &obj) noexcept {
6969
return obj;
7070
}
7171

@@ -75,7 +75,7 @@ namespace gridtools {
7575
}
7676

7777
template <size_t I, class T>
78-
static constexpr GT_FUNCTION T &&get(tuple_leaf<I, T, true> &&obj) noexcept {
78+
static GT_CONSTEXPR GT_FUNCTION T &&get(tuple_leaf<I, T, true> &&obj) noexcept {
7979
return static_cast<T &&>(obj);
8080
}
8181
};
@@ -93,11 +93,11 @@ namespace gridtools {
9393
tuple_impl &operator=(tuple_impl &&) = default;
9494

9595
template <class... Args>
96-
constexpr GT_FUNCTION tuple_impl(Args &&... args) noexcept
96+
GT_CONSTEXPR GT_FUNCTION tuple_impl(Args &&... args) noexcept
9797
: tuple_leaf<Is, Ts>(wstd::forward<Args>(args))... {}
9898

9999
template <class Src>
100-
constexpr GT_FUNCTION tuple_impl(Src &&src) noexcept
100+
GT_CONSTEXPR GT_FUNCTION tuple_impl(Src &&src) noexcept
101101
: tuple_leaf<Is, Ts>(tuple_leaf_getter::get<Is>(wstd::forward<Src>(src)))... {}
102102

103103
GT_FORCE_INLINE void swap(tuple_impl &other) noexcept {
@@ -118,7 +118,7 @@ namespace gridtools {
118118
conjunction<std::is_assignable<Ts &, Args &&>...>::value,
119119
int> = 0>
120120
GT_FUNCTION void assign(tuple_impl<meta::index_sequence<Is...>, Args...> &&src) noexcept {
121-
void((int[]){(tuple_leaf_getter::get<Is>(*this) = tuple_leaf_getter::get<Is>(std::move(src)), 0)...});
121+
void((int[]){(tuple_leaf_getter::get<Is>(*this) = tuple_leaf_getter::get<Is>(wstd::move(src)), 0)...});
122122
}
123123
};
124124
} // namespace impl_
@@ -144,15 +144,15 @@ namespace gridtools {
144144

145145
struct getter {
146146
template <size_t I>
147-
static constexpr GT_FUNCTION auto get(tuple const &obj) noexcept GT_AUTO_RETURN(
147+
static GT_CONSTEXPR GT_FUNCTION auto get(tuple const &obj) noexcept GT_AUTO_RETURN(
148148
impl_::tuple_leaf_getter::get<I>(obj.m_impl));
149149

150150
template <size_t I>
151151
static GT_FUNCTION auto get(tuple &obj) noexcept GT_AUTO_RETURN(
152152
impl_::tuple_leaf_getter::get<I>(obj.m_impl));
153153

154154
template <size_t I>
155-
static constexpr GT_FUNCTION auto get(tuple &&obj) noexcept GT_AUTO_RETURN(
155+
static GT_CONSTEXPR GT_FUNCTION auto get(tuple &&obj) noexcept GT_AUTO_RETURN(
156156
impl_::tuple_leaf_getter::get<I>(wstd::move(obj).m_impl));
157157
};
158158
friend getter tuple_getter(tuple const &) { return {}; }
@@ -168,37 +168,37 @@ namespace gridtools {
168168
tuple &operator=(tuple const &) = default;
169169
tuple &operator=(tuple &&) = default;
170170

171-
constexpr GT_FUNCTION tuple(Ts const &... args) noexcept : m_impl(args...) {}
171+
GT_CONSTEXPR GT_FUNCTION tuple(Ts const &... args) noexcept : m_impl(args...) {}
172172

173173
template <class... Args,
174174
enable_if_t<sizeof...(Ts) == sizeof...(Args) && conjunction<std::is_constructible<Ts, Args &&>...>::value,
175175
int> = 0>
176-
constexpr GT_FUNCTION tuple(Args &&... args) noexcept : m_impl(wstd::forward<Args>(args)...) {}
176+
GT_CONSTEXPR GT_FUNCTION tuple(Args &&... args) noexcept : m_impl(wstd::forward<Args>(args)...) {}
177177

178178
template <class... Args,
179179
enable_if_t<sizeof...(Ts) == sizeof...(Args) &&
180180
conjunction<std::is_constructible<Ts, Args const &>...>::value,
181181
int> = 0>
182-
constexpr GT_FUNCTION tuple(tuple<Args...> const &src) noexcept : m_impl(src.m_impl) {}
182+
GT_CONSTEXPR GT_FUNCTION tuple(tuple<Args...> const &src) noexcept : m_impl(src.m_impl) {}
183183

184184
template <class... Args,
185185
enable_if_t<sizeof...(Ts) == sizeof...(Args) && conjunction<std::is_constructible<Ts, Args &&>...>::value,
186186
int> = 0>
187-
constexpr GT_FUNCTION tuple(tuple<Args...> &&src) noexcept : m_impl(wstd::move(src).m_impl) {}
187+
GT_CONSTEXPR GT_FUNCTION tuple(tuple<Args...> &&src) noexcept : m_impl(wstd::move(src).m_impl) {}
188188

189189
GT_FORCE_INLINE void swap(tuple &other) noexcept { m_impl.swap(other.m_impl); }
190190

191191
template <class Other>
192192
GT_FUNCTION auto operator=(Other &&other)
193-
GT_AUTO_RETURN((m_impl.assign(std::forward<Other>(other).m_impl), *this));
193+
GT_AUTO_RETURN((m_impl.assign(wstd::forward<Other>(other).m_impl), *this));
194194
};
195195

196196
template <class T>
197197
class tuple<T> {
198198
T m_value;
199199
struct getter {
200200
template <size_t I, enable_if_t<I == 0, int> = 0>
201-
static constexpr GT_FUNCTION T const &get(tuple const &obj) noexcept {
201+
static GT_CONSTEXPR GT_FUNCTION T const &get(tuple const &obj) noexcept {
202202
return obj.m_value;
203203
}
204204

@@ -208,7 +208,7 @@ namespace gridtools {
208208
}
209209

210210
template <size_t I, enable_if_t<I == 0, int> = 0>
211-
static constexpr GT_FUNCTION T &&get(tuple &&obj) noexcept {
211+
static GT_CONSTEXPR GT_FUNCTION T &&get(tuple &&obj) noexcept {
212212
return static_cast<T &&>(obj.m_value);
213213
}
214214
};
@@ -225,23 +225,23 @@ namespace gridtools {
225225
tuple &operator=(tuple const &) = default;
226226
tuple &operator=(tuple &&) = default;
227227

228-
constexpr GT_FUNCTION tuple(T const &arg) noexcept : m_value(arg) {}
228+
GT_CONSTEXPR GT_FUNCTION tuple(T const &arg) noexcept : m_value(arg) {}
229229

230230
template <class Arg, enable_if_t<std::is_constructible<T, Arg &&>::value, int> = 0>
231-
constexpr GT_FUNCTION tuple(Arg &&arg) noexcept : m_value(wstd::forward<Arg>(arg)) {}
231+
GT_CONSTEXPR GT_FUNCTION tuple(Arg &&arg) noexcept : m_value(wstd::forward<Arg>(arg)) {}
232232

233233
template <class Arg,
234234
enable_if_t<std::is_constructible<T, Arg const &>::value &&
235235
!std::is_convertible<tuple<Arg> const &, T>::value &&
236236
!std::is_constructible<T, tuple<Arg> const &>::value && !std::is_same<T, Arg>::value,
237237
int> = 0>
238-
constexpr GT_FUNCTION tuple(tuple<Arg> const &src) noexcept : m_value(src.m_value) {}
238+
GT_CONSTEXPR GT_FUNCTION tuple(tuple<Arg> const &src) noexcept : m_value(src.m_value) {}
239239

240240
template <class Arg,
241241
enable_if_t<std::is_constructible<T, Arg &&>::value && !std::is_convertible<tuple<Arg>, T>::value &&
242242
!std::is_constructible<T, tuple<Arg>>::value && !std::is_same<T, Arg>::value,
243243
int> = 0>
244-
constexpr GT_FUNCTION tuple(tuple<Arg> &&src) noexcept : m_value(wstd::move(src).m_value) {}
244+
GT_CONSTEXPR GT_FUNCTION tuple(tuple<Arg> &&src) noexcept : m_value(wstd::move(src).m_value) {}
245245

246246
GT_FORCE_INLINE void swap(tuple &other) noexcept {
247247
using std::swap;
@@ -256,7 +256,7 @@ namespace gridtools {
256256

257257
template <class Arg, enable_if_t<std::is_assignable<T &, Arg &&>::value, int> = 0>
258258
GT_FUNCTION tuple &operator=(tuple<Arg> &&src) noexcept {
259-
m_value = std::move(src).m_value;
259+
m_value = wstd::move(src).m_value;
260260
return *this;
261261
}
262262
};

0 commit comments

Comments
 (0)