> >Subject: Re: [boost] About member extraction > From: Joaquín Mª López Muñoz <[EMAIL PROTECTED]> > Date: Mon, 14 Jul 2003 14:24:37 +0200 > To: Boost mailing list <[EMAIL PROTECTED]> > > > >Daryle Walker ha escrito: > >> But doesn't the "PtrToMember" template parameter already imply the >> "Type" and "Class" parameters? So specifying all three would be >> redundant. Could we reduce it by: >> >> //================================================================ >> template < typename PtrToMember > >> struct member_extractor >> { >> // Don't know if this is a real type-traits class >> BOOST_STATIC_ASSERT(is_pointer_data_member<PtrToMember>::value); >> >> // The extractor traits classes aren't real (yet, maybe) >> typedef get_class_type<PtrToMember> argument_type; >> typedef get_member_type<PtrToMember> return_type; >> >> return_type const & operator ()( argument_type const &c ) const >> { return c.*PtrToMember; } >> >> return_type & operator ()( argument_type &c ) const >> { return c.*PtrToMember; } >> }; > >Of the approaches you propose, this is the one that I like best, but >I'm afraid it cannot be implemented: Note that PtrToMember is a >*type* (something like int A::*), not a pointer to member. >member_extractor would have to defined as > >template < typename PtrToMember, PtrToMember ptr > >struct member_extractor > >and used as > >member_extractor<int A::*,&A::x>; // x is an int member of A
Actually, I think it's worse (I don't have a C++ compiler with me right now:-( ) Something in the lines of: template < typename type, typename result, result type::* ptr > struct member_extractor > >which takes us again to the redundancy we were trying to avoid. >Something in the way of eliminating this redundancy, however, would be >a boon. Maybe some metaprogramming gurus here can think of >something. > I would really love to see a solution to this ;-) Best, John >Joaquín M López Muñoz >Telefónica, Investigación y Desarrollo > >_______________________________________________ >Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost