Boost logo

Boost :

Subject: [boost] [serialization] Passing literals to oarchive
From: Bjorn Reese (breese_at_[hidden])
Date: 2015-03-26 17:23:21


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();
      }


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk