Boost logo

Boost :

Subject: Re: [boost] [iterator] iterator_facade reference type problem
From: Jeffrey Hellrung (jhellrung_at_[hidden])
Date: 2010-01-14 11:00:39


Phil Endecott wrote:
<snip>
> reference. What I think I want to use is std::pair<KEY,VALUE&> i.e. the
> key is returned by value and only the value is returned by reference.
> But when I try this I get various cryptic errors about references to
> references and mpl things.
>
> So, has anyone else tried to do something like this? I wonder if
> boost::reference could be part of the solution.
>
> Thanks for any suggestions,
>
> Phil.

I think your "references to references" problem could have to do with
std::pair not being able to handle references "correctly" :( You might
have to roll your own pair type that uses call_traits to avoid
references to references... (I've had to do this myself)

er's solution seems to do mostly what you want, except the value is
wrapped in a reference_wrapper, which could be inconvenient.

Also, probably want the mutable reference type to be a std::pair< const
Key, ... >.

- Jeff


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk