Boost logo

Boost :

Subject: [boost] Feature request: variant::view
From: TONGARI J (tongari95_at_[hidden])
Date: 2016-06-19 09:31:58


Hi,

Sometimes we need to view a value as a variant and we don't want to copy
the value into a variant.

It'd be great if there's a variant::view that works like a variant but
holds a reference to the value instead.

The constructor should allow any reference to the types as in the variant,
and a constructor that takes a reference to the variant, e.g.

template<class T1, class T2...>
class variant<T1, T2...>::view
{
    view(T1&);
    view(T2&);
    ...
    view(variant&);
};

And we can use apply_visitor/get on a view as on a variant.

Thoughts?

Thanks.


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