草庐IT

move_disc

全部标签

c++ - DICOM C_MOVE 与 gdcm 的 "CompositeNetworkFunctions"

我正在尝试使用gdcm的CompositeNetworkFunctions从服务器获取DICOMS.我的测试服务器是使用“Orthanc”设置的。当我运行Move请求时,我得到:terminatecalledafterthrowinganinstanceof'gdcm::Exception'what():/home/myname/Builds/GDCM/Source/Source/Common/gdcmException.h:74():当我捕获到那个异常时,我发现它是一个“未处理的异常”,没有更多信息。因此,我没有捕获它,而是使用gdb运行该程序。这是我得到的:0x00007ffff3

c++ - 如何判断一个类型是否真正可 move 构造

以这段代码为例:#include#includestructFoo{Foo()=default;Foo(Foo&&)=delete;Foo(constFoo&)noexcept{std::cout,"Fooshouldn'tbemoveconstructible");//Thiswoulderrorifuncommented//static_assert(!std::is_move_constructible_v,"Barshouldn'tbemoveconstructible");intmain(){Barbar{};BarbarTwo{std::move(bar)};//print

c++ - 使用隐式可转换对象调用 move 重载函数时出现编译错误

此程序不使用clang++test.cpp-std=c++0x编译:classA{public:A(){}A(constA&){}A(A&&){}A&operator=(constA&){return*this;}A&operator=(A&&){return*this;}};classB{Am_a;public:operatorconstA&()const{returnm_a;}};intmain(int,char**){Aa;Bb;a=b;//compileerror}编译错误:Appleclangversion3.0(tags/Apple/clang-211.10.1)(base

c++ - 确保 move 构造函数存在时永远不会调用复制构造函数

在设计一个可以move但不能复制的类时,很自然的会将复制构造函数声明为private。当只有可move和可简单复制的对象作为实例成员时,允许编译器隐式生成move构造函数是有意义的。但是,当同时支持VS11和G++4.7时,我发现不兼容:VS11需要明确定义的move构造函数G++要求显式move构造函数具有匹配的公共(public)复制构造函数或noexcept关键字。VS11不支持noexcept关键字。如您所见,这让我有点难堪。我的类(class)不得被复制。我必须支持VS11和MinGW/GCC。我需要我的类(class)是可move的。我是不是误解了什么,或者有解决这个小问题

c++ - move 初始化列表的元素是否安全?

这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:initializer_listandmovesemantics在这段代码中:#include#includetemplateclasssome_custom_container:publicstd::vector{public:some_custom_container(conststd::initializer_list&contents){for(auto&i:contents)this->emplace_back(std::move(i));}};classtest_class{};intmain()

c++ - 当参数被转发时,std::move 在参数列表中是否安全,而不是 move 构造?

试图为std::string_viewandstd::stringinstd::unordered_set提供解决方案,我正在尝试替换std::unordered_set与std::unordered_map>(该值为std::unique_ptr,因为小字符串优化意味着string的基础数据的地址不会始终作为std::move的结果传输)。我的原始测试代码似乎有效,是(省略标题):usingnamespacestd::literals;intmain(intargc,char**argv){std::unordered_map>mymap;for(inti=1;i(argv[i]);

c++ - vector 、 move 语义、nothrow 和 g++ 4.7

我编写了以下代码来理解move语义。它在g++-4.6中按预期工作(即没有复制,只move),但在g++-4.7.0中没有。我认为这是g++-4.7.0中链接的错误,但这个link说这不是g++-4.7中的错误。因此,正如我从上面的链接中理解的那样,我使move构造函数不抛出,但它仍然只执行复制。但是,如果我不抛出复制构造函数,则只会发生move。谁能解释一下?#include#includeusingnamespacestd;structS{intv;staticintccount,mcount;S(){}//nothrowconstructor//S(nothrow)(constS

c++ - 从 unordered_map move 键

我已经搜索过,但我只发现了关于使用映射值move构造函数的问题,但我想尝试一些不同的东西。是否可以使用std::move来自std::unordered_map的key?原因很简单:我想构建一个示例,在该示例中我从map创建一个vector,尽可能少地浪费内存。我知道这会弄乱map的表示,但是嘿,毕竟我再也不会使用map了,所以移出值是有意义的。我的猜测是:不,我不能那样做。不过,我想确认一下。这是一个简单的代码。我希望看到move构造函数被调用,但我调用了复制构造函数。干杯,谢谢!#include#include#include#include#includeclassprop{pu

c++ - 在构造函数初始化列表上 move shared_ptr

最近我看到了几个这样的代码示例,其中std::move用于构造函数初始化列表(而不是move构造函数)。classA{public:A(std::shared_ptrres):myRes(std::move(res)){//...}private:std::shared_ptrmyRes;}我得到的信息是这个结构是出于优化原因而设计的。我个人尽可能少用std::move。我威胁他们作为Actor(正如斯科特迈耶斯所说),并且只在调用者代码中(唯一的异常(exception)是move构造函数)。对我来说,这看起来像是某种混淆或微优化,但也许我错了。如果没有std::move,编译器不会

C++ 为什么在我的类中添加析构函数会使我的类无法 move ?

编译器提醒我正在使用已删除的函数。https://ideone.com/3YAIlA#includeusingnamespacestd;classfoo{public:unique_ptrp;~foo(){}};intmain(){fooa,b;a=move(b);return0;}编译信息prog.cpp:Infunction'intmain()':prog.cpp:15:4:error:useofdeletedfunction'foo&foo::operator=(constfoo&)'a=move(b);prog.cpp:3:7:note:'foo&foo::operator=(