我给新的VS 2015预览一次尝试,我有一些问题的推动。但是在跟踪问题之后,我不明白它是如何在任何编译器上工作的。
我有一个unordered_map<K, boost::variant<std::unordered_map<int, std::unique_ptr<T>>>>。这无法编译,因为boost::variant显然试图复制-构造它内部的unordered_map -基于boost::is_nothrow_move_constructible特性的结果(实际上是boost::false_type )。
这揭示了boost::is_nothrow_move_constructible的定义为
template <class T>
struct is_nothrow_move_constructible_imp{
BOOST_STATIC_CONSTANT(bool, value =(
::boost::type_traits::ice_and<
::boost::type_traits::ice_or<
::boost::has_trivial_move_constructor<T>::value,
::boost::has_nothrow_copy<T>::value
>::value,
::boost::type_traits::ice_not< ::boost::is_array<T>::value >::value
>::value));
};呃,除了移动构造函数之外,其他不平凡的结构呢,就像很多类一样?这个定义如何在其他编译器上起作用?
发布于 2014-11-12 23:09:56
事实证明,这里真正的困惑在于它从未在Visual上工作过。我猜那一定是optional,而不是variant,我以前使用的是仅移动类型。看来,对于任何当前版本,variant实际上都不能支持Visual上的仅移动类型,而且我对它在VS2013上工作的记忆显然是不正确的。
最后,我只是对我所使用的类型进行了专门化。麻木不仁,但很有功能。
https://stackoverflow.com/questions/26897879
复制相似问题