es.davy.ai

Preguntas y respuestas de programación confiables

¿Tienes una pregunta?

Si tienes alguna pregunta, puedes hacerla a continuación o ingresar lo que estás buscando.

Tag: IF-CONSTEXPR

C++ si constexpr vs especialización de plantillas

Considere estos 2 ejemplos Ejemplo 1 template<Type type> static BaseSomething* createSomething(); template<> BaseSomething* createSomething<Type::Something1>() { return Something1Creator.create(); } template<> BaseSomething* createSomething<Type::Something2>() { return Something2Creator.create(); } …. // otros somethings Ejemplo 2 template<Type type> static BaseSomething* createSomething() { if constexpr(type == Type::Something1) { return Something1Creator.create(); } else if constexpr(type == Type::Something2) . . . Read more