c++-concepts

Will concepts lite change the need of CRTP to achieve static polymorphism?

二次信任 提交于 2019-12-10 17:23:38
问题 Since I have discovered CRTP some years ago, I use it in many places to achieve compile-time polymorphism for very intensive computing oriented codes. It's great to "inject" member functions into classes in a generic way when one cares about both genericity and maximal performances at runtime. I have read/watch several things on the concepts lite which will be (I hope) a part of the next C++ standard. It will be absolutely wonderfull to design functions in a more abstract and generic manner,

list of standard concepts? [closed]

流过昼夜 提交于 2019-12-10 14:33:12
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . From what I remember C++ has concepts such as Mergable, Container, Comparable, Sortable, Arithmetic etc. I seen them here and there but I never seen a list. Where can I find a list of standard C++ concepts? -edit- people are confused but what I mean is the example template line in this slide which has Container

C++0X Concepts are gone. Which other features should go too? [closed]

好久不见. 提交于 2019-12-08 23:10:39
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year . As you may have heard, the last meeting of the C++ standards committee voted to remove concepts from the next C++ standard. Of course, this will affect other features and would seem to throw the standard wide open again. If that is the case, which other features do you think

Why Sortable concept requires totally ordered value type, while std::sort only requires “less than” comparable?

不羁岁月 提交于 2019-12-06 18:21:58
问题 In the latest paper on concepts N3701, there is the following example with the sort algorithm: template<typename Cont> requires Sortable<Cont>() void sort(Cont& cont) where Sortable concept is defined as template<typename T> concept bool Sortable() { return Permutable_container<T>() && Totally_ordered<Value_type<T>>(); } where Totally_ordered , not surprisingly, is defined as template<typename T> constexpr bool Totally_ordered() { return Weakly_ordered<T>() && Equality_comparable<T>(); } and

How can we express Concept in UML diagram?

限于喜欢 提交于 2019-12-06 15:28:31
Does UML Class Diagram support expressing Concept? Also, is there any other diagrams that expresses Concept? Just in case of misunderstanding, I mean the "Concept" in C++ and generic programming. xmojmr After reading shortly Wikipedia explanation of C++ "concepts" it looks to me like tool with same goals as generic classes and type constraints in C# If I understood it correctly then by following older Stack Overflow question Representing a C# Generic Method in a UML Class Diagram it turns out that you should check the http://www.uml-diagrams.org/template.html as already suggested by @Aleks

How to write a simple range concept?

非 Y 不嫁゛ 提交于 2019-12-05 18:33:19
问题 How to write a concept that will describe the types the Range-based for loop is enabled for? One attempt is: template < typename Range > concept bool RRange = requires(Range range) {{std::begin(range),std::end(range)};}; but what I really want is some thing like this: template < typename Range > concept bool RRange = requires(Range range) {{for(auto&& item : range);};}; // compile error that is, RRange to be the concept of all types the expression for(auto&& item : range); is valid for. What

Why Sortable concept requires totally ordered value type, while std::sort only requires “less than” comparable?

99封情书 提交于 2019-12-04 23:55:19
In the latest paper on concepts N3701 , there is the following example with the sort algorithm: template<typename Cont> requires Sortable<Cont>() void sort(Cont& cont) where Sortable concept is defined as template<typename T> concept bool Sortable() { return Permutable_container<T>() && Totally_ordered<Value_type<T>>(); } where Totally_ordered , not surprisingly, is defined as template<typename T> constexpr bool Totally_ordered() { return Weakly_ordered<T>() && Equality_comparable<T>(); } and in turn Equality_comparable is defined as template<typename T> constexpr bool Equality_comparable() {

C++ Concepts Same and Assignable

℡╲_俬逩灬. 提交于 2019-12-04 04:53:55
问题 I have been experimenting with C++ concepts recently. I am trying the definitions from the following Ranges Extensions document: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/n4569.pdf The definitions and usages of Same are confusing me. For reasons unknown to me, the authors did not give an explicit definition. So I am using: template <class T, class U> concept bool Same() { return std::is_same<T, U>::value; } The problem is that the document gives the following definition for

How do I build gcc with C++ concepts (“concepts lite”) support?

半世苍凉 提交于 2019-12-03 19:46:14
问题 The C++ standards committee is working on a TS (Technical Specification) for Concepts extension: "Programming Languages - C++ Extensions for Concepts". N4377 is the latest version of this document. For inclusion into the C++ standard features are asked to be implemented, ideally for a publicly accessible system. I'm aware of concept-gcc but the concepts proposal above (colloquially referred to as Concepts Lite ) is different. I heard that there is a concepts branch and I have tried the origin

How will Concepts-Lite interact with variadic templates?

限于喜欢 提交于 2019-12-03 12:15:21
问题 I watched Bjarne Strustrup's talk in Going Native 2013 and he gives the following example for the upcoming concepts-lite feature of C++. void sort(Container& c); // terse notation // Expands to template <Container __Cont> void sort(__Cont& c); // shorthand notation // Expands to template <typename __Cont> requires Container<__Cont>() void sort(__Cont & c); My question is how will this work with variadic templates? Say I want to define a variadic maximum function using a Comparable concept.