Boost logo

Boost :

Subject: Re: [boost] [Variant] Documentation Questions/Notes
From: Dave Abrahams (dave_at_[hidden])
Date: 2012-11-02 11:48:16

on Fri Nov 02 2012, Brian Simpson <> wrote:

> Dave Abrahams <dave <at>> writes:
>> <snip>
>> - Do the semantics for are_strict_equals at
>> differ from those of the built-in equality operator?
> The built-in equality operator compares two instances of identically-typed
> variant. As a binary visitor, however, are_strict_equals can compare
> non-identically-typed variants.

Interesting. hard to think of that as "strict," though.

> boost::variant<int, std::string> v1("hello");
> boost::variant<int, std::string> v2("g'bye");
> boost::variant<double, std::string> v3("hello");
> assert(!(v1 == v2));
> assert(v1 == v3);//compile error
> assert(boost::apply_visitor(are_strict_equals(), v1, v3));
> Interestingly, it looks as if variant goes the extra mile to "prevent comparison
> with foreign types" (that's a comment from variant.hpp). I wonder why.

Yeah. FWIW, while I do appreciate the answers, my *main* intention in
posting these comments was to get the maintainer to fix the
documentation. Hint, hint :-)

Dave Abrahams
BoostPro Computing                  Software Development        Training             Clang/LLVM/EDG Compilers  C++  Boost

Boost list run by bdawes at, gregod at, cpdaniel at, john at