原文: 知无涯之C++ typename的起源与用法
链接:http://feihu.me/blog/2014/the-origin-and-usage-of-typename/
template <typename C> // 模板申明
boost::optional<typename C::mapped_type> // 返回值定义
lookup(const C& dict, const typename C::key_type &key) // 函数签名
{
...
}
在看 Learning Boost C++ Libraries 这本书时,遇到上面这段代码,对
typename C::mapped_type
这部分感到疑惑,而上面这篇博客很好讲解了 typename 这个关键字,解决了我的困惑。