Suppose I have a template class with int parameter:
template <int Param>
class myclass
{
// ...
}
And I want to implement, for example, a cast function from one int-parametrized to another:
template <int Param, class T>
myclass<Param> myclass_cast(const T& other)
{
// ... some logic
}
How can I statically determine that T
is a templated class myclass<N>
? (I can use C++14).
Instead of having a template parameter of T
, you can deduce the parameter of the myclass
specialization you pass in:
template <int Param, int Other>
myclass<Param> myclass_cast (const myclass<Other>& other)
{
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.