The following code will compile with GCC, but clang++ and icpc complain about a missing pair of braces at the end:
template < typename T, int m >
struct PowBogus {
static T pow(const T t) noexcept { return t; }
};
template < typename T, int... mm >
struct CompoundPow {
typedef std::array< T, sizeof...(mm) > return_type;
static return_type pow(T t) noexcept {
return {PowBogus< T, mm >::pow(t)...}; // error in clang, icc
}
static return_type pow_extra_brace(T t) noexcept {
return {{PowBogus< T, mm >::pow(t)...}}; // fine in clang, icc, gcc
}
};
I wonder why the extra pair of braces is necessary. My guess is that icpc and clang always interpret the pack expansion in braces as an initializer list, whereas gcc calls a std::array constructor. What does the standard have to say about this?
Aucun commentaire:
Enregistrer un commentaire