문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top