
Filip Konvi?ka ha escrito:
If you're using Boost 1.34, then you can simply use
hashed_unique< tag<userid>, member<Peer,std::string,&Peer::userid> >
Hi,
I'm just curious - is there a reason why "member" takes 3 template parameters, and not just one, like in
member<&Peer::userid>
? The first two types can be extracted from the member pointer, so I find this a bit redundant...
It certainly looks redundant, but it turns out you really cannot do what you propose: template<...> struct member; What should "..." look like? It's not a type parameter, but it cannot be made a non-type parameter either since we don't know the type of the pointer-to-member being passed... In decltype- (or typeof-) enabled compilers a terser syntax could be achieved by using some macro hackery: template<typename PtrToMemberType,PtrToMemberType PtrToMember> struct member; #define MEMBER(PtrToMember) \ member<decltype(PtrToMember),PtrToMember> So maybe when C++0x arrives we can take advantage of this. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo