Sylwester Lachiewicz created THRIFT-6394:
--------------------------------------------
Summary: C++: build the library without Boost
Key: THRIFT-6394
URL: https://issues.apache.org/jira/browse/THRIFT-6394
Project: Thrift
Issue Type: Improvement
Components: C++ - Library, Build Process
Reporter: Sylwester Lachiewicz
h2. Why
Since 0.13.0 ([THRIFT-4441|https://issues.apache.org/jira/browse/THRIFT-4441],
[THRIFT-4720|https://issues.apache.org/jira/browse/THRIFT-4720]) the runtime
library has been described as not needing Boost, but {{lib/cpp/src}} still
includes Boost headers in eight files, and
[lib/cpp/CMakeLists.txt|https://github.com/apache/thrift/blob/master/lib/cpp/CMakeLists.txt]
still calls {{REQUIRE_BOOST_HEADERS()}} under the comment "Remove the
following once lib/cpp no longer depends on boost headers". Two of the eight
are public headers: {{TMultiplexedProcessor.h}} includes
{{boost/tokenizer.hpp}}, so every user of the multiplexed processor needs the
Boost headers, and {{TProtocol.h}} falls back to {{boost/predef}} for the byte
order where {{<sys/param.h>}} does not define it, which is the case for MSVC.
h2. Uses and their replacements
All replacements are C++11, so this does not depend on
[THRIFT-6364|https://issues.apache.org/jira/browse/THRIFT-6364].
||File||Boost||Replacement||
|{{processor/TMultiplexedProcessor.h}}|{{boost::tokenizer}}|split on {{':'}}
with {{std::string::find}}, skipping empty pieces as {{char_separator}} did|
|{{transport/THttpClient.cpp}}|{{boost::iequals}}, {{iends_with}}, {{split}},
{{trim_copy}}|local helpers|
|{{transport/TSSLSocket.cpp}}|{{boost::shared_array}}|{{std::unique_ptr<Mutex[]>}}|
|{{transport/THeaderTransport.cpp}}|{{boost::numeric_cast}}|local checked cast|
|{{windows/OverlappedSubmissionThread.cpp}}|{{BOOST_SCOPE_EXIT}}|local guard
object|
|{{TUuid.cpp}}|{{boost::uuids::string_generator}}, {{to_string}}|parse and
print the 16 bytes|
|{{protocol/TJSONProtocol.cpp}}|{{boost::locale::conv::utf_to_utf}}|UTF-16 to
UTF-8 conversion|
|{{protocol/TProtocol.h}}|{{boost/predef/other/endian.h}}|the compiler's
{{__BYTE_ORDER__}} macros; little-endian on {{_WIN32}}|
Each replacement keeps the behaviour of the call it replaces, edge cases
included: empty tokens, dash and brace placement in UUID strings, unpaired
UTF-16 surrogates.
[THRIFT-5660|https://issues.apache.org/jira/browse/THRIFT-5660] replaced
{{numeric_cast}} once before and was reverted because its cast rejected {{0UL}}
to {{int32_t}}, so the new cast needs to be checked against Boost across the
conversions {{THeaderTransport}} makes.
The optional {{TUuid(const boost::uuids::uuid&)}} constructor behind
{{THRIFT_TUUID_SUPPORT_BOOST_UUID}} stays; it is opt-in for projects that
already use Boost.
h2. Out of scope
* The unit tests, which use Boost.Test, filesystem, thread and chrono, and
{{test/cpp}}.
* The autotools build, which still requires Boost for the whole C++ library
because it builds the library and its tests in one step ({{AX_BOOST_BASE}} in
{{configure.ac}}).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)