相关疑难解决方法(0)

问题与is_copy_constructible

类型特征是否应该能够处理诸如std::vector < std::unique_ptr <int> >并且检测到它不是可复制构造的情况?

以下是https://ideone.com/gbcRUa(运行g ++ 4.8.1)的示例

#include <type_traits>
#include <vector>
#include <iostream>
#include <memory>

int main()
{
    // This prints 1, implying that it's copy constructible, when it's clearly not
    std::cout << std::is_copy_constructible< std::vector<std::unique_ptr<int> > >::value << std::endl; 
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

如果这是正确的行为is_copy_constructible,有没有办法检测复制结构是否形成错误?好吧,除了让它无法编译之外.

c++ type-traits c++11 g++4.8

14
推荐指数
1
解决办法
1265
查看次数

标签 统计

c++ ×1

c++11 ×1

g++4.8 ×1

type-traits ×1