腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
工具
TVP
最新优惠活动
文章/答案/技术大牛
搜索
搜索
关闭
发布
精选内容/技术社群/优惠产品,
尽在小程序
立即前往
文章
问答
(9999+)
视频
沙龙
2
回答
std
::
common_type
的
目的
是什么
?
、
我开始研究
std
::
common_type
,不太清楚它
的
用途和功能。有几件事我仍然觉得很奇怪: 实例化可能
浏览 2
提问于2011-06-28
得票数 28
回答已采纳
1
回答
T declval()代替T && declval()用于
common_type
、
、
、
、
declval(); // (2) 对于
std
::
common_type
(可能仅为当前
目的
使用不同
的
名称)?
common_type
使用(1)
的
行为更接近三元操作符
的
行为(但不使用
std
::decay_t),而不是使用(2)时
的
行为。这种方法
的
缺点
是什么
?对于(1),对于decltype()上下文类型,T应该是可构造
的
(即至少应该有一个构造函数)和/
浏览 5
提问于2016-02-20
得票数 4
1
回答
用户定义
的
重载操作符*与
std
::chrono::工期
、
、
、
、
我创建了一个用于与一起工作
的
频率类模板。Frequency存储每个单位持续时间
的
多个周期(都对其类型使用模板参数)。这个想法是将频率乘以一个持续时间产生一个代表类型
的
对象,这是类
的
定义。::chrono::The也重载了*操作符,如下所示:duration<typename
std
::
common_type
'explicit' sour
浏览 4
提问于2014-06-03
得票数 4
回答已采纳
1
回答
这是duration_cast
的
一致性实现吗?
、
、
可悲
的
是,VS2012 2012‘Sduration_cast断了,而我实际上需要
的
功能是坏
的
。所以,我自己写了:ToUnit duration_cast_2(const
std
::>::type ratio; typedef
std
::
common_type
<
std
::
common_type
<typ
浏览 0
提问于2013-02-17
得票数 7
1
回答
std
::
common_type
是否应该使用
std
::衰变?
、
、
、
、
给定类型A,B,我关心
的
是
std
::
common_type
<A,B>的确切定义,而忽略了任意类型A...
的
可变情况
std
::
common_type
<A...>。
std
::declval<A>() :
std
::declval<B>());现在,根据一些消息来源,我发现了以下关系(跳过type
浏览 0
提问于2014-02-23
得票数 17
回答已采纳
1
回答
哪个更适合用于自动返回类型: decltype还是
std
::
common_type
<>::type (如果可能)?
、
、
、
作为对我
的
的
回答,建议在可能
的
情况下,在自动返回类型
的
声明中使用
std
::
common_type
<X,Y>::type,而不是我原来
的
decltype()。::
common_type
<X,Y>::type { return a[0]*y[0] + a[1]*y[1] + a[2]*y[2]; } template<typename Y::
common_type
<X,Y>:
浏览 0
提问于2012-06-16
得票数 2
回答已采纳
2
回答
类模板专门化,接受所有版本
的
const / volatile和& vs &&
、
、
、
、
我是专门为我
的
类型
的
std
::
common_type
。我定义了以下专门化:一切都很好。然后有人来打电话给
std
::
common_type
<my_type, my_type &>。如果您传递一个引用而不是一个引用(因为它在类型上调用
std
::decay ),默认版本
的
作用是相同
的
。然而,它不服从于非参考版本
的
浏览 1
提问于2013-11-23
得票数 9
回答已采纳
1
回答
带有对
std
::
common_type
的
引用
的
type_info
、
、
我很困惑:在升级到GCC 6 (RC1)时,一些使用
std
::
common_type
的
模板代码在失败之前就开始工作了。我试了一下clang,这也是fails...so,我肯定做错了什么!该守则相当于:#include <typeinfo> //
common_type
of two const
common_type
<const int&,
浏览 4
提问于2016-04-18
得票数 20
回答已采纳
1
回答
用户定义类型
的
std
::
common_type
特性
、
、
、
、
自C++11以来,引进了类型性状
std
::
common_type
。
std
::
common_type
确定其所有模板参数之间
的
公共类型。在C++14中,还引入了它
的
助手类型
std
::common_type_t,以便缩短使用
std
::
common_type
类型特性
的
代码。
std
::
common_type
在重载算术运算符中特别有用,例如, template<typename T1,
浏览 16
提问于2016-04-09
得票数 8
回答已采纳
3
回答
`
std
::
common_type
`是结合
的
吗?
、
、
、
、
模板类
std
::
common_type
将公共类型计算为可变类型列表。从这个定义来看,计算一个是否是关联
的
,对我来说并不是显而易见
的
,即是否static_assert( is_same<
common_type
< X,
common_type
, "" ); 对于所有类型
的
X、Y和Z,如果is_same<...>表达式是有效
的
,则不会抛出编译时错误。以上
浏览 3
提问于2015-12-22
得票数 16
回答已采纳
2
回答
模板运算符重载中
的
类型冲突
、
很抱歉,这听起来像是一个常见
的
问题,我找不到我
的
问题
的
答案。最近
的
帖子应该是这个:#include <type_traits>template <class T>class A {...}; // In
浏览 0
提问于2012-11-25
得票数 5
回答已采纳
2
回答
std
::min带参数包
、
我在看杰森·特纳
的
template <typename T, typename U>multi_type_min(const T& t, const U& u) return t < u ?t : u; template<typename First,
浏览 2
提问于2017-05-23
得票数 1
回答已采纳
1
回答
我怎样才能专门化
std
::
common_type
<A,B>,使其自然是可交换
的
?
、
、
、
是C++中
的
一个辅助模板,它可以找到所有T1 . TN都隐式可转换到
的
公共类型。根据C++规范,如果适用某些条件,用户可以专门化
std
::
common_type
<T1,T2>,并且:
std
::
common_type
<T1, T2>::type和
std
::
common_type
<然而,
common_type
<T1, T2>对于用户类型T1和T2来说可能是一个非常复杂
的
专门化
浏览 7
提问于2021-11-16
得票数 8
回答已采纳
4
回答
对出现在可变模板参数包
的
任意位置
的
类型
的
类模板进行部分专门化
、
、
、
、
我已经定义了一个作为整数
的
类型。我想为我
的
类型为
std
::
common_type
定义一个专门化。我希望以下代码都是有效
的
:
std
::
common_type
<bounded_integer<1, 10>,第一,预期行为: 如果有人调用
std
::
common_type
浏览 4
提问于2013-09-08
得票数 7
1
回答
不同类型参数
的
重载函数?
、
、
我在考虑重载函数,这不是一种执行重载函数
的
更快
的
方法吗,例如,上瘾而不需要使用不同
的
参数和输出定义函数很多次(int,float double ecc...)。} float c; return c;不是更快
的
方法吗
浏览 0
提问于2013-04-21
得票数 1
回答已采纳
1
回答
当应用于三元(?:)表达式时返回解密类型
、
、
当我查看可能实现
的
代码片段时struct
common_type
<T> {V> typedef common_type_t<common_type_t<T, U>, V...> type;如何获得两个模板参数
的
公共类型<em
浏览 3
提问于2015-05-06
得票数 10
回答已采纳
4
回答
变体访问与
common_type
、
、
是
std
::
common_type
吗?i;struct B {}; namespace
std
备注: 1)专门化
的
std
::
common_type
<A(*)(Ts...),B(*)(Ts...)>不会削减它。这将完成任务,但依赖于特定
的
std
::
浏览 5
提问于2017-09-07
得票数 7
1
回答
Windows MAX/MIN宏作为模板
、
如果我将Windows /max宏编写为模板函数,那么正确
的
方法
是什么
?#define min(a, b) (((a) < (b)) ?(a) : (b)) template <typename T, typename U, typename R =
std
::common_type_t<T, U>> return
std
::mi
浏览 2
提问于2017-10-11
得票数 0
回答已采纳
3
回答
std
::
common_type
实现
、
、
、
为了了解它是如何工作
的
,我在头文件type_traits中查看了
std
::
common_type
的
libstdc++实现。我必须承认,我并不真正理解它是如何工作
的
。_Tp> struct
common_type
<_Tp> struct
common_type</e
浏览 1
提问于2012-09-06
得票数 12
回答已采纳
1
回答
替代失败
、
、
、
、
,只对有理数,有理数积分和积分有理数,但是不管积分和基本
的
积分类型
是什么
,它都能工作。下面是operator+
的
函数声明,例如:constexpr rational<typename
std
::
common_type
<T::enable_if<
std
::is_integral<U>::value, rational<typename
std
::
co
浏览 2
提问于2012-09-05
得票数 0
回答已采纳
点击加载更多
扫码
添加站长 进交流群
领取专属
10元无门槛券
手把手带您无忧上云
相关
资讯
广告投放的目的是什么
比特币挖矿的目的是什么
发展智慧交通的目的是什么?
反向代理目的是什么
软件系统测试是什么?目的是什么?
热门
标签
更多标签
云服务器
ICP备案
腾讯会议
云直播
对象存储
活动推荐
运营活动
广告
关闭
领券