calling on the template gods
I have been attempting to hide the boost interface when using the boost smart pointers. I basically want to get rid of boost declarations in my API's. This basically involves typedef-ing template classes, and the best solution I have been able to come up with is: template <typename T> struct pointer { typedef boost::scoped_ptr<T> obj; typedef boost::scoped_array<T> arr; typedef boost::shared_ptr<T> sobj; typedef boost::shared_array<T> sarr; }; so I can do things like pointer<int>::arr var(new int[10]). This works fine, but if I try to get tricky it falls apart. Another example: template <typename T> class Stuff { private: pointer<T>::arr some_stuff; }; This does not work (I can't even start to tell you why), but I have hit the point where I have to start second guessing my approach to this problem. Are there other (possibly terrible) tricks to get around the typedef templates problem? Any input will probably help. -thanks
Doug Henry wrote:
template <typename T> class Stuff { private: pointer<T>::arr some_stuff;
Should be: typename pointer<T>::arr some_stuff; -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim - Grafik/jabber.org
Have you tried:
typename pointer<T>::arr some_stuff;
On 11/14/05, Doug Henry
I have been attempting to hide the boost interface when using the boost smart pointers. I basically want to get rid of boost declarations in my API's. This basically involves typedef-ing template classes, and the best solution I have been able to come up with is:
template <typename T> struct pointer { typedef boost::scoped_ptr<T> obj; typedef boost::scoped_array<T> arr; typedef boost::shared_ptr<T> sobj; typedef boost::shared_array<T> sarr; };
so I can do things like pointer<int>::arr var(new int[10]). This works fine, but if I try to get tricky it falls apart. Another example:
template <typename T> class Stuff { private: pointer<T>::arr some_stuff; };
This does not work (I can't even start to tell you why), but I have hit the point where I have to start second guessing my approach to this problem. Are there other (possibly terrible) tricks to get around the typedef templates problem? Any input will probably help.
-thanks
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On 11/14/05, Doug Henry
I have been attempting to hide the boost interface when using the boost smart pointers. I basically want to get rid of boost declarations in my API's. This basically involves typedef-ing template classes, and the best solution I have been able to come up with is:
And why are you doing this? [snip] -- Felipe Magno de Almeida Developer from synergy and Computer Science student from State University of Campinas(UNICAMP). Unicamp: http://www.ic.unicamp.br Synergy: http://www.synergy.com.br "There is no dark side of the moon really. Matter of fact it's all dark."
On 11/14/05, Doug Henry
[...] This does not work (I can't even start to tell you why), but I have hit the point where I have to start second guessing my approach to this problem. Are there other (possibly terrible) tricks to get around the typedef templates problem? Any input will probably help.
I think you want to use the `External polymorphism pattern' -- Johan
participants (5)
-
Doug Henry
-
Felipe Magno de Almeida
-
Johan Oudinet
-
Noel Yap
-
Rene Rivera