
pon., 8 kwi 2019 o 19:55 Peter Dimov via Boost <boost@lists.boost.org> napisaĆ(a):
Andrzej Krzemienski wrote:
Such thing could be achieved if the behavior of variant's assignment and emplacement was controlled by a type trait. The default implementation for unfriendly types would be compile-time error; but users would be able to specialize it for their instantiations of variant in order to assign different semantics: double buffering, or setting the valueless_by_exception state.
This can't work in general. If you have
template<class... T> class lib1::X { private:
variant<T...> state_; };
and
template<class... T> class lib2::Y { private:
variant<T...> state_; };
it's not possible for lib1 and lib2 to choose their preferred variant behaviors independently of one another.
Indeed. Good point. Regards, &rzej;