[ConceptGCC] |
ConceptGCC :Re: Importing names from concept |
From: Doug Gregor (dgregor_at_[hidden])
Date: 2007-04-25 13:13:21
Hello,
On Apr 23, 2007, at 4:49 AM, Stefan Chrobot wrote:
> Is there a way to import names from a concept into a scope that is
> neither a concept refinement nor a constrained template?
> [snip example]
> The reason I'm asking is that concepts in a way define static
> interfaces
> and sometimes one wants to use the object as defined in the
> concept -
> for example for testing purposes - I'm using the TUT framework,
> which is
> itself templatized (so I'm not sure there is a way to make a
> constrained
> template test) and if I want to check for concept mapping I have to
> use
> the explicit syntax:
> MyC<A>::function(a);
> I understand that such import of names may cause ambiguity which
> should
> not really happen and something should be preferred (name from the
> concept?), but was this issue ever considered? Do you think there
> might
> be other pros?
There is no syntax for doing this. We've thought about it, and it
would be great if we could do it, but there are some issues that make
it rather complicated. If we did it, we'd probably use "using"
syntax. Here's the problem:
concept Addable<typename T> {
T operator+(T, T);
}
concept_map Addable<int> {
int operator+(int x, int y) { return x*y; }
}
int add(int x, int y) {
using Addable<int>; // pulls in overloads from Addable<int>
return x + y; // built-in operator+ or Addable<int>::operator+?
}
That's what stopped us from adding this feature.
- Doug