Boost logo

Boost Users :

From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2007-06-28 02:45:02


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net