[TypeErasure] BOOST_TYPE_ERASURE_MEMBER

Hi Steven, all BOOST_TYPE_ERASURE_MEMBER is only mentioned in the reference, it could be useful to add it to the tutorial: I guess that most user concepts will start from member functions of a given type. A sample on how to specialize it for types not having the said member function would be also welcome. Finally, why did you choose not to include the member's signature in the macro ? Isn't this giving the way for hard to find mistakes ? Regards, Julien

AMDG On 07/22/2012 04:17 AM, Julien Nitard wrote:
Hi Steven, all
BOOST_TYPE_ERASURE_MEMBER is only mentioned in the reference, it could be useful to add it to the tutorial: I guess that most user concepts will start from member functions of a given type. A sample on how to specialize it for types not having the said member function would be also welcome.
Yes. This macro was introduced fairly late, and I didn't get around to updating the tutorial for the review. I also want to add a corresponding BOOST_TYPE_ERASURE_FREE macro for non-member functions.
Finally, why did you choose not to include the member's signature in the macro ?
I was trying to make the concept that the macro generates as generic as possible.
Isn't this giving the way for hard to find mistakes ?
Mistakes like what? The signature is specified when using the concept. In Christ, Steven Watanabe

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
participants (2)
-
Julien Nitard
-
Steven Watanabe