【发布时间】:2017-07-06 17:04:59
【问题描述】:
考虑:
template<typename X>
inline typename std::enable_if< std::is_pointer<X>::value, void>::type
replyOk(X pointer)
{
*pointer = *pointer; //for sake of example
}
是否可以为指向的数据添加常量,以便 *pointer = *pointer 产生编译器错误。
比如我可以做
...
replyOk(X const pointer)
...
但这增加了变量指针的常量性,而不是它指向的东西。我不确定这是否有意义......
【问题讨论】:
-
static_assert 呢? (我不确定你想在这里实现什么)
标签: c++ function templates constants