腾讯云
开发者社区
文档
建议反馈
控制台
首页
学习
活动
专区
工具
TVP
最新优惠活动
文章/答案/技术大牛
搜索
搜索
关闭
发布
登录/注册
精选内容/技术社群/优惠产品,
尽在小程序
立即前往
文章
问答
(9999+)
视频
沙龙
1
回答
std
::
vector
的
元素
上
的
decltype
c++11
、
decltype
std
::
vector
<int> v{1,2};
decltype
(v)::value_type j; /这里不是int类型
的
v[0]吗? 我知道即使它可以工作,在向量为空
的
情况下,它也不会像后者那样安全,但我觉得这应该是一个运行时问题,而不是编译时问题。
浏览 44
提问于2020-04-08
得票数 0
回答已采纳
2
回答
当函数接受rvalue引用时,函数中该变量
的
类型是什么?
c++
、
rvalue-reference
、
lvalue-to-rvalue
static_assert(
std
::is_same<
decltype
((v)),
std
::
vector
<int>&>::value); return g(
std
:
浏览 4
提问于2019-06-14
得票数 1
回答已采纳
3
回答
C++20概念:
元素
可迭代概念
c++
、
c++20
、
c++-concepts
例如,
std
::
vector
<int>中
的
元素
是不可迭代
的
,但
std
::
vector
<
std
::
vector
<int>>中
的
元素
(
std
::
vector
<int>)是可迭代
的
。关于使用
std
::iterator_traits<T>
的
想法出现在我
浏览 31
提问于2020-10-21
得票数 5
回答已采纳
5
回答
返回转换容器
的
std
::transform类函数
c++
、
templates
、
c++11
、
stl
我正在尝试实现一个类似于
std
::transform算法
的
函数,但不是通过参数获取输出迭代器,而是创建并返回一个带有转换后
的
输入
元素
的
容器。它应该返回相同
的
容器类型,但可能会被不同
的
元素
类型参数化(函子可以返回不同类型
的
元素
)。我想使用我
的
函数,如下例所示:auto vs =
浏览 8
提问于2014-05-26
得票数 45
回答已采纳
1
回答
如何在不创建实例
的
情况下获取类
的
方法成员
的
类型?
c++
、
arrays
、
templates
、
generics
、
types
假设我们有:void foo(
std
::
vector
<T> &t) {
std
::
vector
<
decltype
此数组
的
类型与Get()
的
返回值无关。我们通过创建一个T类型
的
伪变量,然后使用
decltype
推断Get
的
返回类型来找到这个值。 这是可行
的
,但是它需要创建一
浏览 12
提问于2019-08-12
得票数 4
回答已采纳
1
回答
推导出
的
返回类型
c++
、
c++14
#include <iostream>
decltype
(auto)
std
::
vector
<uint32_t> r{2, 4, 6};
std
::cout << "lvalue" &l
浏览 17
提问于2019-06-26
得票数 7
回答已采纳
1
回答
类型推导模板函数返回类型
c++
、
templates
、
c++17
、
type-deduction
我正在编写一个模板函数,它使用
std
::minus返回向量
的
连续
元素
的
差。目前我有以下代码:auto diffs(
std
::
vector
<T> &nums) typedef
decltype
(
std
::minus<T>()) diffType;
std
::
vector
<diffType> diff
浏览 0
提问于2018-04-23
得票数 1
5
回答
使用Visual编译器在编译时获取向量
元素
的
大小(即使它是空
的
)
c++
、
visual-c++
给定某种类型
的
元素
的
std
::
vector
,如何使用Visual编译器在编译时确定这些
元素
的
类型
的
大小。对第一个
元素
使用sizeof不是一个选项,因为向量可能是空
的
。对于clang和gcc,我可以这样做:size_t size_of_
vector
_elements(
st
浏览 0
提问于2019-04-11
得票数 5
回答已采纳
1
回答
使用模板将多个向量(函数
的
结果)合并为一个
c++
、
c++11
、
templates
、
stdvector
我希望有一个接受
vector
<T> v和函数op
的
模板化函数,将T映射到
vector
<U>,并希望将f应用于v
的
每个
元素
向量
的
结果连接起来,以返回
vector
<U> =[ Elements of op::
vector
<U> { for (auto& e : c) {
std
::<e
浏览 21
提问于2019-05-07
得票数 5
回答已采纳
1
回答
用于检测尺寸方法
的
SFINAE不适用于矢量向量
c++
、
sfinae
::cout << typeid(x).name() << '\n';
std
::
vector
<
std
::
vector
<
std
::
vector
<float>>> y{};
std
浏览 5
提问于2022-10-17
得票数 0
3
回答
如何确定数组
元素
的
类型?
c++
、
arrays
、
c++11
、
vector
我无法得到
元素
的
类型。此解决方案返回对
元素
类型
的
引用。int arr[] = { 0, 1, 2, 3, 4, 5 };
vector
<arrElemType> vec(
std
::cbegin(arr),
std
::cend(arr));
浏览 4
提问于2014-03-14
得票数 9
回答已采纳
4
回答
限定为解密类型
c++
、
c++11
我第一次尝试使用
decltype
const
decltype
(&vals[0]) ptr; ptr我想要实现
的
是ptr成为const int*类型。我怎么才能让它起作用?谢谢。
浏览 1
提问于2016-06-30
得票数 1
回答已采纳
1
回答
类,该类将转换为索引和指针并引用容器
c++
、
vector
、
type-conversion
我尝试编写一个通过索引访问容器中
的
元素
的
类。因此,我将能够重新路由指向
的
容器(但这对于我当前
的
问题并不重要)。它将帮助我摆脱复杂
的
复制构造函数。::
vector
<Dog> >' 38:7: error: base operand of '->' has non-pointer type 'paxRef<Dog&,
std
::
vector
<Dog如果我
浏览 3
提问于2016-11-07
得票数 0
1
回答
C++:无法从派生类访问受保护成员
c++
、
c++11
现在,我想专门针对只在修改容器本身(例如,通过MyContainer )而不是修改其
元素
时才执行这项额外工作
的
容器对象进行push_back()。from here test1.cpp:17:4: error: '
std
::
vector
<float> MyVariable<
std
::
vector
<float> >::_element' is protectedelement.at(arg)) MyContainer<T>
浏览 4
提问于2015-12-02
得票数 4
回答已采纳
1
回答
传递转换函数后将对象推送到向量
c++
、
move-semantics
、
perfect-forwarding
我希望插入一个转换函数(可能是
std
:: function )来修改被推送到
std
::
vector
上
的
对象。我希望该对象在不需要构造额外副本
的
情况下,就地构造,并通过该函数。假设我要这么做:现在我要做
的
是:foo_array.push_back(conver
浏览 0
提问于2020-10-12
得票数 0
回答已采纳
2
回答
表示C++类模板中
的
空类型
c++
、
templates
、
c++17
、
variadic-templates
、
template-meta-programming
std
::is_same_v<
decltype
(sv::rest), void *>, "
vector
size out of bound"); constexpr int nth = access_nth<5,
decltype
(a)>();} 我对我们现在所能做
的
浏览 95
提问于2020-07-04
得票数 2
回答已采纳
3
回答
得到函数
的
解密类型
c++
、
decltype
我希望得到函数
的
类型,并创建函数
的
std
::
vector
。例如,我有int bar(int a[], int n) { return 2; }
std
::
vector
<
std
::function<int(int[],int)> > v;
std
::
浏览 0
提问于2015-10-01
得票数 18
回答已采纳
1
回答
一个用于计算C++嵌套类型实现深度
的
C++函数
c++
、
recursion
、
template
、
c++20
给定嵌套类型,如
std
::
vector
<int>、
std
::deque<int>和
std
::list<int>,recursive_depth模板函数
的
输出为1。<
decltype
(test_
vector
)>() << '\n'; //
std
::
vector
<
std
::
vector
浏览 0
提问于2021-10-25
得票数 2
回答已采纳
2
回答
使用解密类型从指针中推断类型
c++
、
visual-studio-2015
、
decltype
在尝试执行以下代码时,VS2015抛出了许多错误:int *p = &a;但是,当我检查这个解密类型返回
的
类型时,我会得到一个typeid(
decltype
(*p)) == typeid(int) // returns true 有人能给我解释一下吗?我只是通过取消指针和解密我得到
的
值来解决这个问题。
浏览 3
提问于2015-09-28
得票数 2
回答已采纳
1
回答
输入错误:在‘struct
std
::iterator_traits<
std
::
vector
<int> >中没有名为’
std
::iterator_traits<
std
::
vector
<int>‘
的
类型
c++
、
c++11
、
vector
、
iterator
、
typetraits
但是当我试图通过
vector
时,我遇到了这个错误错误:在‘struct
std
::iterator_traits<
std
::forward_list >’中没有名为‘iterator_category’<e
浏览 2
提问于2022-06-09
得票数 0
回答已采纳
点击加载更多
扫码
添加站长 进交流群
领取专属
10元无门槛券
手把手带您无忧上云
相关
资讯
《Effective Modern C+》笔记之类型推断
C+的模板类vector的用法“一”
C+auto和decltype的区别
C+实现xml解析器
python爬虫技术:如何定位网页上的内容?xpath定位元素
热门
标签
更多标签
云服务器
即时通信 IM
ICP备案
对象存储
实时音视频
活动推荐
运营活动
广告
关闭
领券