# C++ serialization development

**URL:** <https://forum.opencyphal.org/t/c-serialization-development/1597>\
**Category:** Development & Maintenance\
**Created:** [February 22, 2022, 10:19am UTC](https://forum.opencyphal.org/t/c-serialization-development/1597 "2022-02-22T10:19:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ASMik](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/asmik/32/990_2.png) [@ASMik](https://forum.opencyphal.org/u/ASMik)\
**Post date:** [February 22, 2022, 10:19am UTC](https://forum.opencyphal.org/t/c-serialization-development/1597/1 "2022-02-22T10:19:23Z")

</div>

I’m currently writing C++ (de)serialization layer in Nunavut.  
I’m mostly copying C layer, adapting it to C++.  
Can someone advise me on this?  
How can I run C++ linting for the verification part?  
Can I add external header-only libraries to support headers for C++17/20/23 backports like `std::span` and `std::expected` (I’m using [`span-lite`](https://github.com/martinmoene/span-lite) and [`tl::expected`](https://github.com/TartanLlama/expected))? If I can use them, should I write some kind of a script to update these libraries akin to how Jinja is vendored in Nunavut?  
I am using `span` to hold information about buffers and `expected` to return result.  
Are there any tests on cross-language communication?

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [February 23, 2022, 10:20am UTC](https://forum.opencyphal.org/t/c-serialization-development/1597/2 "2022-02-23T10:20:50Z")

</div>

The best source of advice is @scottdixon.

The current plan is to support C++14 and C++17. The former comes with certain limitations such as using a custom bare-bones implementation of `std::variant` while the latter can use that from the standard library. I understood that C++14 is a hard requirement so it is unlikely to be changeable. Pulling other items from newer standards beyond `std::variant` is probably possible; for instance, `std::span` is a great addition in C++20 that also happens to be absolutely trivial to implement, so we could perhaps ship a homegrown replacement and use the proper `std::span` if `__cplusplus > 2020'00'00`. `std::expected` is, in the end, just a variant with a bit of sugar, not sure how critical it is in this case.

@scottdixon can we carve out a set of tasks for Pavel to get started with?

---

<div class="post-metadata">

**Author:** ![ASMik](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/asmik/32/990_2.png) [@ASMik](https://forum.opencyphal.org/u/ASMik)\
**Post date:** [February 23, 2022, 6:30pm UTC](https://forum.opencyphal.org/t/c-serialization-development/1597/3 "2022-02-23T18:30:55Z")

</div>

Here is a [PR with my work so far](https://github.com/UAVCAN/nunavut/pull/236).
