variant comparison operators
Hello,
is there some deep reason why comparing variant to a nonvariant is
disabled? For example:
variant
AMDG Jiri Palecek wrote:
Hello,
is there some deep reason why comparing variant to a nonvariant is disabled? For example:
variant
v=1; assert(v==1); // doesn't compile The problem is that there are overloads for anything else than a variant, which explicitely fail to compile (via static_assert and other means). If they weren't there, everything would work (the comparison would invoke conversion constructor, and then normal variant/variant comparison.
It seems to be an explicit decision. http://svn.boost.org/trac/boost/changeset/19960 It is probably just to be the same as operator< (See http://lists.boost.org/Archives/boost/2003/09/52425.php for a rationale)
Another problem is that variant includes the == operator, but not !=, even though this could be easily achieved with boost::operators.
You're not the first to want this http://lists.boost.org/Archives/boost/2006/06/105801.php In Christ, Steven Watanabe
participants (2)
-
Jiri Palecek
-
Steven Watanabe