假设someAtomic是一个具有整体基础类型的std :: atomic,如atomic_uint16_t。我不想担任哪种整数类型,然而,在特定的代码,所以我想要的东西来完成;下面,现在不能编译:原子类型的numeric_limits
if (newVal > numeric_limits<decltype(someAtomic)>::max()) throw "newVal too large";
else someAtomic.store(newVal, memory_order_release);
看起来至少在VC++ 2015年,对于原子类型没有numeric_limits专业化,即使它们的基础类型确实有这样的专业化。处理这个问题的最好方法是什么?
我不确定是否允许您将标准模板与标准库中的类型专用 – KABoissonneault
如果允许,我会非常惊讶。你可以备份你的声明吗? – hvd