Boost logo

Boost :

Subject: Re: [boost] [outcome] High level summary of review feedback accepted so far
From: Peter Dimov (lists_at_[hidden])
Date: 2017-06-03 09:25:38

Vicente J. Botet Escriba wrote:

> I see that the implementation you have done don't allows to return it by
> reference, and I was wondering if the variant2::subset function (which
> could for usability purposes be a non-member function) couldn't return by
> reference.
> Note that a variant with less alternatives than another one has the "same
> shared representation".

It doesn't. The underlying recursive unions are completely different types,
and the indices don't match. But even if it were, why would I want to return
by reference? I don't. Returning by reference is bad practice, it breaks
encapsulation, creates lifetime problems, and so on. It's only done when one
must. I don't agree with your mindset in which returning by reference is
somehow desirable.

Boost list run by bdawes at, gregod at, cpdaniel at, john at