有一个类似的问题:检查一个范围的元素是否可以移动?
我不认为其中的答案是一个很好的解决方案。实际上,它需要对所有容器进行部分专业化。
我做了尝试,但我不确定检查operator*()
是否足够。
// RangeType
using IteratorType = std::iterator_t<RangeType>;
using Type = decltype(*(std::declval<IteratorType>()));
constexpr bool canMove = std::is_rvalue_reference_v<Type>;