Why non-const reference here?
template<class T>
const nvp< T > make_nvp(const char * name, T & t);
The reason i'm asking is that i have a structure with public fields and i need to make them private and use accessors instead. So i would like to know if i'm allowed to use temporary variable and pass them to make_nvp
or i need to befriend my serializer with the data structure.
// option 1
auto a = data.getA();
ar & make_nvp("A", a);
// option 2
ar & make_nvp("A", data._a); // _a is private, but serializer is friend
I don't know what is this ar
because it's a templated parameter, so in some cases it could make use of this non-constness and save it for later use and then option 1
is problematic.