$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: [boost] [range_ex] warning when using index operator on the element of a transformed range of a transformed range of a fusion sequence
From: Stjepan Rajko (stipe_at_[hidden])
Date: 2008-10-30 18:37:44
Hello,
I apologize in advance for the long explanation about a small
problem... I tried to trim it down as much as I could right now. If
it is still too much info, I can try to trim it down more...
I am working in a context where I have Ranges of Ranges of fusion
Sequences, and need to access different "slices" of said contraption.
By that I mean, if I have a:
std::vector<std::vector<fusion::vector<int, double> > > RoRoS,
I would like to access a Range of Range of ints (consisting of the
first elements of the fusion vector), and a Range of Range of doubles
(consisting of the second elements).
I wrote a little utility that allows me to do that (using RangeEx
`transformed` adaptors) in the context of a for_each iteration (see
attached "for_each_element_and_slice.hpp"). The purpose of this one
is, given say a
fusion::vector<foo,bar> S0;
for_each_element_and_slice<1>(S0, RoRoS, some_fn) will call:
some_fn (the foo element of S0, the Range of Range of ints)
some_fn (the bar element of S0, the Range of Range of doubles)
1 specifies the "depth" - 1 means the second parameter is a Range of
Range of Sequence, 0 would mean Range of Sequence, 2 would mean Range
of Range of Range of Sequence.
Anyway, in doing this I ran into a weird warning. If some_fn is as follows:
struct weird_warning
{
template<typename Element, typename Slice>
void operator()(Element &element, const Slice &slice) const
{
*boost::begin(slice[0]); // no warning
slice[0][0]; // warning: operator[](outer) returning reference
to temporary
}
};
...I get warnings as indicated by the above comments. That is,
*boost::begin(slice[0]) works just fine, but slice[0][0] issues a
warning about the outer operator[] returning a reference to a
temporary. I would be inclined to think that both of these should be
legal operations (with no warnings being issued) - is that correct?
If so, is there a problem in my use of range_ex, or is there a problem
with range_ex?
(the test file test_for_each_element_and_slice.hpp attached - the bits
relevant to this warning are outlined by:
//------------------------------------------------------------
//------------------------------------------------------------
...relevant bits...
//------------------------------------------------------------
//------------------------------------------------------------
)
I am using what I believe is the latest RangeEx from the vault (thanks
for this great utility!) against boost trunk.
Any help appreciated!
Thanks,
Stjepan