The difference in class and typename template programming of

For the most part interchangeable, but in some cases class can not be replaced typename, for example,

template< class T, class U > 
std::shared_ptr<T> static_pointer_cast( const std::shared_ptr<U>& r ) noexcept
{
    auto p = static_cast<typename std::shared_ptr<T>::element_type*>(r.get());
    return std::shared_ptr<T>(r, p);
}

In some cases, typename can not replace class

Guess you like

Origin www.cnblogs.com/hustcpp/p/11390296.html