【发布时间】:2011-07-21 09:09:38
【问题描述】:
C++ 参考告诉我们一个 std::map
typedef pair<const Key, T> value_type;
是否可以强制 Key Type 不是 const ? 我需要在
之类的模板方法中执行此操作template<class T> // T represent a map in general (std::map, boost::unordered_map or whatever..)
void foo(const T& m)
{
typename T::value_type::first_type x;
x=0; // Wrong because x is const ...
}
【问题讨论】: