Forcing a template parameter to be derived from another
From: Gabriele Trombetti (nonvalid_at_nowhere.com)
Date: 03/10/04
- Next message: P.J. Plauger: "Re: Can I use std::locale to solve this?"
- Previous message: Daniel LAUGT: "Re: Why static pure virtual method is not possible?"
- Next in thread: Leor Zolman: "Re: Forcing a template parameter to be derived from another"
- Reply: Leor Zolman: "Re: Forcing a template parameter to be derived from another"
- Reply: Jonathan Turkanis: "Re: Forcing a template parameter to be derived from another"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 10 Mar 2004 15:24:05 -0600
Hi all,
Is there a way in C++ to force that a template parameter be derived from
something?
The code below should be clear for everybody. I'm asking that the
template parameter T_or_derived is T or derived publicly from T,
otherwise the compiler should give error. Unfortunately this syntax does
not compile.
Is there a way to enforce this constraint? If not, it seems to me that
this would be a very neat addition to C++.
template<class T>
class something
{
...
template<class T_or_derived : public T>
const something<T> & operator =
(something<T_or_derived> & const copythis) {...}
...
};
- Next message: P.J. Plauger: "Re: Can I use std::locale to solve this?"
- Previous message: Daniel LAUGT: "Re: Why static pure virtual method is not possible?"
- Next in thread: Leor Zolman: "Re: Forcing a template parameter to be derived from another"
- Reply: Leor Zolman: "Re: Forcing a template parameter to be derived from another"
- Reply: Jonathan Turkanis: "Re: Forcing a template parameter to be derived from another"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|