I\'ve implemented a constexpr
array like this:
template
class const_array {
const T* p;
unsigned n;
public:
template
The problem was that you cannot imbue the constant nature of the pointer to T in the inner template through the outer template's T parameter.
template class const_array {
const T * p;
unsigned n;
public:
template
constexpr const_array(const T(& a)[N]): p(a), n(N) { }
};
int main(int argc, char* argv[]) {
constexpr const_array ca{(const double []) { 1., 2. }};
return 0;
}
I tried a few dozen permutations to get rid of the cast without success.