C++11 move构造判定(is_move_constructible)问题
之前的帖子结贴了,又没说清楚,就重开一帖,顺便散分
回顾:
前两天的帖子
http://topic.csdn.net/u/20120828/20/88cf9c19-7f9c-40b4-9726-f321a0bea64d.html
http://topic.csdn.net/u/20120903/15/c4000066-0247-431f-9d4a-c051f94ef595.html
stackoverflow上的一个帖子
http://stackoverflow.com/questions/7054952/type-trait-for-moveable-types
前景提要:is_move_constructible总是返回ture,没法返回false.
之前看了下gcc4.7的源码,确认is_move_constructible<void>::value会返回false.但当时的楼主说vs2012还是ture,而且提供了一个stackoverflow的帖子(上面有链接)
恰好昨天没事,就装了一个vs2012,用下面的代码测试了下,发现确实返回1(true)
#include <iostream>using namespace std;struct copy_only { copy_only(copy_only const&) {} // 屏蔽copy_only(copy_only&&)};int main(){ cout<<std::is_move_constructible<copy_only>::value<<endl; return 0;}
#include <iostream>using namespace std;struct copy_only { copy_only(copy_only& ) {} //当然这里不能加const,stackoverflow上面那个人应该是笔误};int main(){ cout<<std::is_move_constructible<copy_only>::value<<endl; return 0;}
using namespace std;struct copy_only { copy_only() = default; copy_only(copy_only&& ) = delete;};int main(){ cout<<std::is_move_constructible<copy_only>::value<<endl; return 0;}