Re: [Boost-bugs] [Boost C++ Libraries] #10811: Add operators !=, <=, >, >=

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #10811: Add operators !=, <=, >, >=
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-12-04 10:59:36


#10811: Add operators !=, <=, >, >=
-------------------------------+-----------------------
  Reporter: viboes | Owner: apolukhin
      Type: Feature Requests | Status: assigned
 Milestone: Boost 1.58.0 | Component: variant
   Version: Boost 1.57.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------+-----------------------

Comment (by apolukhin):

 Replying to [comment:3 viboes]:
> Thanks even if I expected that operator>= be defined in terms of
 operator>= :(

 Current approach reduces binary size. It also follows the Standard Library
 approach (for example `std::vector` implement comparisons in the same way)
 to reduce requirements for ValueTypes.
 [[BR]]
 [[BR]]

> I find weird making private these kind of overloads.
>
>
> {{{
> inline bool operator>=(const variant& rhs) const
> {
> return !(*this < rhs);
> }
> }}}
>
> Does it means that
>
>
> {{{
> variant< int, string> v = 1;
> auto x = 1 < v;
> }}}
>
> would compile and
>
> {{{
> variant< int, string> v = 1;
> auto x = v < 1;
> }}}
>
>
> wouldn't?

 Both cases won't compile. I was following the existing schema and
 implemented those operators in the same way as `operator==` and
 `operator<` were implemented.

 Though it could be useful to have comparison operators with types that are
 held in variant, just like in your example: `(1 < v || v < 1)`. To do it
 in an effective way some metaprograming pretty close to one required by
 #547 must be done. Created a separate ticket #10845 for this feature.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/10811#comment:5>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:17 UTC