https://github.com/royjacobson/ser20
A C++20 serialization library (cereal fork)
https://github.com/royjacobson/ser20
cplusplus cplusplus-20 cpp20 serialization
Last synced: 6 months ago
JSON representation
A C++20 serialization library (cereal fork)
- Host: GitHub
- URL: https://github.com/royjacobson/ser20
- Owner: royjacobson
- License: bsd-3-clause
- Created: 2022-12-19T12:51:32.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-01-12T21:23:17.000Z (almost 3 years ago)
- Last Synced: 2025-04-11T01:46:01.440Z (8 months ago)
- Topics: cplusplus, cplusplus-20, cpp20, serialization
- Language: C++
- Homepage:
- Size: 2.91 MB
- Stars: 29
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Ser20 - A C++20 library for serialization
==========================================
Ser20 is a C++20 fork of cereal, a C++11 serialization library. It is completely compatible
except for a namespace change. Thanks to modern meta-programming, Ser20 is 15% smaller and
can compile up to 25% faster. Ser20 also has some other runtime optimizations, and is optimized for debug experience and debug symbols size.
Ser20 requires compiler support for C++20 concepts. Clang 13 and GCC10 should be modern enough,
but CI testing is not set up very hermetically yet.
### Using Ser20
#### Installation
The best way to use Ser20 is with CMake. Ser20 is not header-only, which means that a compilation step is necessary to use it.
The simplest way to do that is to use Ser20 as a subproject in your CMake project.
#### Usage
Using Ser20 is pretty simple. Except for a new namespace, it is completely compatible with Ser20
and therefor pretty compatible with boost::serialize as well.
This is a simple usage example:
```cpp
#include
#include
#include
#include
struct MyRecord {
uint8_t x, y;
float z;
template void serialize(Archive& ar) { ar(x, y, z); }
};
struct SomeData {
int32_t id;
std::shared_ptr> data;
template void save(Archive& ar) const { ar(data); }
template void load(Archive& ar) {
static int32_t idGen = 0;
id = idGen++;
ar(data);
}
};
int main() {
std::ofstream os("out.bin", std::ios::binary);
Ser20::BinaryOutputArchive archive(os);
SomeData myData;
archive(myData);
return 0;
}
```
### Performance
Although it's by far not the fastest serialization library out there, Ser20 is
sometimes two times as fast as cereal and boost::serialization in binary serialization:

This difference is mostly due to buffering of small reads and writes to ostreams.
## Ser20 has a permissive license
Ser20 is licensed under the [BSD license](http://opensource.org/licenses/BSD-3-Clause).
## Ser20 build status
* [](https://github.com/royjacobson/ser20/actions/workflows/ci.yml)
* [](https://github.com/royjacobson/ser20/actions/workflows/ci-macos.yml)
---