For the following code, what does std::uint64_t = 0 mean?
template< class T, std::uint64_t = 0 >
struct Dummy {
T value;
};
It's a non-type template parameter of type std::uint64_t with a default value of 0.
Note that the parameter is unnamed, so you can't use it directly in Dummy.
However, there are still several uses for this template parameter, e.g. you can use a different value for this parameter to select specializations of Dummy:
// specialization
template< class T>
struct Dummy<T, 42> {
// ...
};
Now Dummy<int> or Dummy<int, 0> will use the primary template, but Dummy<int, 42> will use the partial specialization. One of the common uses of this is in a technique called SFINAE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With