You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Flush the writer's remaining state into the buffer
342
359
uint32_t num_bits = writer.flush();
343
360
344
-
// Create a reader by moving and invalidating the writer
361
+
// Create a reader, referencing the buffer and bits written
345
362
bit_reader reader(buffer, num_bits);
346
363
347
364
// Read the value back
@@ -374,6 +391,9 @@ struct serialize_traits<TRAIT_TYPE> // The type to use when referencing this spe
374
391
};
375
392
```
376
393
394
+
As with any functions, you are free to overload them if you want to serialize an object differently, depending on any parameters you pass.
395
+
As long as their list of parameters starts with `bit_writer&` and `bit_reader&` respectively they will be able to be called.
396
+
377
397
## Unified serialization
378
398
The serialization can also be unified with templating, if writing and reading look similar.
379
399
If some parts of the serialization process don't match entirely you can query the `Stream::reading` or `Stream::writing` and branch depending on the value.
0 commit comments