当前位置: 首页 > news >正文

大一网页设计电商网站作业软件网站关键词优化

大一网页设计电商网站作业,软件网站关键词优化,南网站建设,怎么用nat做网站先说结论: 如果问号表达式能编译通过,那么std::common_type就能通过。因为common_type的底层依赖的就是?: common_type的实现里,利用了问号表达式:ternary conditional operator (?:) https://stackoverflow.com/questions/14…

先说结论:

如果问号表达式能编译通过,那么std::common_type就能通过。因为common_type的底层依赖的就是?:

common_type的实现里,利用了问号表达式:ternary conditional operator (?:)

https://stackoverflow.com/questions/14328034/what-is-the-point-of-this-condition-found-in-the-implementation-of-stdcommon-tstd::common_type的部分实现:template <class T, class U>
struct common_type<T, U> {typedef decltype(true ? declval<T>() : declval<U>()) type;
};

?:这个表达式,有类型两个属性。有以下知识点:

1、表达式的。是运行时的逻辑,这个大家都很熟悉。比如一个问号表达式true : 2 : 1.0。它有一个值,这个值是根据condition判断出来的(这个例子里是true)。咱们可以用auto val来接住该值,auto val = true : 2 : 1.0; 那么val的值就是2.0。(注意,为什么是2.0,看下面分解

2、表达式的类型。是编译时获取的。也就是说true : 2 : 1.0作为一个整体,它有一个类型,系统会取其“共同”的类型。至于怎么提取的,是系统决定的。这个类型可以用decltype()在编译器来取,比如decltype(true : 2 : 1.0)。记住它是在编译期来确定的,而不是运行期来确定,所以它不管condition的。所以第一条里面,true : 2 : 1.0的值为什么是2.0呢,因为decltype对其分析的结果就是double。为了验证这一点,参看下面的写法,编译不成功:

auto x = true ? 1 : L"123";编译错误:
error C2446: “:”: 没有从“const wchar_t *”到“int”的转换
note: 没有使该转换得以执行的上下文
error C3536: “x”: 初始化之前无法使用为什么编译不成功呢,那是因为int和const wchar_t*是没有共同类型的。using T = decltype(true? std::declval<int>() : std::declval<const wchar_t *>());
或者
using T = decltype(false ? std::declval<int>() : std::declval<const wchar_t *>());结果都一样,编译错误:
error C2446: “:”: 没有从“const wchar_t *”到“_Ty1”的转换
1>        with
1>        [
1>            _Ty1=int
1>        ]
note: 没有使该转换得以执行的上下文
而以下的写法,表达式的类型均为double输出double
using T = decltype(1 ? 1 : 1.0);
std::cout << boost::typeindex::type_id_with_cvr<T>().pretty_name() << std::endl;输出double
using T = decltype(0 ? 1 : 1.0);
std::cout << boost::typeindex::type_id_with_cvr<T>().pretty_name() << std::endl;输出double
using T = decltype(0 ? 1.0 : 1);
std::cout << boost::typeindex::type_id_with_cvr<T>().pretty_name() << std::endl;输出double
using T = decltype(true ? std::declval<int>() : std::declval<double>());
std::cout << boost::typeindex::type_id_with_cvr<T>().pretty_name() << std::endl;输出double
using T = decltype(false? std::declval<int>() : std::declval<double>());
std::cout << boost::typeindex::type_id_with_cvr<T>().pretty_name() << std::endl;

再看自定义指针的例子: 

提取shit0*和shit1*的共同类型。
运行结果:struct shit0 * __ptr64struct shit0
{};
struct shit1 : shit0
{};void Test()
{using T = decltype(true ? std::declval<shit0*>() : std::declval<shit1*>());
std::cout << boost::typeindex::type_id_with_cvr<T>().pretty_name() << std::endl;}///
提取shit0和shit1的共同类型。
运行结果:struct shit0struct shit0
{};
struct shit1 : shit0
{};void Test()
{using T = decltype(true ? std::declval<shit0*>() : std::declval<shit1*>());
std::cout << boost::typeindex::type_id_with_cvr<T>().pretty_name() << std::endl;}

貌似等于号=也有类似属性,之后再研究吧

http://www.tj-hxxt.cn/news/12042.html

相关文章:

  • 做热血钓鱼网站企业推广方式
  • 怎么优化网站源代码宝安网站建设
  • 湖南网站建设网络公司十大中文网站排名
  • 58同城武汉网站建设seo优化网站教程
  • 政府网站开发程序员重庆网络推广平台
  • 惠州网站建设培训中国网站排名网
  • 企业运营系统seo网址超级外链工具
  • 大型门户网站建设多少钱清远今日头条最新消息
  • 建网站做点什么好飞猪关键词排名优化
  • 网站建设与制作价格微信软文推广怎么做
  • 网站建设哪里有什么是seo什么是sem
  • 学校建设网站赛雷猴是什么意思
  • h5免费制作平台易企秀淘宝怎么优化关键词排名
  • 织梦做分类信息系统网站网站制作企业
  • 金水郑州网站建设淄博网站优化
  • 达川区建设局局网站网站接广告平台
  • 网站中滚动条怎么做免费信息推广平台
  • 西安网络公司网站建设seo优化价格
  • 用香港服务器做网站网络营销seo是什么意思
  • 菏砖网站建设百度关键词排名神器
  • 培训网站建设方案书网络营销咨询服务
  • 郑州做网站公司360网站推广
  • 兰州市城关区疫情最新消息河南seo
  • 怎么做网站地图导航在线建站模板
  • 代做视频的网站头条新闻今日头条官方版本
  • 佛山专业网站设计方案绍兴seo排名外包
  • 上海当地网站推广产品的文案
  • 自己做传奇网站培训学校招生方案
  • 怎样做公司自己的官方网站seo学校培训
  • 服装手机商城网站建设百度账号申诉中心