Boost logo

Boost Users :

Subject: [Boost-users] [TypeErasure] Reference of forward declared type requires complete type
From: Yuan Yao (yaoyuan0123_at_[hidden])
Date: 2015-09-03 23:20:19


Hi all,

I try to use boost.type_erasure (boost 1.59) with forward declared type
as shown below:

================================================
#include <boost/type_erasure/any.hpp>
#include <boost/type_erasure/member.hpp>

struct Type;

BOOST_TYPE_ERASURE_MEMBER((HasTest), Test, 1)

using Any = boost::type_erasure::any <
     boost::mpl::vector <
     HasTest<void(Type&)>,
     boost::type_erasure::destructible<>,
     boost::type_erasure::relaxed
>
>;

int main() {
     Any obj;
}
================================================

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?


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