In C++11 standard (clause 3.3.9/3) i found this code snippet:
template<class T, T* p, class U = T> class X { /∗ ... ∗/ };
Can anybody explain for me which possible (and usefull) code can contain in body of class X?
With usage of parameter p
ofcourse.
If foo
is a global object of type T
, you can pass a pointer-to-foo
to the template class X
.
As an example, suppose T
was an ostream
. I can create two logging types, which based on the type output to error or out. Their static
methods can even do it.
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