This seems to be because in array.hpp the return type of array::data() const is marked constexpr but not const (constexpr makes the pointer type const, but not the pointed-to value).
constexpr T* data() const noexcept {
// ^
// |
// should be constexpr const T*!
return &_stor[0];
}
I'm not sure why it works when templated, though.
// compiles no problem
template <typename T>
class ConstArrayTest
{
public:
const T *data() const
{
return arr_.data();
}
private:
frg::array<T, 5> arr_;
};
ConstArrayTest<int> t;
Both examples compile with the GNU implementation of the C++ Standard Library, which does declare the return type const:
The following program fails to compile:
This seems to be because in
array.hpp
the return type ofarray::data() const
is markedconstexpr
but notconst
(constexpr
makes the pointer typeconst
, but not the pointed-to value).I'm not sure why it works when templated, though.
Both examples compile with the GNU implementation of the C++ Standard Library, which does declare the return type
const
: