You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by "Sylwester Lachiewicz (Jira)" <ji...@apache.org> on 2026/09/23 13:29:00 UTC

[jira] [Created] (THRIFT-6364) Raise the minimum C++ language level to C++17

Sylwester Lachiewicz created THRIFT-6364:
--------------------------------------------

             Summary: Raise the minimum C++ language level to C++17
                 Key: THRIFT-6364
                 URL: https://issues.apache.org/jira/browse/THRIFT-6364
             Project: Thrift
          Issue Type: Improvement
          Components: C++ - Library, C++ - Compiler, Build Process
            Reporter: Sylwester Lachiewicz
             Fix For: 0.26.0


The C++ library and the code the C++ generator writes still target C++11 ([lib/cpp/README.md|https://github.com/apache/thrift/blob/master/lib/cpp/README.md], [LANGUAGES.md|https://github.com/apache/thrift/blob/master/LANGUAGES.md]). No toolchain the project builds with needs that any more: CI uses GCC 11 (Ubuntu 22.04), GCC 13 (Ubuntu 24.04), Visual Studio 2022 and current Apple Clang, all with complete C++17 support. So does the system compiler of the oldest common enterprise distribution, GCC 8 on RHEL 8.

h3. What C++17 makes possible

* Most of the remaining Boost usage in {{lib/cpp/src}} has a standard replacement:
** {{boost::tokenizer}} in [TMultiplexedProcessor.h|https://github.com/apache/thrift/blob/master/lib/cpp/src/thrift/processor/TMultiplexedProcessor.h] and {{boost::algorithm::string}} in {{THttpClient.cpp}}: {{std::string_view}}.
** {{boost::shared_array}} in {{TSSLSocket.cpp}}: {{std::shared_ptr<T[]>}}.
** {{boost::numeric_cast}} in {{THeaderTransport.cpp}} and {{BOOST_SCOPE_EXIT}} in {{OverlappedSubmissionThread.cpp}}: a checked cast and a scope guard of a few lines each.
** {{boost::uuid}} in {{TUuid.cpp}}: parsing and printing 16 bytes.
* That leaves {{boost::locale}} in {{TJSONProtocol.cpp}} as the one runtime use without a direct replacement, and moves the library towards what the README has promised since 0.13.0: Boost no longer being needed to build it. {{TMultiplexedProcessor.h}} is a public header, so today every user of the multiplexed processor needs the Boost headers.
* The generator could later offer {{std::optional}} for optional fields and {{std::string_view}} accessors, as opt-in options.

h3. Scope

This ticket only raises the minimum:
* {{CMAKE_CXX_STANDARD}} default in [build/cmake/DefineCMakeDefaults.cmake|https://github.com/apache/thrift/blob/master/build/cmake/DefineCMakeDefaults.cmake#L66] from 11 to 17.
* {{AX_CXX_COMPILE_STDCXX_11}} in [configure.ac|https://github.com/apache/thrift/blob/master/configure.ac#L111] to {{AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory])}}.
* The hard-coded {{-std=c++11}} in the PHP extension ({{lib/php/src/ext/thrift_protocol/config.m4}}) and the Python extension ({{lib/py/setup.py}}).
* {{lib/cpp/README.md}} and {{LANGUAGES.md}}.

Each Boost replacement above is a separate ticket. Master builds unchanged with {{CMAKE_CXX_STANDARD=17}} and passes the C++ test suite on GCC 11.4 (Ubuntu 22.04) and Apple Clang; the compiler itself ({{compiler/cpp}}) builds with the same setting.

h3. Compatibility

Generated C++ includes the library headers, so users must compile their own code as C++17 or later. That is a breaking change for anyone still on C++11 or C++14 and belongs in {{CHANGES.md}}. C++20 or later is not proposed: it would drop GCC 8 and 9 toolchains for little gain in this library, and C++23 is not complete in GCC 11, the compiler of the project's own Ubuntu 22.04 image ([GCC C++ status|https://gcc.gnu.org/projects/cxx-status.html#cxx23]).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)