is_move_constructible和msvc2013

Gui*_*e07 3 c++ move c++11

#include <iostream>
#include <type_traits> 

struct Foo 
{
    Foo(Foo&& f) = delete;
};

int main()
{

    std::cout << std::is_move_constructible<Foo>::value; // output is 1

    std::cin.ignore();
}
Run Code Online (Sandbox Code Playgroud)

在msv2013下我应该忘记一些东西,还是有错误?

APPENDUM:

#include <iostream>
#include <type_traits> 

struct Foo 
{ 
    ~Foo(){}
};

int main()
{
    std::cout << std::is_move_constructible<Foo>::value;

    std::cin.ignore();
}
Run Code Online (Sandbox Code Playgroud)

即使使用CTP,这个程序产生的输出为1(而c ++标准则相反),而CTP的第一个例子工作正常.

Lig*_*ica 5

是的,它一定是个bug.

is_move_constructible根据is_constructible这个定义,这要求具有给定参数的结构是良好的,这在这里显然不是这种情况.

[C++11: Table 49]: is_move_constructible<T>

is_constructible<T, T&&>::value 是真的

 

[C++11: 20.9.4.3/6]: 给出以下函数原型:

template <class T>
typename add_rvalue_reference<T>::type create();
Run Code Online (Sandbox Code Playgroud)

is_constructible<T, Args...>当且仅当以下变量定义适用于某些发明变量时,才应满足模板特化的谓词条件t:

T t(create<Args>()...);
Run Code Online (Sandbox Code Playgroud)

(下面的注释澄清了create这里用来避免所有人的最烦恼的解析Args.)

为了记录,输出是0GCC 4.8.


is_*constructible与抽象类相关的类似错误似乎在2013年中期得到修复,这是另一个:

微软发表于18/09/2013 at 13:17嗨,

感谢您报告此错误.我们已修复它,修复程序在VS 2013 RC中可用.

事实上,我们已经彻底改造,修复了所有已知错误.你可以在这里阅读更多相关信息:http: //blogs.msdn.com/b/vcblog/archive/2013/06/28/c-11-14-stl-features-fixes-and-breaking-changes-in- VS-2013.aspx

Stephan T. Lavavej
高级开发人员 - Visual C++ Libraries
stl@microsoft.com

该链接背后的更改日志包括以下修复:

类型特征的is_constructible族与引用行为不正确(DevDiv#517460)

所以,请再次参加MSVS 2013年11月的CTP.

更新:我被告知这在11月CTP中修复的.感谢Andy Prowl进行测试.