Skip to content

Commit 5942d20

Browse files
Switch from SFINAE to static_assert so that we can give a better error message.
1 parent 9aaa291 commit 5942d20

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

spiner/databox.hpp

+8-11
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,15 @@ class DataBox {
165165
// Index operators
166166
// examle calls:
167167
// T x = db(n4, n3, n2, n1);
168-
template <typename... Args,
169-
typename transform_t = Transform, // only for SFINAE
170-
typename std::enable_if<std::is_same<
171-
transform_t, TransformLinear>::value>::type * = nullptr>
172-
PORTABLE_INLINE_FUNCTION T &operator()(Args... args) {
173-
return dataView_(std::forward<Args>(args)...);
174-
}
175-
template <typename... Args,
176-
typename transform_t = Transform, // only for SFINAE
177-
typename std::enable_if<std::is_same<
178-
transform_t, TransformLinear>::value>::type * = nullptr>
168+
template <typename... Args>
179169
PORTABLE_INLINE_FUNCTION T &operator()(Args... args) const {
170+
static_assert(std::is_same<Transform, TransformLinear>::value,
171+
"DataBox::operator() is only available if the independent "
172+
"variable data transform is Spiner::TransformLinear, because "
173+
"otherwise accessing the underlying data is not doing what you "
174+
"expect. Use DataBox::get_data_value and DataBox::set_data_value "
175+
"instead, because those correctly account for the independent "
176+
"value data transformation.");
180177
return dataView_(std::forward<Args>(args)...);
181178
}
182179

0 commit comments

Comments
 (0)