Github user viveksjain commented on a diff in the pull request:
https://github.com/apache/thrift/pull/1083#discussion_r77875285
--- Diff: compiler/cpp/src/generate/t_cpp_generator.cc ---
@@ -541,6 +542,35 @@ void t_cpp_generator::generate_enum(t_enum* tenum) {
<< tenum->get_name() << "Values"
<< ", _k" << tenum->get_name() << "Names), "
<< "::apache::thrift::TEnumIterator(-1, NULL, NULL));" <<
endl << endl;
+
+ generate_enum_ostream_operator(tenum);
+}
+
+void t_cpp_generator::generate_enum_ostream_operator(t_enum* tenum) {
+ f_types_ << "inline std::ostream& operator<<(std::ostream& out, const ";
+ if (gen_pure_enums_) {
+ f_types_ << tenum->get_name();
+ } else {
+ f_types_ << tenum->get_name() << "::type";
--- End diff --
I haven't read anything particular about `operator<<`, but in general I
think for classes you want a reference, and for numeric types (enums included)
you want the value â pass by reference is probably actually slower.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---