|
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