V
verec
Last week I asked here how I could detect that a T was polymorphic, and
received
very thoughtful and useful replies that I used straight away. Thanks to all who
answered.
This week, it turns out that detecting whether T is polymorphic clashes with
a new requirement, that T be allowed to not be complete.
Last week, this code used to compile:
typedef std::queue<Request> RequestQueue ;
typedef envelope<RequestQueue> Queue ;
This week, I now have to wrap std::queue into a polymorphic
container, as in:
struct RequestQueue : public std::queue<Request> {
// envelope does NOT work with monomorphic types
virtual ~RequestQueue() {} ;
} ;
typedef envelope<RequestQueue> Queue ;
Obviously, I'd like to create some kind of adaptor template ...
template <typename T> struct polymorphic : public T {
virtual ~polymorhic() {}
} ;
intended usage:
typedef polymorphic<std::queue<int> > Queue ;
But this doesn't compile!
The FAQ#35 seems mute here, and I'm beginning to suspect that
something is wrong with my syntax. I also checked
http://www.boost.org/libs/utility/call_traits.htm &
http://www.boost.org/libs/conversion/cast.htm (because it
contained the word: polymorphic_cast, but this turned out
a red-herring)
What would be the correct way to do this?
Many thanks, again.
received
very thoughtful and useful replies that I used straight away. Thanks to all who
answered.
This week, it turns out that detecting whether T is polymorphic clashes with
a new requirement, that T be allowed to not be complete.
Last week, this code used to compile:
typedef std::queue<Request> RequestQueue ;
typedef envelope<RequestQueue> Queue ;
This week, I now have to wrap std::queue into a polymorphic
container, as in:
struct RequestQueue : public std::queue<Request> {
// envelope does NOT work with monomorphic types
virtual ~RequestQueue() {} ;
} ;
typedef envelope<RequestQueue> Queue ;
Obviously, I'd like to create some kind of adaptor template ...
template <typename T> struct polymorphic : public T {
virtual ~polymorhic() {}
} ;
intended usage:
typedef polymorphic<std::queue<int> > Queue ;
But this doesn't compile!
The FAQ#35 seems mute here, and I'm beginning to suspect that
something is wrong with my syntax. I also checked
http://www.boost.org/libs/utility/call_traits.htm &
http://www.boost.org/libs/conversion/cast.htm (because it
contained the word: polymorphic_cast, but this turned out
a red-herring)
What would be the correct way to do this?
Many thanks, again.