Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5766

Replace std::endl with "\n"

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.19.0
    • 0.21.0
    • Compiler (General)
    • None

    Description

      Remove the usage of std::endl to force new lines for std::ostream

      Rationale

      • Using `std::endl` for linebreaks is bad practice since std::endl also forces a stream flush.
      • A past Ticket THRIFT-1815 identified the flush component as a problem and the behavior of std::endl was replaced with a custom constant that only did the new line to minimize code changes.
      • This enforces bad practice and changes expected behaviour
      • The C++ Core Guidelines SL.io.50 also suggest that std::endl should be avoided

      I propose (by PR) to remove the usage of endl and instead use \n directly to avoid building on the bad practice.

      See: https://github.com/apache/thrift/pull/2943

      • Replace the usage of endl with "\n" in all genertors
      • Replace the usage in most test files and examples
      • Keep the usage in std::cerr

      Attachments

        Issue Links

          Activity

            People

              cjcombrink Carel
              cjcombrink Carel
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 4h 20m
                  4h 20m