rt,我正在尝试在 c++11 下写一个类似 c++17 std::any 的东西。
于是我写了这个:
template<typename _t>
inline constexpr _t& get()
{
return *((_t*)_data);
}
template<typename _t>
inline constexpr const _t& get()const
{
return *((const _t*)_data);
}
然后它本地编译成功,洛谷ide编译失败:错误:对重载的‘get()’的调用有歧义
但是如果我去掉 constexpr 就可以编译成功。
这是什么原因,c++11 不允许 constexpr 函数重载吗?(c++14 及以上可以编译通过)