changeset 31:5ea2876ac37a

Relax usage of structs
author David Demelier <markand@malikania.fr>
date Thu, 12 Jul 2018 09:01:40 +0200
parents 35b67345eb4b
children 651aee870e36
files STYLE.md
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/STYLE.md	Tue May 29 16:17:21 2018 +0200
+++ b/STYLE.md	Thu Jul 12 09:01:40 2018 +0200
@@ -357,15 +357,24 @@
 
 ### Structs
 
-Do not use C structs unless you have very good reason to do so. If you want to
-pack some data, just use `class` and make all fields public.
+Use structs for objects that only need to store public data and have no
+invariants. For example PODs and traits match this criteria:
 
 ```cpp
-class point {
-public:
+struct point {
     int x{0};
     int y{0};
 };
+
+template <>
+struct info_traits<point> {
+    template <typename Archive>
+    static void serialize(Archive& ar, const point& point)
+    {
+        ar.write(point.x);
+        ar.write(point.y);
+    }
+};
 ```
 
 ### Return