Skip to content

Commit de2b42d

Browse files
authored
Fieldview by value (#24)
gridtools_verification was taking references to fields. this does not work nicely with passing gridtools data_stores by value.
1 parent ee17e1f commit de2b42d

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ project(gridtools-verification CXX C)
99

1010
include(ExternalProject)
1111

12-
set(GRIDTOOLS_VERIFICATION_VERSION_STRING "0.4")
12+
set(GRIDTOOLS_VERIFICATION_VERSION_STRING "0.5")
1313
set(SERIALBOX_VERSION_REQUIRED "2.2.1")
1414

1515
#----------------- CMake options

src/core/type_erased_field.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ namespace gt_verification {
136136
static_assert(
137137
std::is_same< typename FieldType::storage_t::data_t, T >::value, "internal error: types do not match");
138138

139-
type_erased_field_view_base(FieldType &field) : field_(field) {}
139+
type_erased_field_view_base(FieldType field) : field_(field) {}
140140

141141
virtual const T &access(int i, int j, int k) const noexcept override {
142142
return make_host_view(field_)(i, j, k);
@@ -189,7 +189,7 @@ namespace gt_verification {
189189
virtual void sync() noexcept override { field_.sync(); }
190190

191191
private:
192-
FieldType &field_;
192+
FieldType field_;
193193
};
194194

195195
template < typename FieldType, typename T >
@@ -320,15 +320,15 @@ namespace gt_verification {
320320
* @brief Create a TypeErasedFieldView from GridTools field (stores a reference to the field)
321321
*/
322322
template < class FieldType >
323-
type_erased_field_view(const FieldType &field) {
323+
type_erased_field_view(FieldType field) {
324324
static_assert(
325325
!internal::is_type_erased_field_view< FieldType >::value, "FieldType is not a GridTools field");
326326

327327
// The const cast is ugly here but the signature of this constructor needs to be the same as
328328
// the copy constructor. Hence, we need to capture the field by const ref.. maybe this can
329329
// be improved.
330330
base_ = std::make_shared< internal::type_erased_field_view_base< FieldType, T > >(
331-
const_cast< FieldType & >(field));
331+
field);
332332
}
333333

334334
/**

0 commit comments

Comments
 (0)