Python
Java
PHP
IOS
Android
Nodejs
JavaScript
Html5
Windows
Ubuntu
Linux
将自定义对象添加到向量时如何启用移动语义?
下面的代码将包含大向量的对象传递到向量中 我希望这是高性能的 我需要投吗test在调用中右值push back 我需要告诉编译器如何移动结构体的实例吗Test 或者这一切都是自动进行的 int main struct Test std ve
c
C11
movesemantics
C++11:按值调用、移动语义和继承
假设我有一个类 我计划直接将其公开为可实例化类 给程序员 class Base public Base std string text m text std move text private std string m text 到目前为止
c
inheritance
C11
move
movesemantics
移动赋值运算符和移动构造函数之间的区别?
一段时间以来 这一直让我感到困惑 而且到目前为止我还没有找到满意的答案 问题很简单 什么时候有一个move assignment operator接到电话 什么时候move constructor operator接到电话吗 cpprefe
c
C11
constructor
movesemantics
与移动构造函数配对时发生意外的析构函数调用
以下代码是在 Visual Studio 2012 Express for Windows Desktop 中编译并运行的 作为学习练习 include
c
visualc
C11
visualstudio2012
movesemantics
引用限定符 `const &&` 有什么用?
继上一个问题之后 我一直在研究 ref qualifiers 给出下面的代码示例 include
c
C11
languagelawyer
movesemantics
rvaluereference
C++0x 中的特殊成员函数
维基百科文章关于特殊成员函数 http en wikipedia org wiki Special member functions不包含任何对移动构造函数和移动赋值运算符的引用 我想更新该条目 但我不确定 0x 标准的内容 这两个函数的规
c
constructor
C11
assignmentoperator
movesemantics
通过 destruct+move 构造进行的移动分配安全吗?
这是使用移动构造函数为大多数类定义移动赋值的一种非常简单的方法 class Foo public Foo Foo foo you still have to write this one Foo operator Foo foo if th
c
C11
movesemantics
placementnew
moveassignmentoperator
我可以将移动的变量标记为不再可用,并在使用它时收到编译器警告吗?
有时在我使用的函数中std move传递我不再使用的变量 如下所示 void f std vector
c
movesemantics
成员函数 .begin() 和 std::begin()
调用成员函数 begin of std vector and std begin 右值会导致不同的输出 如以下测试所示 vector
c
C11
Iterator
move
movesemantics
默认定义的移动构造函数的 noexcept 规则是什么?
特别是与std vector重要的是类型是noexcept尽可能移动 所以在声明移动构造函数时 default like in struct Object1 Object1 Object1 other default std is noth
c
C11
movesemantics
pimplidiom
noexcept
Rcpp 和移动语义
我实现了一个算法C 返回一个巨大的元素数组作为输出 现在 我想实现一个包装器Rcpp这样我就可以使用调用这个函数R 我在 Makevars 文件中指定了以下设置 PKG CXXFLAGS std c 11 这样我就可以使用C 11版本了 R
c
C11
rcpp
movesemantics
为什么从初始化列表启动向量时不使用移动构造(通过隐式构造函数)
为了演示移动语义 我编写了以下示例代码 其中包含 int 的隐式构造函数 struct C int i 0 C C int i i i C const C other i other i std cout lt lt A copy cons
c
c14
movesemantics
initializerlist
为什么 C++11 对值参数有隐式移动,但对右值参数没有隐式移动?
在 C 11 中 值参数 和其他值 在返回时享受隐式移动 A func A a return a uses A A A if it exists 至少在 MSVC 2010 中 右值引用参数需要std move A func A a ret
c
C11
movesemantics
rvaluereference
C20
我可以列表初始化仅移动类型的向量吗?
如果我通过 GCC 4 7 快照传递以下代码 它会尝试复制unique ptrs 进入向量 include
c
C11
initializerlist
movesemantics
防止移动 unique_ptr C++11
有什么方法可以阻止用户显式获取唯一指针的所有权 std move Make it const The unique ptr移动构造函数需要一个非常量右值引用 因此不能用 a 调用const object const unique ptr
c
C11
movesemantics
uniqueptr
是否应该在构造函数链中使用移动语义?
假设我有以下两个类 class Person public Person string name string surname name move name surname move surname private string name
c
C11
movesemantics
了解左值/右值表达式与对象类型
我读过一些之前的最佳答案以及 Stroustrup 的 C 编程语言 和 Effective Modern C 但我很难真正理解表达式的左值 右值方面与其类型之间的区别 在 Effective Modern C 的简介中说 确定表达式是否为
c
C11
move
movesemantics
将两个对象(其中一个对象持有对另一个对象的引用)传递到线程中
我有两个对象 其中第二个对象需要第一个对象比它更长寿 因为它保存对第一个对象的引用 我需要将它们移到一个线程中 但编译器抱怨第一个线程的寿命不够长 这是代码 use std thread trait Facade Sync fn add s
reference
Rust
movesemantics
lifetime
lifetimescoping
具有嵌入式竞技场的堆栈分配器问题
我在使用 Howard Hinnant 时遇到崩溃基于堆栈的分配器 http howardhinnant github io stack alloc h 都在 MacOS 和 64 位 Linux 上的 Clang 3 4 这是一个最小的例
c
C11
movesemantics
allocator
禁止复制操作会自动禁止移动操作吗? [复制]
这个问题在这里已经有答案了 我想编写一个没有任何复制和移动语义的 C 类 我只对其构造函数和析构函数感兴趣 我禁用了复制操作 即复制构造函数和复制赋值运算符 明确地使用 C 11 delete语法 例如 class MyClass publ
c
C11
movesemantics
«
1
2
3
4
5
6
7
»