[
https://issues.apache.org/jira/browse/THRIFT-3336?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14908321#comment-14908321
]
ASF GitHub Bot commented on THRIFT-3336:
----------------------------------------
Github user hcorg commented on a diff in the pull request:
https://github.com/apache/thrift/pull/626#discussion_r40451162
--- Diff: compiler/cpp/src/generate/t_cpp_generator.cc ---
@@ -1506,24 +1523,16 @@ void generate_fields(std::ofstream& out,
/**
* Generates operator<<
*/
-void t_cpp_generator::generate_struct_ostream_operator(std::ofstream& out,
t_struct* tstruct) {
+void t_cpp_generator::generate_struct_print_operator(std::ofstream& out,
t_struct* tstruct) {
out << indent();
- generate_struct_ostream_operator_decl(out, tstruct);
+ generate_struct_print_operator_decl(out, tstruct);
out << " {" << endl;
indent_up();
out << indent() << "using apache::thrift::to_string;" << endl;
-
- // eliminate compiler unused warning
- const vector<t_field*>& fields = tstruct->get_members();
- if (fields.empty())
- out << indent() << "(void) obj;" << endl;
--- End diff --
why this line is removed? I'm pretty sure struct/exception without fields
will generate warning "unused function parameter" for operator<</print method
> Thrift generated streaming operators added in 0.9.2 cannot be overridden
> ------------------------------------------------------------------------
>
> Key: THRIFT-3336
> URL: https://issues.apache.org/jira/browse/THRIFT-3336
> Project: Thrift
> Issue Type: Bug
> Components: C++ - Compiler
> Affects Versions: 0.9.2, 0.9.3
> Reporter: James E. King, III
> Assignee: James E. King, III
>
> I work on one project that has been using thrift-0.8.0 and I am updating it
> to 0.9.3. The project defines streaming operators for "operator <<" on a
> variety of thrift-generated types.
> The fix added in THRIFT-2067 provides similar but not identical functionality
> however it was done in a way that cannot be overridden, and this causes
> projects upgrading from versions prior to 0.9.2 with their own streaming
> operators to fail to compile.
> One way to make the streaming operator virtual is to follow the example
> provided in
> http://stackoverflow.com/questions/5189614/operator-and-inheritance
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)