腾讯云
开发者社区
文档
建议反馈
控制台
首页
学习
活动
专区
工具
TVP
最新优惠活动
文章/答案/技术大牛
搜索
搜索
关闭
发布
登录/注册
精选内容/技术社群/优惠产品,
尽在小程序
立即前往
文章
问答
(9999+)
视频
沙龙
2
回答
为什么insert in
std
::unordered_set
调用
复制
构造
函数
?
c++
、
insert
、
unordered-set
);void add(const
std
::
unique_ptr
<int>::
move
(val)); } 这是不能编译
的
。它给了我们 状态错误C2280
浏览 55
提问于2021-04-23
得票数 3
回答已采纳
4
回答
如何防止客户端将nullptr传递给
构造
函数
?
c++
、
c++11
、
constructor
、
unique-ptr
对于期望
std
::
unique_ptr
的
构造
函数
,如何有效地防止客户端传递nullptr?class Foo{ myBar(
std
::
move
(bar))} 我是否可以用nullptr_t参数重载
构造
函数
,然后将其设置为
已
删除
,以便在编译
时<
浏览 7
提问于2014-06-06
得票数 6
回答已采纳
1
回答
返回值优化不适用于const
unique_ptr
成员?
c++
、
copy-constructor
、
unique-ptr
我有一个类整体,它通过
unique_ptr
保存类部件
的
一个对象。由于我没有为整个复制
构造
函数
提供副本
构造
函数
,所以由于
unique_ptr
成员,复制
构造
函数
将被
删除
。以下是代码:}; public: Whole(
std
::
unique_ptr
<Part> part) : part(
std
浏览 3
提问于2016-03-09
得票数 3
回答已采纳
1
回答
只移动继承
构造
函数
中
的
类参数
c++
、
gcc
、
c++14
、
move-semantics
::
unique_ptr
<int>)' 它似乎试图
调用
已
删除
的
复制
构造
函数
move
构造
函数
(可能是省略)。最新标准草案
的
说: 1当
调用
B类型
的
构造
函数</e
浏览 3
提问于2016-05-06
得票数 4
1
回答
unique_ptr
,您在引用一个
已
删除
的
函数
c++
、
c++14
、
unique-ptr
我正在尝试将一个
unique_ptr
移动到WriteAsync方法。这如预期
的
那样起作用。QueueMessage需要一个
std
::
unique_ptr
<
std
::vector<char>>。 在这种情况下,简单
的
方法是只
使用
shared_ptr。我想知道是否有一种不用
使用
shared_ptr就能使其工作
的
方法。QueueMessage(
std
::
move
( buffer
浏览 0
提问于2018-08-19
得票数 1
回答已采纳
1
回答
在
move
构造
函数
中
调用
std
::
move
on
unique_ptr
时
出现"error: use of deleted function“
c++
、
c++11
、
move
::
move
( rhs.a );
std
::
unique_ptr
<int> a;此代码不能
使用
g++ 4.8.4进行编译,并抛出以下错误:::operator=(const
std</e
浏览 17
提问于2017-03-06
得票数 11
回答已采纳
1
回答
将不可复制
的
对象移动到向量中。
c++11
::
unique_ptr
<A> pA;{
std
::vector<B> vb; /usr/include/c++/4.7/bits/stl_construct.h:77:7: error: use of deleted function ‘B::B(const B&)’ 谁在
调用
<em
浏览 3
提问于2015-07-05
得票数 1
回答已采纳
1
回答
std
::
unique_ptr
中不可复制
的
删除
c++
、
c++11
、
move
、
unique-ptr
我一直在寻找另一个问题()
的
解决方案。似乎应该可以为可以解锁互斥锁
的
unique_ptr
实例创建自定义
删除
器。{
std
::
unique_ptr
<int, LockDeleter> ptr(new int(42), LockDeleter(moo));}在VS2013 express下编译它,我得到 错误1错误C2280:'
std
::unique_lock::uniqu
浏览 1
提问于2014-05-12
得票数 2
回答已采纳
3
回答
移动
构造
函数
和移动赋值
构造
函数
在所需
的
唯一指针中是什么?
c++
、
c++11
、
smart-pointers
、
move-semantics
、
unique-ptr
我有一个简化
的
unique_ptr
示例。我想知道唯一指针中
的
移动
构造
函数
和移动赋值操作符需要什么?如果我理解正确地移动
构造
函数
(并传递rvalue),那么这两行代码
的
结果应该是相同
的
。UniquePointer<T> a(new T);以下是简化
的
UniquePointer代码: templ
浏览 5
提问于2015-05-22
得票数 0
回答已采纳
1
回答
调用
`
std
::
unique_ptr
`
move
构造
函数
时
“
使用
已
删除
的
函数
”?
c++
、
constructor
、
smart-pointers
、
move-semantics
在定义一个接受对
std
::
unique_ptr
对象
的
移动引用
的
函数
时
,我面临着一个编译问题。::
unique_ptr
<foo>&& arg){} int main(int argc, char const *argv[function ‘
std
::
unique_ptr
<_Tp,
浏览 59
提问于2020-05-03
得票数 3
回答已采纳
4
回答
对unique_ptrs列表进行排序
c++
、
smart-pointers
以下代码将不编译:{} {
unique_ptr
<int> ptr2(new int(2));
unique_ptr
<int>
的
复制
构造</e
浏览 0
提问于2018-05-20
得票数 2
回答已采纳
1
回答
在
构造
函数
内
使用
C++中
的
unique_ptr
初始化向量
c++
、
smart-pointers
、
initializer-list
我是C++新手,在阅读了大量关于移动语义和唯一指针(以及初始化器列表)
的
内容之后,我明白了为什么这段代码不能工作(抛出“尝试引用
已
删除
函数
”): : term(
std
::vector<
std
::
unique_ptr
<term>> {
std
::
mo
浏览 54
提问于2018-05-31
得票数 3
回答已采纳
2
回答
C++无法移动具有通用引用
的
unique_ptr
c++
、
c++11
、
move-semantics
、
unique-ptr
、
universal-reference
请考虑以下代码:T mov(T&& t){}
std
::
unique_ptr
<int> a =
std
::
unique_ptr
<int>(new int());} mov
函数
浏览 12
提问于2014-07-22
得票数 4
回答已采纳
1
回答
在合并
unique_ptr
的
两个向量
时
“
删除
函数
的
使用
”
c++
、
c++11
、
move-semantics
、
unique-ptr
、
deleted-functions
我试图将
unique_ptr
的
两个向量合并(即从一个向量到另一个向量),并不断地遇到“
使用
已
删除
的
函数
.”错误文本墙。根据错误,我显然试图
使用
unique_ptr
删除
的
复制
构造
函数
,但我不知道为什么。::vector<
std
::
unique_ptr
<Foo>> foos; void add(<e
浏览 3
提问于2016-04-24
得票数 3
回答已采纳
1
回答
将一对移动到向量中
c++
、
c++11
、
move
、
std-pair
,
std
::true_type) col.insert(col.end(),
std
::
move
(element));如果T是可移动
的
,则
调用
它。>和T=
std
::pair<
std
::
unique_ptr
<..>, bool>
调用
这个
函数
,但是编译器会抱怨
unique_ptr
和结对
的
已
删除
<em
浏览 2
提问于2015-09-08
得票数 2
回答已采纳
1
回答
无法移动性病::任何
c++
、
c++17
、
move
、
move-semantics
、
stdany
以下代码auto m =
std
::unordered_map<int,
std
::any>{};无法编译,抱怨
使用
已
删除
的
unique_ptr
复制
构造
函数
。在模板参
浏览 2
提问于2019-05-29
得票数 0
回答已采纳
1
回答
unique_ptr
作为类成员和移动语义无法
使用
clang进行编译
compiler-errors
、
unique-ptr
、
llvm-clang
(new A(*x.ptr)) { } Cl(
std
::
unique_ptr
<A> p) : ptr(
std
::
move
(p)) { } ptr =
std
::
unique_ptr
<
浏览 0
提问于2013-07-18
得票数 1
回答已采纳
2
回答
不传递所有权传递
unique_ptr
<T>
的
unique_ptr
<T>向量
c++
、
c++11
、
move
、
smart-pointers
、
unique-ptr
我有一个类Outer,它包含一个Inner成员,拥有,一个
unique_ptr
元素
的
向量: { } Elements _vec; // T
浏览 1
提问于2019-06-26
得票数 1
回答已采纳
1
回答
为什么
调用
的
是复制
构造
函数
而不是移动
构造
函数
?
c++
、
c++11
、
move-constructor
std
::
move
(test))private:
std
::
unique_ptr
<
std
::string> test; Outer2012上编译上面的
浏览 2
提问于2013-12-17
得票数 3
1
回答
std
::make_shared、
std
::
unique_ptr
和
move
构造
函数
c++
、
stl
、
c++11
、
clang
foo =
std
::make_shared<Foo>("aaa");} Clang抱怨
删除
构造
函数
的
用法。对我来说,这是没有意义
的
,因为
std
::make_shared不应该复制Foo实例,这是唯一会触发对
std
::
unique_ptr
(
已
删除
的
)复制
构造
函数
的
<
浏览 3
提问于2011-12-19
得票数 12
回答已采纳
点击加载更多
扫码
添加站长 进交流群
领取专属
10元无门槛券
手把手带您无忧上云
相关
资讯
智能指针:让C+程序更加安全和高效的神器
实现线程安全队列——细粒度锁实现
C+11 shared_ptr智能指针(超级详细)
Visual Studio:优化了复制/移动省略
C+11并发编程:多线程std:thread
热门
标签
更多标签
云服务器
即时通信 IM
ICP备案
对象存储
实时音视频
活动推荐
运营活动
广告
关闭
领券