thiru-mg commented on code in PR #3545:
URL: https://github.com/apache/avro/pull/3545#discussion_r2591450372
##########
lang/c++/include/avro/Specific.hh:
##########
@@ -165,6 +166,44 @@ struct codec_traits<double> {
}
};
+/**
+* codec_traits for Avro optional.
+*/
+template<typename T>
+struct codec_traits<std::optional<T>> {
+ /**
+ * Encodes a given value.
+ */
+ static void encode(Encoder &e, const std::optional<T> &b) {
Review Comment:
I like the idea of standard encoding for `optional<T>`. Users are expected
to use it only if the schema is `[null, T]`. We can even make the code
generator use `optional<T>` whenever the schema is `[null, T]`. This will break
compatibility, of course. So there should be a switch for the generator to make
this optional (pun intended).
Since this PR does not break compatibility and makes its intent clear, I
think, we should merge it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]