Boost logo

Boost Users :

Subject: [Boost-users] [shared_ptr] Error in Constructor
From: David A. Greene (greened_at_[hidden])
Date: 2010-05-21 21:54:25


Using boost 1.42, the attached fails to compile with g++:

shared_ptr_test.cpp: In instantiation of ‘Wrapper<A>’:
/usr/include/boost/smart_ptr/detail/sp_convertible.hpp:48: instantiated from
‘boost::detail::sp_convertible<Wrapper<B>, Wrapper<A> >’
/usr/include/boost/smart_ptr/detail/sp_convertible.hpp:67: instantiated from
‘boost::detail::sp_enable_if_convertible<Wrapper<B>, Wrapper<A> >’
shared_ptr_test.cpp:33: instantiated from here
shared_ptr_test.cpp :14: error: invalid use of incomplete type ‘struct A’
shared_ptr_test.cpp:5: error: forward declaration of ‘struct A’

This is surprising to me as the code does not use A anywhere.

I found BOOST_SP_NO_SP_CONVERTIBLE in shared_ptr.hpp and indeed
turning that on fixes the problem. Unfortunately, it doesn't seem to
be documented.

What's the rationale for the enable_if'd constructor? Is
BOOST_SP_NO_SP_CONVERTIBLE an official part of the
library? Apparently it is causing gcc to check all doSomething
members of Action against shared_ptr<Wrapper<B> >
and those checks are causing instantiations of Wrapper<A>.

                      -Dave




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