boostorg / range

Boost.org range module
http://boost.org/libs/range
43 stars 104 forks source link

Fixing non-reference base_t::reference case with replaced_if adaptor #108

Open m-karcz opened 3 years ago

m-karcz commented 3 years ago

replaced_if is just transformed with conditional replacing functor.

If base iterator returns value instead reference, conditional functor returns dangling reference to that value which ends with undefined behaviour. This pull request fix that by forwarding this value or returning copy of held one.

Ex. on gcc-7 added test had {0,0,7,32767} as result range instead of {3,2,7,0}. After this change it returns valid range.

m-karcz commented 3 years ago

I don't know why regression fails on apple, same issue happened on PR#107.

My PR doesn't touch transformed, just replaced_if, but ticket_6742_transformed_c4789_warning fails. Looks like some boost.phoenix breaking change.