腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
MCP广场
文章/答案/技术大牛
搜索
搜索
关闭
发布
搜索
关闭
文章
问答
(9999+)
视频
开发者手册
清单
用户
专栏
沙龙
全部问答
原创问答
Stack Exchange问答
更多筛选
回答情况:
全部
有回答
回答已采纳
提问时间:
不限
一周内
一月内
三月内
一年内
问题标签:
未找到与 相关的标签
筛选
重置
5
回答
decltype
vs
auto
据我所知,
decltype
和
auto
都会尝试找出某种东西的类型。如果我们定义: return 34;那么这两个声明都是合法的:cout << x << endl; cout << y << endl; 你能告诉我
decltype
和
auto
的主要区别是什么吗?
浏览 4
修改于2016-02-21
得票数 63
回答已采纳
2
回答
为什么std::向前不工作在羔羊身上?
#include <utility> {
auto
fn2 = std::forward<
decltype
(fn1)>(fn1); fn
3
(); [fn2 = std::for
浏览 5
修改于2021-12-03
得票数 3
回答已采纳
2
回答
为什么
auto
会有不同的推导?
int main(){
auto
x2 = x; static_assert(is_same<int,
decltype
(x2)>::value, "
decltype
(x
浏览 2
修改于2013-05-22
得票数 11
回答已采纳
1
回答
从C++ lambda返回类型
我有兴趣了解尾随
auto
&&返回类型的确切含义,特别是区别于这里不工作的
decltype
(
auto
),以及未指定的返回类型,后者也不起作用。 在下面的代码中,fn返回参数的x_字段。我明白为什么->
auto
会导致这种情况,但我希望->
decltype
(
auto
)返回int&。为什么只有->
auto
&&才能工作?(
auto
) { return std::forward<
decl
浏览 2
修改于2020-05-12
得票数 3
回答已采纳
2
回答
默认模板参数&未评估上下文中的lambda : bug还是功能?
std::is_same_v<
decltype
(x0),
decltype
(y0)>; constexpr
auto
x1 = function();constexpr
auto
x2 = defaulted(); constexprst
浏览 0
修改于2019-04-02
得票数 39
回答已采纳
2
回答
使用
auto
,
decltype
,=,[]声明函数
#include <iostream>{}; intf = [](int a, int b) //DOES NOT WORK return a * b;*/ { int a = 2, b =
3
;
浏览 4
提问于2015-09-21
得票数 2
回答已采纳
5
回答
auto
与
decltype
的关系
是等同于或
decltype
((initializer)) x = initializer
浏览 0
修改于2015-08-15
得票数 35
回答已采纳
1
回答
为什么C++20的概念与"const &“不兼容?
template<typename T>Octet
decltype
(
auto
) c = 'a'; voidf1(const
auto
&) {} void f2(Octet
auto
) {} void f
3
(Octet
auto
&&)
浏览 6
修改于2021-05-07
得票数 6
回答已采纳
1
回答
泛型lambda尾随返回类型中的函数作用域名称无法编译(MSVC)
给定以下代码片段,case 1、2、
3
和4在Visual Studio2017 (/std:c++14)中编译,但case 5没有。这是怎么回事?int i; int j;
auto
case
3</
浏览 10
修改于2018-11-20
得票数 0
2
回答
如何在C++14中编写通用转发lambda?
尝试#1在函数体中,x是一个lvalue,所以这是不起作用的。尝试#2这正确地转发了lambda中的引用,但是它总是按值返回(除非编译器删除副本)。尝试#
3
[](
auto
&& x) ->
decltype
(x) { return std::forward&l
浏览 1
提问于2015-05-07
得票数 16
回答已采纳
4
回答
auto
在C++17模板参数中的优势
auto
在C++17引入的模板参数中有哪些优点(可能)?
auto
v2 = constant<true>; // v2 == true,
decltype
(v2) is bool
auto
v
3
= cons
浏览 11
修改于2017-03-16
得票数 70
回答已采纳
1
回答
为什么rvalue int向量的元素的
decltype
(
auto
)的类型推导是int&?
我希望是0001,因为func使用右值向量作为参数,那么forward(c)是int的常量引用,因此
decltype
(
auto
)的类型推导应该得到const int&。请帮我理解一下结果。谢谢!template <typename T>{} { <&
浏览 13
提问于2017-01-14
得票数 2
回答已采纳
1
回答
为什么gcc和clang在聚合初始化方面给出了不同的结果?
f(X<4>) ->
decltype
(T(U{}, U{}, U{}, U{}), 0u) { return 4u; } constexpr
auto
f(X<
3
>) ->
decltype
(T(U{}, U{}, U{}), 0u) { return
3
u; } constexpr
auto
f(X<2>) ->
浏览 7
修改于2021-12-29
得票数 1
回答已采纳
2
回答
C++14自动推导错误:函数返回数组
我试图应用新的C++14特性,但在尝试将const char[]参数传递给以下函数时意外地遇到了错误: {/untitled6/main.cpp: In instantiation of '<lambda(const
auto
:
3
&)> [with
auto
:
3
= char [15]]': ../..
浏览 1
修改于2015-02-07
得票数 1
回答已采纳
3
回答
完美转发
struct B{} int data_array[100];{ const A x_const;
auto
y2 = f(x);
auto
y4 = f(std::move(x));我想知道一个f (最好是函数,但宏也可以),这样:<e
浏览 0
修改于2012-02-10
得票数 5
1
回答
有没有任何方法来跟踪编译器的模板参数推断?
auto
) foo(T&& t) ->
decltype
(t + t) return t + t;
decltype
(
auto
) foo(T&<< foo(std::vector<int>{1,2,
3
}) << '\n';我很想收到这样的信息: candidate:
decltype
(
auto</em
浏览 1
修改于2018-02-16
得票数 8
回答已采纳
2
回答
为什么不能调用具有
auto
&参数的const可变lambda?
#include <type_traits> { static_assert(std::is_invocable_v<
decltype
(f1), int&>); // ok static_assert(std::is_invocable_v<
de
浏览 14
修改于2021-12-10
得票数 28
回答已采纳
1
回答
循环遍历异构类型的变量
template <typename ...A>{ (f(std::forward<
decltype
(a)>(a)),
auto
cond_loop(A&& ...a) noexcept return [&](
auto
const f) noe
浏览 0
提问于2021-08-05
得票数 2
1
回答
函数参数中容器的
Decltype
类型
我试图从函数的参数中扣除函数中stl容器的类型,但它不编译:
decltype
(v)::value_type b=0;}main.cpp:10:52: error: '
decltype
(v)' (aka 'constvector<double> &'
浏览 4
修改于2014-07-06
得票数 4
回答已采纳
1
回答
后继返回类型中的占位符是否覆盖初始占位符?
g++似乎接受
auto
和
decltype
(
auto
)的任何组合作为初始和尾部返回类型:
auto
f() { return (a); }// int
auto
h() ->
decltype
(
auto
) { return(a); }
浏览 1
修改于2014-08-20
得票数 6
回答已采纳
第 2 页
第 3 页
第 4 页
第 5 页
第 6 页
第 7 页
第 8 页
第 9 页
第 10 页
第 11 页
点击加载更多
领券