Boost logo

Boost Users :

From: David A. Greene (greened_at_[hidden])
Date: 2006-01-25 10:54:41

Well, if nothing else, I'm learning lots about the corners of the

I've got the following testcase:

#include <boost/shared_ptr.hpp>

#include <iostream>

template<typename Base>
class Handle {
   typedef boost::shared_ptr<Base> type;

template<typename Type>
void print_shared_ptr(boost::shared_ptr<Type> ptr)
   std::cout << "Value is " << *ptr << std::endl;

template<typename Type>
void print_handle(typename Handle<Type>::type ptr)
   std::cout << "Value is " << *ptr << std::endl;

int main(void)
   Handle<int>::type iptr(new int(10));



The calls to print_shared_ptr and the first print_handle resolve just
fine but the compiler (g++ 4.0.2) can't seem to resolve the final call
to print_handle: In function 'int main()': error: no matching function for call to

The point of class Handle is to hide the implementation detail
that boost::shared_ptr is being used to manage resources. I
would like the ability to easily change the type of smart
pointer used throughout the application.

What's going on here? Is there a way to make this work without
having to explicitly specify the type to print_handle?



Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at