RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
C++单类型参数概念是什么

本篇内容主要讲解“C++单类型参数概念是什么”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“C++单类型参数概念是什么”吧!

成都创新互联公司专业为企业提供葫芦岛网站建设、葫芦岛做网站、葫芦岛网站设计、葫芦岛网站制作等企业网站建设、网页设计与制作、葫芦岛企业网站模板建站服务,十年葫芦岛做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

T.13:对于简单的,单类型参数概念,使用缩略记法更好

Reason(原因)

Readability. Direct expression of an idea.

可读性。直接表现想法。

Example (using TS concepts)示例(使用TS概念)

To say "T is Sortable":

为了表达“T是可排序类型”:

template       // Correct but verbose: "The parameter is
//    requires Sortable   // of type T which is the name of a type
void sort(T&);             // that is Sortable"

template       // Better (assuming support for concepts): "The parameter is of type T
void sort(T&);             // which is Sortable"

void sort(Sortable&);      // Best (assuming support for concepts): "The parameter is Sortable"

The shorter versions better match the way we speak. Note that many templates don't need to use the template keyword.

较短的版本更符合我们想要表达的。注意很多模板不需要使用模板关键字。

Note(注意)

"Concepts" are defined in an ISO Technical Specification: concepts. A draft of a set of standard-library concepts can be found in another ISO TS: ranges Concepts are supported in GCC 6.1 and later. Consequently, we comment out uses of concepts in examples; that is, we use them as formalized comments only. If you use a compiler that supports concepts (e.g., GCC 6.1 or later), you can remove the //

“概念”在ISO技术规格concepts中被定义。一套标准库concepts的初步版本可以在另一个ISO技术规格:ranges中找到。GCC6.1以后都支持concepts。因此我们在实例代码中注释掉使用concepts的部分;也就是说我们只是将它们用作标准的注释。如果你使用GCC6.1之后的版本,可以打开注释。

Enforcement(实施建议)

  • Not feasible in the short term when people convert from the  and  notation.

  • 如果人们从记法转过来,使用缩略记法是不合适的。

  • Later, flag declarations that first introduce a typename and then constrain it with a simple, single-type-argument concept.

  • 随后,标记第一次引入类型名并马上使用简单的,单类型概念对其进行约束的情况。

到此,相信大家对“C++单类型参数概念是什么”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!


网站题目:C++单类型参数概念是什么
网页URL:http://scyingshan.cn/article/gsihjd.html