[MultiIndex] strange problem with simple use of member key extractor
namespace bmi = boost::multi_index;
....
bmi::ordered_non_unique<
bmi::member<
ItemBase,
unsigned,
&ItemBase::my_member
>
>, // ordered_non_unique
....
I'm getting a compiler error on VS10 from
template
On Thu, Jan 17, 2013 at 4:28 PM, John M. Dlugosz
namespace bmi = boost::multi_index;
.... bmi::ordered_non_unique< bmi::member< ItemBase, unsigned, &ItemBase::my_member > >, // ordered_non_unique ....
I'm getting a compiler error on VS10 from
template
struct non_const_member_base { .... Type& operator()(const ChainedPtr& x)const { return operator()(*x); } boost/multi_index/member.hpp(**105): error C2440: 'return' : cannot convert from 'const unsigned int' to 'unsigned int &'
It also tells me that the ChainedPtr is a shared_ptr to a const ItemBase, and I can see that _none_ of the operator()'s in that class return a non-reference. But if the compiler is already thinking ref-becomes-lvalue and leaves that out, the next form
const Type& operator()(const Class& x,int=0)const { return x.*PtrToMember; }
is a perfect match to *x and so I expect the return value to be in fact const (because the object being dereferencd was const)
Any idea what's going on here, and what I might do about it?
Our project is using Boost 1.49, though I didn't see anything in the release notes about changes to MultiIndex in later releases.
Offhand, looks like the wrong return type for the first operator()'s overload. Any chance you can try throwing some metaprogramming in there to get the right return type? Some combination of mpl::if_, add_const, is_const, remove_reference, and indirect_reference, I'd expect (untested): template< class ChainedPtr > result_with_chained_ptr : mpl::if_c< is_const< typename remove_reference< typename indirect_reference< ChainedPtr >::type >::type >::value, typename add_const< Type >::type, Type > { }; - Jeff
participants (2)
-
Jeffrey Lee Hellrung, Jr.
-
John M. Dlugosz