[ConceptGCC] |
ConceptGCC :Re: Concepts in std::string; default implementations |
From: Douglas Gregor (doug.gregor_at_[hidden])
Date: 2007-04-09 05:30:43
On Sun, 2007-04-08 at 12:18 +0200, Stefan wrote:
> Hello!
>
> I'm very excited about the idea of concepts. I have a few questions:
>
> 1) Is there a proposal to "conceptualize" std::string? I'm writing a
> class, in which I operate on characters, so it looks like this:
>
> template<typename CharT>
> class MyClass
> {
> // ...
> };
>
> It would be nice to have a concept for that CharT type. Is there going
> to be one in the standard library?
We intend to conceptualize std::string, which will include some kind of
'Character' concept suitable for the 'CharT' type (and probably the
Traits type as well; we're not quite sure how to handle this yet).
> 2) Why sometimes I need to include the <concepts> header?
It's needed for the CopyConstructible concept, which gets added
automatically in some cases. It's the same idea as with the <typeinfo>
header, which you need to include before using "typeid".
> 3) Is the ';' needed after concept or concept_map? AFAIK no, but in all
> examples in the tutorial it's there.
The ';' is optional after a concept or concept_map.
> 4) What's a default implementation? Is it a function that lives in some
> translation unit or is it some sort of metacode?
It's an implementation that will be used if no other implementation of
that concept operation is available. It's essentially an inline function
template that will only be instantiated when it is needed to satisfy the
requirements of the concept.
- Doug