
13 Aug
2010
13 Aug
'10
2:30 p.m.
Ralf Globisch wrote:
Hi, I'm not sure if this is the correct mailing list for this question:
Is there a way to determine if a template parameters is of type boost::shared_ptr at compile time?
I would like to do something like:
template<class A> void doSomething( const A& a) { // if "a" is of type boost::shared_ptr<SomeType> a->someMethod(); // else a.someMethod(); }
Is this possible at all?
Yes it is: template <typename A> void doSomething(A const& a) { a.someMethod(); } template <typename A> void doSomething(shared_ptr<A> a) { a->someMethod(); }
Regards, Ralf