| re: Templates problem
"Christopher" <cpisz@austin.rr.com> wrote in message
news:71dce74a.0409031030.6fcbcd89@posting.google.c om...[color=blue]
> I would like to make a template data structure such that any type of
> data structure may be contained within the template object with the
> constraint that the object being contained must have a specific data
> member of a specific type. Does there exist a c++ construct to
> accomplish this task?
>
> EX
> template class container
> {
> methods
> .
> .
> .
> Data * list_of_data; // Instead of type Data, could be any type.
> };
>
> class Data // Mock data type
> {
> methods
> .
> .
> Bounding_Box bounds; // Must have this!
> };
>
> Not sure if that got my point across :([/color]
You could just write the code and let the compiler complain about it when it
discovers that the template argument doesn't contain the required member.
You also might be able to cook up a "concept check" (similar to boost's
library, or perhaps using it) that checks for the member, but I wouldn't
know if that's possible without doing some research.
--
David Hilsee |