
AMDG On 09/13/2012 01:42 PM, Christophe Henry wrote:
* ping *
I'm sorry. I don't think I received the original message.
<snip> namespace boost { namespace type_erasure { template<class C, class T, class Base> struct concept_interface< ::getName<C, T>, Base, C> : Base { T getName() { return call(::getName<C, T>(), *this); } }; } }
<snip>
This compiles and outputs as expected.
Problem 1: This will not compile std::cout << "data: " << (*it).getName() << std::endl;
concept_interface<...>::getName needs to be declared const for this to work.
Hmmm ok not so bad. I'll gladly pay the extra line. (interestingly, it would compile and work without const)
Problem 2: if I use the MEMBER macro:
BOOST_TYPE_ERASURE_MEMBER((has_getName), getName, 0); typedef any< mpl::vector< has_getName<std::string const&()>, relaxed_match, copy_constructible<>, typeid_<> >, const _self& > AnyNameable;
Then the code does not compile, unless I accept to give up all of my consts.
For a constant member function use: has_getName<std::string const&(), const _self>
On one hand, I will find it a easier job to sell type_erasure with the macro, OTOH, I will not give up my consts ;-)
Would it be possible to have the macro AND const-correctness?
In Christ, Steven Watanabe