Skip to content

Use core::string_view directly instead of alias - #3058

Open
ssam18 wants to merge 1 commit into
boostorg:developfrom
ssam18:use-core-string-view
Open

ssam18 wants to merge 1 commit into
boostorg:developfrom
ssam18:use-core-string-view

Conversation

@ssam18

@ssam18 ssam18 commented Nov 18, 2025

Copy link
Copy Markdown

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_view with core::string_view in all header files (.hpp)
  • Replaced string_view with core::string_view in all inline implementation files (.ipp)
  • Updated documentation files (.qbk) to use core::string_view
  • Replaced basic_string_view with core::basic_string_view where applicable
  • Retained type aliases in string_type.hpp for 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

@cppalliance-bot

cppalliance-bot commented Nov 18, 2025

Copy link
Copy Markdown

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.

2026-09-09 09:45:10 UTC

@codecov

codecov Bot commented Nov 18, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.27%. Comparing base (66e232d) to head (3a47493).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3058      +/-   ##
===========================================
- Coverage    93.30%   93.27%   -0.03%     
===========================================
  Files          177      177              
  Lines        13764    13764              
===========================================
- Hits         12843    12839       -4     
- Misses         921      925       +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 Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 66e232d...3a47493. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ashtum

ashtum commented Nov 18, 2025

Copy link
Copy Markdown
Collaborator

Thank you. Could you please check the example and test directories as well?

Comment thread replace_string_view.py Outdated
@vinniefalco

Copy link
Copy Markdown
Member

This is great!

@ssam18
ssam18 force-pushed the use-core-string-view branch from 24c3156 to 8b0bb38 Compare November 18, 2025 14:21
@ssam18

ssam18 commented Nov 18, 2025

Copy link
Copy Markdown
Author

Thank you @ashtum for the review! I've updated the PR to:

  1. Process example and test directories - added 58 more files with string_view replacements
  2. Remove replace_string_view.py from the committed files

Comment thread include/boost/beast/core/string_type.hpp Outdated
Comment thread .gitignore Outdated
Comment thread doc/qbk/04_http/08_chunked_encoding.qbk Outdated
Comment thread doc/qbk/08_design/1_http_message.qbk
@ssam18
ssam18 force-pushed the use-core-string-view branch from 8b0bb38 to 629d37d Compare November 18, 2025 15:44
@ssam18

ssam18 commented Nov 18, 2025

Copy link
Copy Markdown
Author

Thank you for the detailed review! I've addressed all the feedback:

  1. Removed the type aliases from string_type.hpp as they're no longer needed since all code now uses core::string_view directly
  2. Removed the .gitignore entry for replace_string_view.py

Comment thread include/boost/beast/http/parser.hpp Outdated
@ssam18

ssam18 commented Nov 18, 2025

Copy link
Copy Markdown
Author

Fixed all remaining comment alignment issues.

@ashtum

ashtum commented Nov 18, 2025

Copy link
Copy Markdown
Collaborator

@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.

ssam18 added a commit to ssam18/beast that referenced this pull request Nov 18, 2025
Use fully qualified boost::core::string_view instead of core::string_view
or beast::string_view to ensure correct namespace resolution in nested
boost::beast namespace contexts. This fixes compilation errors across all
platforms where the compiler was looking for non-existent types like
boost::beast::core::string_view.

Fixes CI compilation failures in PR boostorg#3058.
Comment thread example/doc/http_examples.hpp Outdated
Comment thread test/doc/http_10_custom_parser.cpp Outdated
Comment thread test/beast/websocket/read3.cpp Outdated
@ssam18

ssam18 commented Nov 18, 2025

Copy link
Copy Markdown
Author

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.

Comment thread include/boost/beast/http/impl/verb.ipp Outdated
Comment thread doc/qbk/release_notes.qbk Outdated
Comment thread test/doc/core_1_refresher.cpp Outdated
@ssam18

ssam18 commented Nov 30, 2025

Copy link
Copy Markdown
Author

@ashtum Please let me know if this PR looks good?

@ashtum

ashtum commented Nov 30, 2025

Copy link
Copy Markdown
Collaborator

@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).

Comment thread example/advanced/server-flex/advanced_server_flex.cpp Outdated
Comment thread example/http/server/async-local/http_server_async_local.cpp Outdated
Comment thread test/doc/exemplars.cpp Outdated
Comment thread test/doc/http_10_custom_parser.cpp Outdated
ssam18 added a commit to ssam18/beast that referenced this pull request Apr 2, 2026
Use fully qualified boost::core::string_view instead of core::string_view
or beast::string_view to ensure correct namespace resolution in nested
boost::beast namespace contexts. This fixes compilation errors across all
platforms where the compiler was looking for non-existent types like
boost::beast::core::string_view.

Fixes CI compilation failures in PR boostorg#3058.
@ssam18
ssam18 force-pushed the use-core-string-view branch from 987e58b to a0031df Compare April 2, 2026 13:27
ssam18 added a commit to ssam18/beast that referenced this pull request Apr 2, 2026
Use fully qualified boost::core::string_view instead of core::string_view
or beast::string_view to ensure correct namespace resolution in nested
boost::beast namespace contexts. This fixes compilation errors across all
platforms where the compiler was looking for non-existent types like
boost::beast::core::string_view.

Fixes CI compilation failures in PR boostorg#3058.
@ssam18
ssam18 force-pushed the use-core-string-view branch from a0031df to 48130a7 Compare April 2, 2026 13:29
@ssam18

ssam18 commented Apr 2, 2026

Copy link
Copy Markdown
Author

@vinniefalco vinniefalco after a long chase, I was able to fix all the failing tests after addressing the review comments. Please take a look at this PR.

@ssam18

ssam18 commented Apr 10, 2026

Copy link
Copy Markdown
Author

@ashtum please review this PR. This has been pending over months.

@ashtum

ashtum commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

@ssam18 Thanks for the effort here. After four rounds of reviews, there are still open issues (comment alignment in the doc snippets, redundant core namespace aliases inside boost::beast, and dangling string_view links in the docs), and a couple of earlier fixes have regressed. The review is now costing more than the change itself. I'll squash your commits and apply the required changes in a single commit.

@ashtum
ashtum force-pushed the use-core-string-view branch 2 times, most recently from e24d98a to 91ce221 Compare September 9, 2026 08:16
The library now spells the type as core::string_view directly, rather
than going through the beast::string_view alias. Standalone translation
units that need one get a namespace core = boost::core alias.

The beast::string_view and beast::basic_string_view aliases are retained
as deprecated for compatibility with existing code.

Co-authored-by: Samaresh Kumar Singh <ssam3003@gmail.com>
@ashtum
ashtum force-pushed the use-core-string-view branch from 91ce221 to 3a47493 Compare September 9, 2026 09:33
@ashtum ashtum mentioned this pull request Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core::string_view

4 participants