Use core::string_view directly instead of alias
This PR addresses issue #3046 by replacing all uses of the string_view alias with core::string_view throughout the codebase for improved clarity in both documentation and source code.
Changes
- Replaced
string_viewwithcore::string_viewin all header files (.hpp) - Replaced
string_viewwithcore::string_viewin all inline implementation files (.ipp) - Updated documentation files (.qbk) to use
core::string_view - Replaced
basic_string_viewwithcore::basic_string_viewwhere applicable - Retained type aliases in
string_type.hppfor backward compatibility
Benefits
- Makes it explicit that Beast uses
boost::core::string_view - Improves code clarity and documentation
- Easier for users to understand the library's dependencies
Files Modified
- 48 header and implementation files
- 4 documentation files
- Total: 52 files with 410 insertions and 347 deletions
Closes #3046
An automated preview of the documentation is available at https://3058.beast.prtest.cppalliance.org/libs/beast/doc/html/index.html
If more commits are pushed to the pull request, the docs will rebuild at the same URL.
2025-11-30 16:23:30 UTC
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 93.19%. Comparing base (67106eb) to head (7188b56).
Additional details and impacted files
@@ Coverage Diff @@
## develop #3058 +/- ##
===========================================
- Coverage 93.22% 93.19% -0.03%
===========================================
Files 176 176
Lines 13703 13703
===========================================
- Hits 12774 12770 -4
- Misses 929 933 +4
| Files with missing lines | Coverage Δ | |
|---|---|---|
| example/doc/http_examples.hpp | 80.36% <100.00%> (ø) |
|
| ...ude/boost/beast/_experimental/test/impl/stream.ipp | 98.36% <ø> (ø) |
|
| include/boost/beast/_experimental/test/stream.hpp | 75.00% <ø> (ø) |
|
| .../boost/beast/core/detail/impl/temporary_buffer.ipp | 100.00% <ø> (ø) |
|
| include/boost/beast/core/detail/string.hpp | 100.00% <100.00%> (ø) |
|
| ...clude/boost/beast/core/detail/temporary_buffer.hpp | 100.00% <ø> (ø) |
|
| include/boost/beast/core/impl/string.ipp | 100.00% <ø> (ø) |
|
| include/boost/beast/core/string_type.hpp | 100.00% <100.00%> (ø) |
|
| include/boost/beast/http/basic_parser.hpp | 94.11% <ø> (ø) |
|
| include/boost/beast/http/chunk_encode.hpp | 100.00% <ø> (ø) |
|
| ... and 30 more |
... and 1 file with indirect coverage changes
Continue to review full report in Codecov by Sentry.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 67106eb...7188b56. Read the comment docs.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Thank you. Could you please check the example and test directories as well?
This is great!
Thank you @ashtum for the review! I've updated the PR to:
- Process example and test directories - added 58 more files with string_view replacements
- Remove replace_string_view.py from the committed files
Thank you for the detailed review! I've addressed all the feedback:
- Removed the type aliases from string_type.hpp as they're no longer needed since all code now uses core::string_view directly
- Removed the .gitignore entry for replace_string_view.py
Fixed all remaining comment alignment issues.
@ssam18 You can use the GitHub Action CI in your own fork to address the compile errors, since it won’t require approval to run each time.
Why the core::string_view → boost::core::string_view change is necessary?
The issue:
C++ namespace lookup rules mean that when you write core::string_view in a file, the compiler searches for core starting from the current namespace and working outward. This works fine in files already inside namespace boost { ... } because the compiler finds boost::core. But in standalone example and test files that aren't wrapped in the boost namespace, the compiler can't find core at all.
FIX:
Files need to use the fully qualified name boost::core::string_view unless they're already inside the boost namespace. This is why:
Example files (like example/http/server/async/http_server_async.cpp) → Need boost::core::string_view (standalone programs) Test/doc files outside boost namespace → Need boost::core::string_view Header files inside namespace boost (like example/doc/http_examples.hpp) → Can use core::string_view (already in boost namespace) This is standard C++ namespace behavior—you need the full qualification when you're not already in the parent namespace. The changes ensure MSVC (and all other compilers) can properly resolve the type regardless of where it's used.
@ashtum Please let me know if this PR looks good?
@ashtum Please let me know if this PR looks good?
All files under test/doc and example should use core::string_view rather than boost::string_view.
If needed, add namespace core = boost::core; in the correct location, following the style of nearby using declarations.
For example:
namespace beast = boost::beast; // from <boost/beast.hpp>
namespace http = beast::http; // from <boost/beast/http.hpp>
namespace websocket = beast::websocket; // from <boost/beast/websocket.hpp>
namespace net = boost::asio; // from <boost/asio.hpp>
namespace ssl = boost::asio::ssl; // from <boost/asio/ssl.hpp>
namespace core = boost::core; // from <boost/core/detail/string_view.hpp>
using tcp = boost::asio::ip::tcp; // from <boost/asio/ip/tcp.hpp>
Please review each changed line manually and use your judgment to fix any formatting, clarity, or semantic issues. Please run the CI on your branch and address the build failures (you need to activate GHA action for your fork).