Re: [Boost-bugs] [Boost C++ Libraries] #6501: BOOST_STRONG_TYPEDEF Unexpected result when performing an addition (and probably other type of operators) of two strongly typed variables.

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #6501: BOOST_STRONG_TYPEDEF Unexpected result when performing an addition (and probably other type of operators) of two strongly typed variables.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-05-28 18:33:45


#6501: BOOST_STRONG_TYPEDEF Unexpected result when performing an addition (and
probably other type of operators) of two strongly typed variables.
-------------------------------+--------------------------------------------
  Reporter: anonymous | Owner: ramey
      Type: Feature Requests | Status: closed
 Milestone: To Be Determined | Component: serialization
   Version: Boost 1.48.0 | Severity: Problem
Resolution: wontfix | Keywords:
-------------------------------+--------------------------------------------
Changes (by ramey):

  * status: new => closed
  * type: Bugs => Feature Requests
  * resolution: => wontfix

Comment:

 I don't think the serialization library uses this any more. Of course
 it's still in there. I have no idea if anyone uses it. If you want to
 submit a patch, I'd be happy to roll it in.

 On the other hand, one might want to really think about this.

 BOOST_STRONG_TYPEDEF(int, T1);
 BOOST_STRONG_TYPEDEF(int, T2);
 BOOST_STRONG_TYPEDEF(long, T3);
 BOOST_STRONG_TYPEDEF(int, T4)

 T1 t1;
 T2 t2;
 T2 t3;
 T4 t4;

 So what type should t1 + t2 be? What about t1 + t3 ? Not at all clear to
 me. You can already do

 T4 operator+(T1 t1, T3, t3){
     return t1 + t3;
 }

 which was the original motivation for this strong type.

 Of course you can resolve the issue with static_cast<T4>(t1 + t3) or any
 assignment

 t4 = t1 + t3.

 So now I think about this, I don't think it's a good idea to mess with
 this.

 Robert Ramey



 Seems to be the best course would to follow the

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6501#comment:2>
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:09 UTC