|
Boost Users : |
From: Sohail Somani (s.somani_at_[hidden])
Date: 2006-01-25 14:14:24
> > Why is there a need? Presumably you're potential surrogate
> for shared_ptr
> > will also support operator *, and that's all you use in
> your function.
>
> Why is there a need to do what? I'm not following you here. I've
> gone through and specified Type everywhere in my application. It's
> ugly but it works. Would the upcoming template typedef feature
> avoid the need to specify Type in the call?
I think what Jens is getting at is that you should use the duck-typing
that
C++ templating affords you:
#include <boost/smart_ptr.hpp>
#include <iostream>
using namespace std;
template<typename Handle>
void print_handle(Handle p)
{
cout << *p << endl;
}
int main()
{
int * a = new int(5);
boost::shared_ptr<int> b(new int(6));
print_handle(a);print_handle(b);
}
$ ./a.out
5
6
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net