concept Mungible<typename T> {
void T::Mung();
}
template<typename T>
class Widget {
public:
void Mung();
};
Am I permitted to have a templatized concept map, like this?
template<typename T> // all Widget instantiations are
concept_map Mungible<Widget<T>> {} // Mungible
If not, how do I express that all Widget instantiations are a model of Mungible?
Suppose that not quite all of the classes generated by the template model the
concept. This specialization, for example, does not:
template<>
class Widget<void> {
void Smack();
};
Will this compile, or is it contrary to the concept map above?
If the above compiles, what about the following?
Widget<void> w; // compiles? We now have an instance of
// a class that doesn't satisfy Mungible
If that compiles, what about this, which invokes a template that requires the
concept:
template<Mungible T>
void f(T thingToMung);
f(w); // compiles? w isn't Mungible
Assuming that at least something above fails to compile, we can presumably fix
it via a suitable concept map:
concept_map Mungible<Widget<void>> {
void T::Mung() { T::Smack(); }
}
Where would this have to be defined? Presumably after the declaration of the
concept, but before or after the templatized concept map (or whatever mechanism
is used to assert that all instantiations of a template satisfy a concept)?
Thanks,
Scott
PS - My attempts to get conceptgcc up and running on my Windows XP machine have
failed, and the conceptgcc mailing list seem to be offline. If you have
experience getting conceptgcc to work under WinXP and would be interested in
helping me coax life out of mine, please send me mail off-group:
sme...@aristeia.com. Thanks.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
This I can answer positively:
�14.5.6 of the C++0x draft mentions concept_map templates, and
�14.9.2.1 gives a nice example for a concept_map partially specialized
for std::vector
> Suppose that not quite all of the classes generated by the template model the
> concept. This specialization, for example, does not:
>
> template<>
> class Widget<void> {
> void Smack();
> };
>
> Will this compile, or is it contrary to the concept map above?
>
> If the above compiles, what about the following?
>
> Widget<void> w; // compiles? We now have an instance of
> // a class that doesn't satisfy Mungible
I'd expect this to compile. A stand-alone template class (and all it's
specializations) must not, by all means, be dependent on any
concept_maps that define mappings to "external" concepts. This would
totally defeat de-coupling of components!
> If that compiles, what about this, which invokes a template that requires the
> concept:
>
> template<Mungible T>
> void f(T thingToMung);
>
> f(w); // compiles? w isn't Mungible
I'd expect this not to compile, since there is no concept_map that
fits the specialization Widget<void>.