0

I have a constructor template (in non-template class) with a non-type template parameter, which is deduced from std::integral_constant. Is there a need to declare an object of std::integral_constant type that will be passed into the constructor constexpr? It seems superfluous.

Also I see that C++ standard libraries make objects for tag dispatching constexpr. Is there a real need for that? Since not a tag object is used at compile-time but its type.

Oleksa
  • 635
  • 5
  • 15

1 Answers1

0

If you want to create an instance of your class in compile-time code aka constexpr or consteval the constructor must be declared constexpr (or be implicit constexpr).

The code you posted as link contains no explicit constexpr constructors. But it defines constexpr variables.

Could you post your code?

Bernd
  • 2,113
  • 8
  • 22
  • The constructor is not `constexpr`. It's just a template, instantiation of which will be used at runtime. – Oleksa Feb 20 '21 at 19:34