小编use*_*335的帖子

Rust如何提供移动语义?

锈语言网站索赔移动语义的语言的特征之一.但我无法看到Rust中如何实现移动语义.

Rust box是唯一使用移动语义的地方.

let x = Box::new(5);
let y: Box<i32> = x; // x is 'moved'
Run Code Online (Sandbox Code Playgroud)

上面的Rust代码可以用C++编写

auto x = std::make_unique<int>();
auto y = std::move(x); // Note the explicit move
Run Code Online (Sandbox Code Playgroud)

据我所知(如果我错了,请纠正我),

  • Rust根本没有构造函数,更不用说移动构造函数了.
  • 不支持右值参考.
  • 无法使用rvalue参数创建函数重载.

Rust如何提供移动语义?

move-semantics rust

37
推荐指数
3
解决办法
8225
查看次数

在C++中如何使用GC_malloc然后调用构造函数?

我在 C++ 中使用 Boehm 垃圾收集。使用GC_malloc分配后如何调用构造函数?

SomeClass *i = new SomeClass(); // Here the constructor is called.
SomeClass *j = (SomeClass *)GC_malloc(sizeof(SomeClass)); // How to call the constructor here?
Run Code Online (Sandbox Code Playgroud)

c++

4
推荐指数
1
解决办法
477
查看次数

如何使用LLVM IRBuilder从外部DLL调用函数?

如何从LLVM中调用外部DLL的函数?如何从LLVM代码调用DLL文件中定义的函数?

llvm

2
推荐指数
1
解决办法
1134
查看次数

标签 统计

c++ ×1

llvm ×1

move-semantics ×1

rust ×1