You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As explained in the SO answer, there's disagreement over assignment. To take your case as an example, if I assign to the return value of axis_get, what should happen?
I argued in the SO question discussion that I would except a variant which currently holds a reference to act like a reference, so assignment should pass through, not rebind. But I understand from your comments on cpplang slack that you want to keep this open as long as it is open for std::variant, which makes perfect sense.
I think this should be closed. If variant2 is to be a drop-in replacement for std::variant with the exact same interface and behavior, support for references cannot be implemented.
variant2 cannot have references as bounded types, https://godbolt.org/z/mnP-CU, which is conforming with std::variant, but this could be another improvement over std::variant if it is not too much work to implement. boost::variant is supporting them and I am using this in boost.histogram in this function
https://github.com/HDembinski/histogram/blob/5ae08d40c26f8db0613545b84a4c0b60c3729102/include/boost/histogram/detail/axes.hpp#L47
which allows me to get a reference to an element of a std::tuple with a run-time index.
Related SO question:
https://stackoverflow.com/questions/54218595/why-are-references-forbidden-in-stdvariant
The text was updated successfully, but these errors were encountered: