
On Tue, 11 May 2010, joaquin@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
It seems like it is. Is the workaround that complicated, though? Is there a way to get some of that factored out to reuse in other Boost libraries? Would putting an explicit cast to ... std::pair::* in the template argument work instead?
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::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. (snip)
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:
template
class pair_first_extractor { typedef std::pair value_type; public: typedef First result_type;
const result_type& operator()(const value_type& x)const { return x.first; }
result_type& operator()(value_type& x)const { return x.first; } };
typedef multi_index::multi_index_container< std::pair
, multi_index::indexed_by< multi_index::sequenced<>, multi_index::hashed_unique< pair_first_extractor ghost_cells_type;
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. Otherwise, can I copy your code into BGL (under the Boost license)? Also, would just a simple cast on the pointer-to-member type work, or are those not allowed in non-type template arguments? -- Jeremiah Willcock