estática constexpr puntero a función, diferencia entre compiladores
Al contestaresta pregunta, Probé el siguiente código con gcc (código compilado) y clang (código rechazado):
typedef long (*func)(int);
long function(int) { return 42; }
struct Test
{
static constexpr func f = &function;
};
template<func c>
struct Call
{
static void f()
{
c(0);
}
};
int main()
{
Call<Test::f>::f();
}
No estoy seguro de qué compilador es correcto, aunque creo que la inicialización de constexpr deTest::f
esta bien El error clang salidas es:
error: non-type template argument for template parameter of pointer type 'func'
(aka 'long (*)(int)') must have its address taken
¿Qué compilador tiene razón?Si clang tiene razón, ¿por qué y qué significa realmente este error?EDITAR: para el "por qué", verPregunta de DyP.