TRIQS / nda

C++ library for multi-dimensional arrays
https://triqs.github.io/nda
Other
15 stars 12 forks source link

Problem with MemoryArray concept for array<T const> #28

Closed mmorale3 closed 1 year ago

mmorale3 commented 1 year ago

Prerequisites

Description

array<const T, N> doesn't satisfy MemoryArray concept.

The problem is in the definition of the MemoryArray concept:

/// Check if A is an Array and exposes its data() and its indexmap().strides() template concept MemoryArray = Array && requires(A &a) {

// We can acquire the pointer to the underlying data { a.data() } -> std::same_as<std::conditional_t<std::is_const_v, const get_value_t, get_value_t> *>;

// Exposes the memory stride for each dimension { a.indexmap().strides() } -> StdArrayOfLong; };

{ a.data() } -> std::same_as<std::conditional_t<std::is_const_v, const get_value_t, get_value_t> *>;

will fail for any array/array_view since get_value_t decays away qualifiers.

Additional Information

Error message from gcc 11,2

.../c++/nda/concepts.hpp:103:35: in requirements with 'A& a' [with A = nda::basic_array_view<const double, 2, nda::C_layout, 'A', nda::default_accessor, nda::borrowed>] .../c++/nda/concepts.hpp:106:11: note: 'a.data()' does not satisfy return-type-requirement, because 106 | { a.data() } -> std::same_as<std::conditional_t<std::is_const_v, const get_value_t, get_value_t> >; | ~~^~ .../c++/nda/concepts.hpp:106:5: error: deduced expression type does not satisfy placeholder constraints 106 | { a.data() } -> std::same_as<std::conditional_t<std::is_const_v, const get_value_t, get_value_t> >; | ^~~~~~~~~~~~~~~~~~~~~~~~

Wentzell commented 1 year ago

This should be fixed in commits 328cdfd and a9760b1, which were also applied to DEV_H5SLAB. Please confirm that the issue is resolved

Wentzell commented 1 year ago

Closing this, as it was fixed.