Re: [Boost-bugs] [Boost C++ Libraries] #11152: Passing literals to oarchive

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #11152: Passing literals to oarchive
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-03-30 15:40:22


#11152: Passing literals to oarchive
-------------------------------+---------------------------
  Reporter: breese@… | Owner: ramey
      Type: Feature Requests | Status: new
 Milestone: To Be Determined | Component: serialization
   Version: Boost 1.57.0 | Severity: Optimization
Resolution: | Keywords:
-------------------------------+---------------------------

Comment (by ramey):

 Currently we cannot pass literals directly to an oarchive like this:
    oarchive << 42;
 since compilation fails in interface_oarchive.hpp, as the operator<<
 only takes parameters by reference.
 We can remedy this by changing operator<< to take the parameter
 by const-ref instead, as show below. Is there any reason not to do
 this?
 {{{
 --- a/include/boost/archive/detail/interface_oarchive.hpp
 +++ b/include/boost/archive/detail/interface_oarchive.hpp
 @@ -59,7 +59,7 @@ public:
       }
       template<class T>
 - Archive & operator<<(T & t){
 + Archive & operator<<(const T & t){
           this->This()->save_override(t, 0);
           return * this->This();
       }
 }}}
 Since I wrote this, I've been considering it. I looked at your patch.
 I would likely condition it on the type being a tracked or untracked
 type rather than being on a primitive type.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11152#comment:1>
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:18 UTC