腾讯云
开发者社区
文档
建议反馈
控制台
首页
学习
活动
专区
工具
TVP
最新优惠活动
文章/答案/技术大牛
搜索
搜索
关闭
发布
登录/注册
精选内容/技术社群/优惠产品,
尽在小程序
立即前往
文章
问答
(9999+)
视频
沙龙
1
回答
为什么
不
能将
std
::
make_unique
<
S
>
作为
函数
参数
传递
?
c++
、
c++11
、
templates
、
unique-ptr
有没有人能解释清楚
为什么
只有一个模板
参数
,即
S
,就可以调用
std
::
make_unique
<
S
>,就像这样: auto p =
std
::
make_unique
<
S
>(12, 13); 但是,我不
能将
std
::
make_unique
<
S
>
传递
给
函数
来为我做这件事,如下所示: template
浏览 53
提问于2021-08-05
得票数 2
回答已采纳
1
回答
如何使用
make_unique
构造数组
c++
、
unique-ptr
、
raii
、
stdarray
如何使用
std
::
make_unique
构造
std
::array#include <iostream>#include<memory> { const
std
::unique_ptr<
std
::array<int, 1'000'000> > uptr1( n
浏览 10
提问于2022-01-04
得票数 0
回答已采纳
2
回答
试图使用初始化程序列表构造` `
std
::vector`‘的问题
c++
、
c++11
、
vector
、
initializer-list
<A>> as1 = {
std
::
make_unique
<A>({1}), as3.push_back(
std
::
make_uniqu
浏览 21
提问于2017-07-16
得票数 0
2
回答
为什么
std
::initializer_list重载不存在于
std
::
make_unique
等人身上?
c++
、
c++11
、
c++-standard-library
、
uniform-initialization
Args> unique_ptr<T>
make_unique
(Args&&... args); auto
s
1 =
std
::
make_unique
<foo>(3, 1).get()->size(); auto
s
2 =
std
::
make_unique
<foo>(1).get()-&g
浏览 6
提问于2016-05-11
得票数 5
2
回答
使用
std
::forward和rvalue的
函数
模板
c++
给定“C++编程语言第4版”中的下列
函数
模板:unique_ptr<TT>
make_unique
(int i, A && a){} A绝对是一个rvalue,因此
make_unique
函数
似乎在堆上分配其内容,并将
浏览 7
提问于2013-08-22
得票数 1
回答已采纳
1
回答
std
::
make_unique
可以将
函数
的输出
作为
参数
吗?
c++
、
smart-pointers
、
unique-ptr
是否有一种使用
make_unique
并将
函数
的输出
作为
参数
传递
的方法?=
std
::
make_unique
<SDL_Surface, SurfaceDeleter>();autoloadedSurface3 =
std
::
make_unique
<SDL_Surface, SurfaceDeleter>(IMG_Load
浏览 0
提问于2019-05-03
得票数 1
回答已采纳
1
回答
当
std
::
make_unique
<T>()赋值给
std
::unique_ptr<T>时会发生什么?
c++
、
c++11
、
smart-pointers
我对
std
::unique_ptr有一个疑问。 int a, b; A(int w, int e) : a(w), b(e) {} A h(1, 2);
std
浏览 0
提问于2018-12-31
得票数 0
1
回答
如何在
std
::unique_ptr的
std
::vector上使用remove_if?
c++
、
stl
、
unique-ptr
由于忘记了让我的lambda
不
尝试复制
参数
,我搜索了解释,并在中找到了它。但是,当我尝试通过引用或const ref
传递
我的lambda
参数
时,就像在那里和其他关于这个问题的问题一样,我仍然得到了'
std
::unique_ptr<int,
std
::default_delete我不明白
为什么
要调用这个复制构造。
std
::vector<
std
::unique_ptr<int>> v { <e
浏览 1
提问于2021-05-19
得票数 2
1
回答
C++ -覆盖虚拟模板化成员
函数
c++
、
templates
::unique_ptr<T> createObj() return
std
::
make_unique
<T>();}; {
std
::unique_ptr<MyClass> createObj() override return
std
::
make_unique
<MyClass>
浏览 10
提问于2021-06-11
得票数 2
回答已采纳
1
回答
C++模板
函数
别名为可变模板
参数
c++
、
c++14
、
variadic-templates
我正在尝试创建一个模板,允许调用者指定他们自己的格式良好的分配方法,但我在
传递
变量模板
参数
时遇到了问题。如果我
不
传递
任何
参数
,那么一切都会按预期的方式工作;但是,如果我
传递
一个或多个
参数
,我就会得到一个编译错误,即“
函数
调用的
参数
太多了”。using allocator =
std
::unique_ptr<T>(Args...); template <typena
浏览 3
提问于2016-07-14
得票数 1
回答已采纳
2
回答
std
::
make_unique
<SomeWrapper<T>>中的完全转发不是很完美
c++
{};auto compiles =
std
::
make_unique
<DataHolder<int>>(42);而这个代码并没有:auto
浏览 6
提问于2021-05-24
得票数 2
回答已采纳
1
回答
将shared_ptr
传递
给所需的
函数
澄清
c++
shared_ptr<ParticleSystem> psys = make_shared<ParticleSystem>(...);成功了,但
为什么
呢默认情况下,我
不
尝试
传递
指针。在考虑
函数
参数
时,如果希望
不
更改
传递
变量上的任何内容,则使用const&,或者在计划使用将更改给定变量成员的方法时使用&。<Model>(path, gamma); m
浏览 1
提问于2018-10-16
得票数 0
回答已采纳
1
回答
我不能在unique_ptrs中使用'fill‘
std
::向量构造
函数
c++
、
vector
、
unique-ptr
我正在尝试使用
std
::vector构造
函数
的“填充”版本。它将元素数
作为
第一个
参数
,const value_type&
作为
第二个
参数
:{ 考虑到第二个
参数
使用const引用向量中包含的类型,我希望
std</em
浏览 2
提问于2018-08-04
得票数 2
回答已采纳
1
回答
将智能指针
作为
指针的指针
传递
给
函数
c++11
、
smart-pointers
我尝试将智能指针
作为
函数
的
参数
传递
,该
函数
接受指针的指针。我想知道是否有任何适当的解决方案。foo(Class** input) // Do something foo(&myClass.get())
浏览 2
提问于2018-09-12
得票数 0
2
回答
为什么
std
::map只通过左值引用接受自定义比较器?
c++
我想知道
为什么
像map或unordered_map这样的STL类只通过常量左值引用而不是右值引用来接受自定义的比较器和散列对象。#include <iostream>#include <unordered_map>{ KeyHasher(KeyHasher&&
浏览 1
提问于2021-03-04
得票数 2
1
回答
如何将
std
::find_if与唯一指针的向量一起使用?
c++
、
algorithm
、
unique-ptr
如何使用带有唯一指针向量的算法(如
std
::find_if )?::unique_ptr<Integer>; IntegerPtr p1 =
std
::
make_unique
<Integer>(4); IntegerPtr p3 =
std
::
make_unique
<Integer>
浏览 15
提问于2021-04-02
得票数 3
回答已采纳
2
回答
如何使
std
::
函数
和lambdas可以接受任何类型的
参数
c++
、
lambda
、
c++14
、
std-function
为了支持不同类型的
参数
,我创建了2个构造
函数
和一个不接受
参数
的默认构造
函数
。接受
std
::
函数
的构造
函数
,它接受bool
参数
。每个lambda接受不同类型的
参数
,并将它们
作为
浏览 1
提问于2018-09-22
得票数 2
回答已采纳
1
回答
是否存在将
函数
模板
作为
模板
参数
传递
的解决办法?
c++
、
function
、
templates
、
enable-if
我正在尝试创建一个
函数
模板,该模板将
函数
模板
作为
模板
参数
,然后在调用普通
函数
参数
时返回该
函数
的结果。它会被这样使用:该
函数
的目的是允许模板类型的推断,即使允许另一个
函数
执行实例的构造。我已经在代码中的很多地方手动完成了这样的操作: auto fooPtr =
std
::<e
浏览 5
提问于2021-12-12
得票数 6
回答已采纳
1
回答
在模板的帮助下,C++构造
函数
根据输入的不同行为。
c++
、
templates
、
constructor
代码应该根据不同的
参数
输入指定
s
,特别是"type“。但是,我不能让它起作用。#include <iostream>publicSellDiscount(args...); case RETURN:
浏览 2
提问于2021-11-15
得票数 1
回答已采纳
1
回答
将非常量c字符串读入string类
c++
更新:{错误:test.cpp:11:14: error: no match for call to '(
std
::string {aka
std
::basic_string<char>}
浏览 5
提问于2014-09-26
得票数 0
回答已采纳
点击加载更多
扫码
添加站长 进交流群
领取专属
10元无门槛券
手把手带您无忧上云
相关
资讯
C+11模板参数简介
智能指针:让C+程序更加安全和高效的神器
如何把C/C++程序编译成实用的Python模块
Python函数基本讲解
C+23 特性概览
热门
标签
更多标签
云服务器
即时通信 IM
ICP备案
对象存储
实时音视频
活动推荐
运营活动
广告
关闭
领券