|
Boost Users : |
Subject: Re: [Boost-users] [MultiIndex] Visual C++ 10 issue
From: Joaquin M Lopez Munoz (joaquin_at_[hidden])
Date: 2010-05-11 14:40:13
Jeremiah Willcock <jewillco <at> osl.iu.edu> writes:
>
> On Tue, 11 May 2010, joaquin <at> tid.es wrote:
>
> > Jeremiah Willcock escribió:
> >> On Mon, 10 May 2010, Richard Webb wrote:
> >>
> >>
> >>> Sounds like the same problem as
> >>> https://svn.boost.org/trac/boost/ticket/3594
> >>>
> >>> [...]
> >
> > Hi Jeremiah,
> >
> > The problem is not a bug with VC++ 10, but a collateral effect of the
> > way std::pair is implemented in the stdlib provided for this compiler
> > --namely, by deriving from an implementation-specific _Pair_base class
> > where the members are actually defined. This reduced test case can help
> > explain the problem:
>
> Could this be viewed as a library issue, then, or is the type of
> &std::pair<a, b>::first not considered to be part of the library's
> interface? It does seem bad that any use of pointers-to-members is
> fragile to the use of mixins or hidden base classes as part of a class's
> implementation.
I'm sure there must be valid reasons for the restrictons posed
by 14.3.2/5 but I can't see them. I posted about the issue
in comp.std.c++ some years ago alas the response was nearly null:
I might try posting again.
> > The workaround applied at https://svn.boost.org/trac/boost/ticket/3594
> > works, but it's probably overkill (and uses the objectionable
> > member_offset, which is really meant to be used as a last resort for
> > legacy compilers). A nicer workaround consists in providing a
> > user-defined key extractor:
> >
> > [...]
>
> OK. Should that code (for std::pairs) be part of multi_index anywhere?
> It would seem like other users would use parts of pairs as keys.
I don't feel comfortable with providing such custom key
extractors (where should we finish once we start down this path?)
On the other hand, specializing boost::multi_index::member
when Class is a std::pair might be a good idea. I'll add it to
my "to consider" list.
> Otherwise, can I copy your code into BGL (under the Boost license)?
Sure, use it freely. You might want to use the specialization
variant in anticipation to Boost.MultiIndex providing this
specialization itself in the future.
> Also, would just a simple cast on the pointer-to-member type work,
> or are those not allowed in non-type template arguments?
That wouldn't work, you can't cast that way in that context. But if
you don't mind coupling with VC++ 10 stdlib implementation details
you can just use
boost::multi_index::member<
std::_Pair_base<key_type,value_type>,
key_type,
std::_Pair_base<key_type,value_type>::first
>
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