Re: [Boost-users] [TypeErasure] Reference of forward declared type requires complete type

On 2015-09-03 23:36:03, Steven Watanabe wrote:
<snip>
struct Type;
BOOST_TYPE_ERASURE_MEMBER((HasTest), Test, 1)
<snip> HasTest<void(Type&)>, <snip> ================================================
However, the compiler (e.g. clang) complains about incomplete type:
================================================ /usr/local/include/boost/type_traits/is_base_and_derived.hpp:228:42: error: incomplete type 'Type' used in type trait expression BOOST_STATIC_CONSTANT(bool, value = (BOOST_IS_BASE_OF(B,D) && ! ::boost::is_same<ncvB,ncvD>::value)); ================================================
Replacing Type& with Type* can fix the problem. Is this a bug?
Probably. Is boost::type_erasure::is_placeholder in the instantiation backtrace?
Yes. And the following is the full error message: ================================================ In file included from main.cpp:1: In file included from /usr/local/include/boost/type_erasure/any.hpp:36: In file included from /usr/local/include/boost/type_erasure/detail/normalize.hpp:30: In file included from /usr/local/include/boost/type_erasure/detail/get_placeholders.hpp:25: In file included from /usr/local/include/boost/type_erasure/is_placeholder.hpp:15: /usr/local/include/boost/type_traits/is_base_and_derived.hpp:228:42: error: incomplete type 'Type' used in type trait expression BOOST_STATIC_CONSTANT(bool, value = (BOOST_IS_BASE_OF(B,D) && ! ::boost::is_same<ncvB,ncvD>::value)); ^ /usr/local/include/boost/type_traits/intrinsics.hpp:189:53: note: expanded from macro 'BOOST_IS_BASE_OF' # define BOOST_IS_BASE_OF(T,U) (__is_base_of(T,U) && !is_same<T,U>::value) ^ /usr/local/include/boost/config/suffix.hpp:394:72: note: expanded from macro 'BOOST_STATIC_CONSTANT' # define BOOST_STATIC_CONSTANT(type, assignment) static const type assignment ^ /usr/local/include/boost/type_traits/is_base_and_derived.hpp:237:25: note: in instantiation of template class 'boost::detail::is_base_and_derived_impl<boost::type_erasure::placeholder, Type>' requested here , (::boost::detail::is_base_and_derived_impl<Base,Derived>::value) ^ /usr/local/include/boost/type_traits/detail/bool_trait_def.hpp:74:30: note: expanded from macro 'BOOST_TT_AUX_BOOL_TRAIT_DEF2' BOOST_TT_AUX_BOOL_C_BASE(C) \ ^ /usr/local/include/boost/type_traits/detail/bool_trait_def.hpp:55:81: note: expanded from macro 'BOOST_TT_AUX_BOOL_C_BASE' # define BOOST_TT_AUX_BOOL_C_BASE(C) : public ::boost::integral_constant<bool,C> ^ /usr/local/include/boost/type_erasure/is_placeholder.hpp:27:25: note: in instantiation of template class 'boost::is_base_and_derived<boost::type_erasure::placeholder, Type>' requested here struct is_placeholder : ::boost::is_base_and_derived<placeholder, T> {}; ^ /usr/local/include/boost/mpl/aux_/nested_type_wknd.hpp:27:7: note: in instantiation of template class 'boost::type_erasure::is_placeholder<Type>' requested here : T::type ^ /usr/local/include/boost/mpl/not.hpp:41:11: note: in instantiation of template class 'boost::mpl::aux::nested_type_wknd<boost::type_erasure::is_placeholder<Type>
' requested here
BOOST_MPL_AUX_NESTED_TYPE_WKND(T)::value ^ /usr/local/include/boost/mpl/aux_/nested_type_wknd.hpp:38:24: note: expanded from macro 'BOOST_MPL_AUX_NESTED_TYPE_WKND' ::boost::mpl::aux::nested_type_wknd<T> \ ^ /usr/local/include/boost/mpl/aux_/nested_type_wknd.hpp:27:7: note: in instantiation of template class 'boost::mpl::not_<boost::type_erasure::is_placeholder<Type> >' requested here : T::type ^ /usr/local/include/boost/mpl/aux_/preprocessed/gcc/or.hpp:51:11: note: (skipping 17 contexts in backtrace; use -ftemplate-backtrace-limit=0 to see all) BOOST_MPL_AUX_NESTED_TYPE_WKND(T1)::value ^ /usr/local/include/boost/mpl/aux_/nested_type_wknd.hpp:38:24: note: expanded from macro 'BOOST_MPL_AUX_NESTED_TYPE_WKND' ::boost::mpl::aux::nested_type_wknd<T> \ ^ /usr/local/include/boost/mpl/eval_if.hpp:38:22: note: in instantiation of template class 'boost::mpl::fold<boost::mpl::vector<HasTest<void (Type &), boost::type_erasure::_self>, boost::type_erasure::destructible<boost::type_erasure::_self>, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::mpl::s_item<boost::mpl::vector<HasTest<void (Type &), boost::type_erasure::_self>, boost::type_erasure::destructible<boost::type_erasure::_self>, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::mpl::set0<mpl_::na> >, boost::type_erasure::detail::collect_concepts<mpl_::arg<2>, boost::mpl::map0<mpl_::na>, mpl_::arg<1> > >' requested here typedef typename f_::type type; ^ /usr/local/include/boost/type_erasure/detail/normalize.hpp:388:36: note: in instantiation of template class 'boost::mpl::eval_if<boost::mpl::is_sequence<boost::mpl::vector<HasTest<void (Type &), boost::type_erasure::_self>, boost::type_erasure::destructible<boost::type_erasure::_self>, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na> >, boost::mpl::fold<boost::mpl::vector<HasTest<void (Type &), boost::type_erasure::_self>, boost::type_erasure::destructible<boost::type_erasure::_self>, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::mpl::s_item<boost::mpl::vector<HasTest<void (Type &), boost::type_erasure::_self>, boost::type_erasure::destructible<boost::type_erasure::_self>, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::mpl::set0<mpl_::na> >, boost::type_erasure::detail::collect_concepts<mpl_::arg<2>, boost::mpl::map0<mpl_::na>, mpl_::arg<1> > >, boost::mpl::identity<boost::mpl::s_item<boost::mpl::vector<HasTest<void (Type &), boost::type_erasure::_self>, boost::type_erasure::destructible<boost::type_erasure::_self>, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::mpl::set0<mpl_::na> > > >' requested here typedef typename ::boost::mpl::eval_if< ::boost::mpl::is_sequence<Concept>, ^ /usr/local/include/boost/type_erasure/any.hpp:65:49: note: in instantiation of template class 'boost::type_erasure::detail::collect_concepts<boost::mpl::vector<HasTest<void (Type &), boost::type_erasure::_self>, boost::type_erasure::destructible<boost::type_erasure::_self>, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::mpl::map0<mpl_::na>, boost::mpl::set0<mpl_::na> >' requested here typename ::boost::type_erasure::detail::collect_concepts< ^ /usr/local/include/boost/type_erasure/any.hpp:132:43: note: in instantiation of template class 'boost::type_erasure::detail::compute_bases<boost::type_erasure::any<boost::mpl::vector<HasTest<void (Type &), boost::type_erasure::_self>, boost::type_erasure::destructible<boost::type_erasure::_self>, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::type_erasure::_self>, boost::mpl::vector<HasTest<void (Type &), boost::type_erasure::_self>, boost::type_erasure::destructible<boost::type_erasure::_self>, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::type_erasure::_self>' requested here public ::boost::type_erasure::detail::compute_bases< ^ main.cpp:17:10: note: in instantiation of template class 'boost::type_erasure::any<boost::mpl::vector<HasTest<void (Type &), boost::type_erasure::_self>, boost::type_erasure::destructible<boost::type_erasure::_self>, boost::type_erasure::relaxed, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na, mpl_::na>, boost::type_erasure::_self>' requested here Any obj; ^ main.cpp:4:8: note: forward declaration of 'Type' struct Type; ^ 1 error generated. ================================================
participants (1)
-
Yuan Yao