Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我猜从函数(如New()样式构造函数)返回的对象被移到外面,这是由编译器隐式完成的。
New()
Go中已经存在pointers隐式reference语义(slice、map、chan和闭包捕获),除了copy和move语义是对某些特定内存进行操作的另一种方式,它存在于内存效率中C++并Rust用于提高内存效率。
pointers
reference
slice
map
chan
copy
move
C++
Rust
Go中是否有移动语义[?]
不。
根据Go 官方文档,移动操作没有明确的语法。如果有的话,那将由编译器实现定义,而不是语言规范。