【发布时间】:2014-05-21 16:50:38
【问题描述】:
是否可以根据模板参数的 const 有条件地启用模板类的非 const/const 数据成员?或者也许有一些条件typedef?我考虑过将 std::enable_if 与 std::is_const 一起使用,但没有我可以使用的 std::is_not_const。
class A;
template <typename T>
class Test
{
A& m_a; // If T != const.
const A& m_a; // If T == const.
};
请注意,始终 T != A。
【问题讨论】: