-
Notifications
You must be signed in to change notification settings - Fork 74
Bump the C++ standard to 17 #525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Replace `boost::optional` with `std::optional` - Replace `boost::any` with `std::any` - Use `std::weak_from_this` to create a `weak_ptr` from a `shared_ptr` - Leverage initializers for if to simplify code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR upgrades the C++ standard requirement from C++11 to C++17 for the Pulsar C++ client library, bumping the version to 4.0.0-pre. The upgrade modernizes the codebase by replacing Boost types with their standard library equivalents and leveraging C++17 language features for cleaner, more maintainable code.
Key Changes:
- Replaced
boost::optionalwithstd::optionalandboost::anywithstd::anythroughout the codebase - Adopted
std::weak_from_this()for creating weak pointers fromshared_from_this() - Introduced if-initializers to reduce variable scope and improve code clarity in async callback patterns
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| version.txt | Bumped version from 3.8.0-pre to 4.0.0-pre |
| CMakeLists.txt | Set CMAKE_CXX_STANDARD to 17 (moved from INTEGRATE_VCPKG block to global scope) |
| README.md | Added documentation noting C++17 requirement starting from version 4.0.0 |
| pkg/mac/build-static-library.sh | Updated compiler flags from -std=c++11 to -std=c++17 |
| pkg/apk/build-apk.sh | Updated compiler flags from -std=c++11 to -std=c++17 |
| lib/SynchronizedHashMap.h | Replaced boost::optional with std::optional, updated comments and return patterns |
| lib/ProducerConfigurationImpl.h | Replaced boost::optional with std::optional for member variables |
| lib/ProducerConfiguration.cc | Replaced boost::make_optional with std::make_optional |
| lib/ProducerImpl.h | Replaced boost::optional with optional for method parameters and member variables |
| lib/ProducerImpl.cc | Updated to use std::optional, replaced nullptr with {} for optional initialization |
| lib/HandlerBase.h | Replaced boost::optional with optional in method signatures |
| lib/HandlerBase.cc | Adopted weak_from_this() and if-initializers, replaced nullptr with {} for optional |
| lib/ConsumerImpl.h | Replaced boost::optional with optional in method signatures and member variables |
| lib/ConsumerImpl.cc | Comprehensive migration to std::optional, adopted weak_from_this() and if-initializers |
| lib/ConsumerImplBase.cc | Adopted weak_from_this() and if-initializers with static_pointer_cast for proper typing |
| lib/MultiTopicsConsumerImpl.h | Updated constructor parameters to use optional with default values |
| lib/MultiTopicsConsumerImpl.cc | Adopted weak_from_this(), changed optional access from get() to value() |
| lib/Commands.h | Replaced boost::optional with optional in function signatures |
| lib/Commands.cc | Updated function parameters to use optional, added boost/throw_exception.hpp include |
| lib/ClientConnection.h | Replaced boost::any with std::any, removed C++14 weak_from_this workaround, replaced boost::optional with optional |
| lib/ClientConnection.cc | Replaced boost::any_cast with std::any_cast, updated optional value construction |
| lib/ProducerStatsImpl.cc | Adopted weak_from_this() for cleaner code |
| lib/ConsumerStatsImpl.cc | Adopted weak_from_this() for cleaner code |
| lib/UnAckedMessageTrackerEnabled.cc | Adopted weak_from_this() and if-initializers |
| lib/TableViewImpl.cc | Updated containsKey to use static_cast for optional checking, adopted weak_from_this() |
| lib/PeriodicTask.cc | Adopted weak_from_this() and if-initializers |
| lib/NegativeAcksTracker.cc | Adopted weak_from_this() for cleaner code |
| lib/RetryableOperationCache.h | Adopted weak_from_this() for cleaner code |
| lib/AckGroupingTrackerEnabled.cc | Adopted weak_from_this() and if-initializers |
| tests/SynchronizedHashMapTest.cc | Updated tests to use std::optional syntax, removed boost include |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
boost::optionalwithstd::optionalboost::anywithstd::anystd::weak_from_thisto create aweak_ptrfrom ashared_ptrSet the next major version to 4.0.0 for this change. If there are still demands from community for C++11 based build, we can consider 3.x.y releases.