Python
Java
PHP
IOS
Android
Nodejs
JavaScript
Html5
Windows
Ubuntu
Linux
何时应在函数返回值上使用 std::move? [复制]
这个问题在这里已经有答案了 在这种情况下 struct Foo Foo meh return std move Foo 我很确定此举是不必要的 因为新创建的Foo将是一个 x 值 但在这样的情况下该怎么办呢 struct Foo Foo m
c
C11
movesemantics
为什么我要 std::move std::shared_ptr?
我一直在寻找铿锵源码 https clang llvm org doxygen CompilerInstance 8cpp source html l00069我发现了这个片段 void CompilerInstance setInvoca
c
C11
sharedptr
smartpointers
movesemantics
C++11 - 2 个向量之间的 emplace_back 不起作用
我试图调整一些代码并将内容从一个向量移动到另一个向量emplace back include
c
vector
C11
movesemantics
为什么局部变量的常量性会抑制返回值的移动语义?
struct STest public boost noncopyable STest STest test m n std move test m n explicit STest int n m n n int m n STest Fu
C11
Return
constants
movesemantics
rvaluereference
重载算术中的移动语义和右值引用传递
我正在用 C 编写一个小型数值分析库 我一直在尝试使用最新的 C 11 功能 包括移动语义 来实现 我理解以下帖子中的讨论和最佳答案 C 11 右值和移动语义混淆 return 语句 https stackoverflow com ques
c
C11
rvaluereference
movesemantics
复制/移动省略与显式删除的复制/移动构造函数
我想知道复制 移动省略何时适用 或允许适用 显式deleted 复制 移动构造函数和非deleted 复制 移动构造函数 具体如下 可以明确地deleted 复制 ctor 或移动 ctor 被删除 是否尝试从另一个相同类型的对象或临时对象
c
constructor
movesemantics
deleteoperator
copyelision
从自身内部替换 std::function (通过移动赋值给 *this?)
可以换一个吗std function从自身内部与另一个std function 以下代码无法编译 include
c
C11
movesemantics
stdfunction
thispointer
移动 lambda:一旦移动捕获了仅移动类型,如何使用 lambda? [复制]
这个问题在这里已经有答案了 这个答案 https stackoverflow com a 20669290 1858225解释了如何在 C 14 中移动捕获 lambda 中的变量 但是一旦你移动捕获了一个不可复制的对象 例如std uni
c
Lambda
c14
movesemantics
stdmove
默认的 Move 构造函数是否定义为 noexcept?
看起来向量会在重新分配时决定是否移动或复制元素之前检查移动构造函数是否标记为 noexcept 默认的移动构造函数是否定义为 noexcept 我看到了以下文档 但没有具体说明这一点 http en cppreference com w c
c
C11
constructor
movesemantics
我在这里使用 std::forward 还是 std::move ?
假设我有 template
c
C11
movesemantics
rvaluereference
Rust 有一天能在对象移动过程中优化掉按位复制吗?
考虑片段 struct Foo dummy u8 65536 fn bar foo Foo println p foo fn main let o Foo dummy 42u8 65536 println p o bar o 一个典型的该计
Rust
movesemantics
llvmcodegen
C++11 中返回本地值的最佳方式
在过去 如果我想要一个对象的字符串表示A 我会写一些带有签名的东西void to string const A a string out 以避免额外的副本 这是否仍然是 C 11 中的最佳实践 包括移动语义等 我读过一些关于其他上下文的评论
C11
copy
movesemantics
returnbyreference
returnbyvalue
使用常量数据成员或引用成员移动类的构造函数
我在理解何时以及是否调用移动构造函数或移动赋值运算符时遇到一些问题 特别是在具有常量数据成员的类的上下文中 考虑班级 template
c
constructor
C11
movesemantics
移动语义和原始类型
示例代码 int main std vector
c
C11
primitive
movesemantics
C++ 删除移动赋值运算符编译问题
以下代码在 gcc 4 8 0 mingw w64 中失败 并带有 O2 std c 11 frtti fexceptions mthreads include
c
C11
constructor
movesemantics
为什么不可变字符串可以调用 String::add(mut self, other: &str) [重复]
这个问题在这里已经有答案了 In stdlib字符串 rs impl Add lt str gt for String type Output String inline fn add mut self other str gt Strin
Rust
movesemantics
C++11 move(x) 实际上意味着 static_cast
(x)? [复制]
这个问题在这里已经有答案了 刚读完 Stroustrup 的 C 编程语言 第 4 版 他在第 7 章中说道 move x means static cast
c
C11
move
movesemantics
为什么抛出局部变量调用移动构造函数?
最近 我 玩弄 了右值来理解它们的行为 大多数结果并不让我感到惊讶 但后来我发现 如果我抛出一个局部变量 则会调用移动构造函数 在那之前 我认为移动语义规则的目的是保证仅当编译器可以检测到该对象将不再被使用 如在临时对象中 时才会移动 并变
c
Exception
C11
movesemantics
对于已构造的对象,使用 std::move 的 C++11 Push_back() 与 emplace_back() 的效率
在 C 11 中emplace back 通常优选 就效率而言 push back 因为它允许就地施工 但使用时仍然是这种情况push back std move 使用已经构建的对象 例如 是emplace back 在以下情况下仍然首选
C11
movesemantics
pushback
emplace
移动语义中的“常规类型”是什么?
Alex Stepanov 定义了常规类型 http www stepanovpapers com DeSt98 pdf作为满足复制和相等性某些属性的类型 现在 C 11 已将移动语义添加到泛型编程领域 Stepanov 的定义不再完整 我
c
generics
C11
movesemantics
«
1
2
3
4
5
6
7
»