简体   繁体   English

C ++ 14会支持无约束的泛型函数吗?

[英]Will C++14 support unconstrained generic functions?

While looking at the GCC 4.9.0 release changes here , I was pleasantly surprised to read the following; 在注视GCC 4.9.0版本改变了这里 ,我惊喜地阅读以下; under the "New Languages and Language specific improvements" section for C++: 在C ++的“新语言和语言特定改进”部分下:

G++ supports unconstrained generic functions as specified by §4.1.2 and §5.1.1 of N3889: Concepts Lite Specification . G ++支持N3889的§4.1.2和§5.1.1:Concepts Lite Specification所规定的无约束泛型函数。 Briefly, auto may be used as a type-specifier in a parameter declaration of any function declarator in order to introduce an implicit function template parameter, akin to generic lambdas. 简而言之,auto可以用作任何函数声明符的参数声明中的类型说明符,以便引入隐式函数模板参数,类似于通用lambdas。

// the following two function declarations are equivalent
auto incr(auto x) { return x++; }
template <typename T>
auto incr(T x) { return x++; }

I built GCC 4.9.0 and my initial tests worked as expected. 我构建了GCC 4.9.0,我的初始测试按预期工作。 I believe that Concepts Lite will remain somehow auxiliary to the upcoming C++14 specification. 我相信Concepts Lite将继续以某种方式辅助即将推出的C ++ 14规范。 Is there though any plan for "unconstrained generic functions" to become a part of C++? 是否有任何“无约束通用函数”计划成为C ++的一部分?

If we look at the latest draft standard N3936 which is pretty close to the C++14 DIS which is N3937 ( this is covered in N3938 ). 如果我们看一下最新的标准N3936 ,它与N3937的C ++ 14 DIS非常接近( 这在N3938中有介绍 )。 It does not contain any of the language specified in sections 4.1.2 and 5.1.1 of N3889 . 它不包含N3889 4.1.25.1.1节中指定的任何语言。

So for C++14 it looks like the answer is no, but Bjarne Stroustrup says concepts lite will be a technical report . 所以对于C ++ 14来说,看起来答案是否定的,但是Bjarne Stroustrup说概念lite将是一份技术报告 You can find more about technical reports on ISO cpp's Current Status page which says: 您可以在ISO cpp的“当前状态”页面上找到有关技术报告的更多信息,其中说明:

Beyond C++14, the committee contemplates producing another C++ Standard in approximately 2017. That doesn't mean nothing is happening in the meantime, however, because we currently have eight (8) separate Technical Specifications underway, several of which are on track to be published in 2014 and 2015. Starting in 2012, the committee has transitioned to a “decoupled” model where major pieces of work can progress independently from the Standard itself and be delivered as separate TS's. 除了C ++ 14之外,该委员会计划在2017年左右制作另一个C ++标准。但这并不意味着在此期间没有发生任何事情,因为我们目前正在进行八(8)个单独的技术规范,其中一些正在进行中将于2012年和2015年出版。从2012年开始,该委员会已转变为“脱钩”模式,其中主要工作可独立于标准本身进行,并作为单独的TS提供。 Vendors can choose to implement these, and the community can gain experience with the std::experimental version of each feature. 供应商可以选择实施这些,社区可以获得每个功能的std :: experimental版本的经验。 This lets us learn and adjust each feature's design based on experience before it is formally included in a future version of the actual C++ Standard 这让我们可以根据经验学习和调整每个功能的设计,然后才能将其正式包含在实际C ++标准的未来版本中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM