You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by "thiru-mg (via GitHub)" <gi...@apache.org> on 2025/01/01 03:11:42 UTC
Re: [PR] AVRO-4105: [C++] Remove boost::lexical_cast and boost::math [avro]
thiru-mg commented on code in PR #3277:
URL: https://github.com/apache/avro/pull/3277#discussion_r1900313226
##########
lang/c++/impl/json/JsonIO.hh:
##########
@@ -404,9 +404,25 @@ public:
template<typename T>
void encodeNumber(T t) {
Review Comment:
Instead of having a template function `encodeNumber` and its specializations, it'll be cleaner to have (a) a template function `numberToString` and its specialization to convert the given number into a string and then (b) have a single function `encodeNumber` that puts the string into `out_`.
##########
lang/c++/impl/json/JsonIO.hh:
##########
@@ -404,9 +404,25 @@ public:
template<typename T>
void encodeNumber(T t) {
+ sep();
+ const std::string s = std::to_string(t);
+ out_.writeBytes(reinterpret_cast<const uint8_t *>(s.data()), s.size());
+ sep2();
+ }
+
+ void encodeNumber(float t) {
Review Comment:
Since this is a specialization, it'll better to be explicit about it. Please add: `template <>` before this line.
--
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: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org