C++ Logo

std-proposals

Advanced search

Re: Modern std::byte stream IO for C++

From: Lyberta <lyberta_at_[hidden]>
Date: Thu, 5 Mar 2020 23:28:47 +0300
Ryan Nicholl:
> Suggestion: Read and write should not be added as member functions, but as trait specializations.
>
> Reason: Adding serialization points for third party code.
>
> I did this in my rpnx::serial_traits library. It worked pretty well and allowed me to define partial specializations for e.g. std::map<K, V> where K and V also has serial specializations. This was an iterator based library (just reads/writes from iterators instead of "memory" or "files").

Can this be solved with non-member approach that this paper also introduces? Although I would argue that standard containers
shouldn't have default way of serialization.

Instead of custom traits you can pass customization point object around, the default being std::io::read or std::io::write.


Received on 2020-03-05 14:31:42