Boost logo

Boost :

Subject: Re: [boost] [TypeErasure] BOOST_TYPE_ERASURE_MEMBER
From: Julien Nitard (julien.nitard_at_[hidden])
Date: 2012-07-23 11:44:45


>
>> Isn't this giving the way for hard to find mistakes ?
>>
>
> Mistakes like what? The signature is
> specified when using the concept.

Well then one need to typedef the "final" concept or risk very strange
errors if some type don't match, due to simple typo.

I have tried something similar to this (shortened but I could provide
a full version):

...
BOOST_TYPE_ERASURE_MEMBER((connect_), Connect, 1);

template <class Socket>
struct disconnect
{
    static void apply(Socket& sock)
    {
        sock.Disconnect();
    }
};

...
typedef mpl::vector<connect_<void(const EndPoint&)>,
disconnect<_self>, copy_constructible<> > SockReqs;

typedef any<mpl::vector<connect_<void(const EndPoint)> >, _self&>
AnyConnect; // WOOPS, missed the "&"

void DoConnect(AnyConnect ac)
{
    ac.Connect(EndPoint());
}

...

AnySockRef as2(...);
AnyConnect ac2(as2);

Even with clang I get 50 lines of errors starting with:

clang++ -std=c++0x -c
"/media/win/Projects/type_erasure/type_erasure/main.cpp" -O2 -Wall
-o ./Release/main.o -I. -I/media/win/Projects/boost_trunk
-I/media/win/Projects/type_erasure -I.
In file included from /media/win/Projects/type_erasure/type_erasure/main.cpp:6:
In file included from
/media/win/Projects/type_erasure/boost/type_erasure/any.hpp:39:
In file included from
/media/win/Projects/type_erasure/boost/type_erasure/binding.hpp:29:
In file included from
/media/win/Projects/type_erasure/boost/type_erasure/detail/vtable.hpp:191:
In file included from
/media/win/Projects/boost_trunk/boost/preprocessor/iteration/detail/iter/forward1.hpp:52:
/media/win/Projects/type_erasure/boost/type_erasure/detail/vtable.hpp:240:28:
error: no matching member function for call to 'lookup'
        BOOST_PP_REPEAT(N, BOOST_TYPE_ERASURE_CONVERT_ELEMENT, ~)
        ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Julien


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk