为什么所有的迭代器/迭代器适配器不能移动在C ++ 11? [英] why should all iterators / iterator adaptors not-movable in C++11?
问题描述
在此问题中讨论何时在C ++ 11中使类型不可移动,我发现Scott Meyers在 comp.std.c ++ ,其中下面列出的类类型不能在C ++ 11 libeary中移动。
In this question discussed When to make a type non-movable in C++11 and I discovered Scott Meyers had similar question on comp.std.c++, where SG listed below class types are not movable in C++11 libeary.
- 所有互斥类型(recursive_mutex,timed_mutex,recursive_timed_mutex,
- condition_variable
- type_info
- error_category
- locale :: facet
- random_device
- seed_seq
- reference_wrapper
- 持续时间
- time_point
- 迭代器适配器 li>
- 所有原子类型
- once_flag
- all mutex types(recursive_mutex , timed_mutex, recursive_timed_mutex,
- condition_variable
- type_info
- error_category
- locale::facet
- random_device
- seed_seq
- reference_wrapper
- duration
- time_point
- - all iterators / iterator adaptors
- ios_base
- basic_istream::sentry
- basic_ostream::sentry
- all atomic types
- once_flag
为什么所有迭代器/迭代器适配器
不可移动?
推荐答案
职位,从标准批准之前的一年,是过时的。海报是丹尼尔·克鲁格勒,一个活跃的委员会成员,它有点政治游说:
That post, from a year before the standard was ratified, is outdated. The poster is Daniel Krügler, an active committee member, and it's a bit of political lobbying:
这些是不可移动的,意外,因为用于隐式生成移动操作的
规则在匹兹堡会议上变得澄清了
。已打开常规库问题
These aren't moveable and probably some more by accident, because the rules for implicitly generated move operations became clarified just at the Pittsburgh meeting. A general library issue has been opened
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#1331
以应对图书馆中缺乏移动支持。确保你
与你的国家机构代表联系,因为我怀疑这个
问题不足以取代国家机构对FCD的评论
。
to cope for lack of move support in the library. Be sure that you contact you national body representative, because I've heart that this issue is not a sufficient replacement for a national body comment against the FCD.
换句话说,所有那些不可移动的类型都将是标准的一个showstopper bug,他希望Usenet受众中的读者要求这个问题在标准成为官方之前固定。
In other words, all those types being non-movable would be a showstopper bug for the standard, and he wants readers in the Usenet audience to demand that the problem be fixed before the standard becomes official.
缺陷已移动到已关闭列表。解决方案是为了方便起见提供链接:
The defect has been moved to the "closed" list. The resolution is (link provided for convenience):
查看规范的库部分,并添加新添加的核心功能移动特殊成员函数( N3044 )。
由于N3044是一个重要的资料,很容易看出为什么这样的基本功能是必不可少的。
Since N3044 is a hefty bit of material, it's easy to see why it would be essential for such basic functionality to work.
迭代器,以及任何其他具有简单的价值语义如 std :: duration
和 std :: time_point
肯定是可移动的。正如其他人所提到的,可复制性意味着可移动性,如果没有,则会破坏语言。这个职位当时没有错。而是在争论未完成的语言的破碎。
Iterators, and anything else with simple value semantics like std::duration
and std::time_point
, are certainly movable. As others have mentioned, copyability implies movability, and if it didn't the language would be broken. This post wasn't wrong at the time; rather it's arguing about the brokenness of the unfinished language.
这篇关于为什么所有的迭代器/迭代器适配器不能移动在C ++ 11?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!