Skip to content

Conversation

@ssam18
Copy link

@ssam18 ssam18 commented Nov 18, 2025

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
Copy link

cppalliance-bot commented Nov 18, 2025

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-20 18:08:39 UTC

@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.19%. Comparing base (67106eb) to head (7188b56).

Additional details and impacted files

Impacted file tree graph

@@             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 data
Powered by Codecov. Last update 67106eb...7188b56. Read the comment docs.

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

@ashtum
Copy link
Collaborator

ashtum commented Nov 18, 2025

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

@vinniefalco
Copy link
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
Copy link
Author

ssam18 commented Nov 18, 2025

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

Replaced all uses of string_view and basic_string_view with
core::string_view and core::basic_string_view respectively
throughout the codebase.

Closes boostorg#3046
@ssam18 ssam18 force-pushed the use-core-string-view branch from 8b0bb38 to 629d37d Compare November 18, 2025 15:44
@ssam18
Copy link
Author

ssam18 commented Nov 18, 2025

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

@ssam18
Copy link
Author

ssam18 commented Nov 18, 2025

Fixed all remaining comment alignment issues.

@ashtum
Copy link
Collaborator

ashtum commented Nov 18, 2025

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

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.
This fixes macOS compilation errors where the compiler couldn't
resolve the unqualified string_view type in iterator declarations.
…tring_view

The test/doc files are not inside the boost namespace, so they need
the fully qualified boost::core::string_view instead of core::string_view.
Changed back to boost::core::string_view in all affected test/doc files.
…ring_view

Example files are standalone programs not inside the boost namespace,
so they require the fully qualified boost::core::string_view.
Updated all example files except those in example/doc/ which are
already inside the boost namespace.
@ssam18
Copy link
Author

ssam18 commented Nov 18, 2025

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.

Remove boost:: prefix from core::string_view in implementation files
(.ipp) where code is already inside the boost namespace. This makes
the code cleaner and follows the project's namespace usage conventions.

Also reverted unintended change to release notes as requested by maintainer.

Signed-off-by: Samaresh Kumar Singh <[email protected]>
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