Boost logo

Boost Users :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-03-28 12:52:23


AMDG

Jiri Palecek wrote:
> Hello,
>
> is there some deep reason why comparing variant to a nonvariant is
> disabled? For example:
>
> variant<int, string> 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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net