[Boost-users] calling on the template gods

2 views
Skip to first unread message

Doug Henry

unread,
Nov 14, 2005, 4:43:47 PM11/14/05
to boost
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

Noel Yap

unread,
Nov 14, 2005, 4:56:54 PM11/14/05
to boost...@lists.boost.org
Have you tried:

typename pointer<T>::arr some_stuff;
> _______________________________________________
> Boost-users mailing list
> Boost...@lists.boost.org
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>

_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Rene Rivera

unread,
Nov 14, 2005, 4:52:39 PM11/14/05
to boost...@lists.boost.org
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

Felipe Magno de Almeida

unread,
Nov 14, 2005, 5:02:22 PM11/14/05
to boost...@lists.boost.org
On 11/14/05, Doug Henry <brill...@gmail.com> wrote:
> 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."

Johan Oudinet

unread,
Nov 18, 2005, 5:12:37 AM11/18/05
to boost...@lists.boost.org
On 11/14/05, Doug Henry <brill...@gmail.com> wrote:
> [...]
> 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
Reply all
Reply to author
Forward
0 new messages