Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

C++ Programming

Determining if type T is a subclass of X


Hi,

Is there a way using templates at compile time to determine if a type
T is a subclass of another type?

Basically I want to chose one struct if it is a subclass, or another
struct if it is not.

flopbucket wrote:
> Is there a way using templates at compile time to determine if a type
> T is a subclass of another type?

> Basically I want to chose one struct if it is a subclass, or another
> struct if it is not.

Yes, IIRC.  Check "is_derived_from" (or something like that) in Boost.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

flopbucket wrote :

> Hi,

> Is there a way using templates at compile time to determine if a type
> T is a subclass of another type?

> Basically I want to chose one struct if it is a subclass, or another
> struct if it is not.

Yes there is, see boost::is_base_of

http://www.boost.org/doc/html/boost_typetraits/reference.html#boost_t...

- Sylvester

On Jun 4, 10:27 am, Sylvester Hesp <s.hes@SPAMoisyn.nl> wrote:

> flopbucket wrote :

> > Hi,

> > Is there a way using templates at compile time to determine if a type
> > T is a subclass of another type?

> > Basically I want to chose one struct if it is a subclass, or another
> > struct if it is not.

> Yes there is, see boost::is_base_of

> http://www.boost.org/doc/html/boost_typetraits/reference.html#boost_t...

> - Sylvester

Is it possible to do this without using Boost library functions ???
Vaibhav <vaibhav.pa@gmail.com> wrote in news:1180967826.331580.90410
@p77g2000hsh.googlegroups.com:

Sure.  Look at how Boost did it... do the same thing.
On 4 juin, 16:14, flopbucket <flopbuc@hotmail.com> wrote:

> Hi,

> Is there a way using templates at compile time to determine if a type
> T is a subclass of another type?

> Basically I want to chose one struct if it is a subclass, or another
> struct if it is not.

Look at "Modern C++ Design" - Alexandrescu
The whole process is explained (and used in Loki).
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc