What are concepts?

I heard all this new (on /.) About C ++ 0x, which has no concepts, but I have no idea what it is? Can someone explain to me?

+22
c ++ generic-programming c ++ 11 c ++ - concepts
Aug 10 '09 at 1:53
source share
2 answers

Concepts is a general programming function that allows a person writing template code to specify requirements that type parameters must meet.

For example, some collection types need a type parameter for the collection to define & lt; operator. Thus, the programmer can define a concept called LessThanComparable, which tells the compiler that the type parameter for the template class must have the & lt; defined. If the template user then tries to instantiate the template using a type that does not have the LessThanComparable concept (that is, does not have the & lt; operator function), the compiler can produce a simple error message rather than a stream of error messages related to the template code. The compiler can also use the additional information provided by the concepts to generate more efficient code.

This is too simplistic, but I think it gives you a general idea of ​​the concepts.

If you want to try out some of the features of the concepts, take a look at the Boost.Concept Check library. I do not think that it provides the whole range of features that should have been in the standard, but this is a good place to start.

You can also look at ConceptC ++ , there is a good definition of concepts.

+24
Aug 10 '09 at 2:03
source share

Here is an article that I think would help:

http://www.devx.com/SpecialReports/Article/38864

The decision to address them has been discussed several times here and in SO. This might be interesting:

c0x No more concepts

Concepts versus Interfaces

Hypothetical discussion of concepts

+10
Aug 10 '09 at 1:57
source share



All Articles