|
JH-Toolkit v1.4.1
An engineering-oriented C++20 toolkit with duck-typed concepts, static design, async coroutines, and semantic containers — header-only, RTTI-free, and concurrency-friendly.
|
A unified common view adaptor for both std::ranges::range and jh::concepts::sequence types.
More...
Go to the source code of this file.
Namespaces | |
| namespace | jh::ranges |
| Semantic pipeline namespace for JH range operations. | |
| namespace | jh::ranges::views |
| Range view adaptor implementations with explicit semantic control. | |
Variables | |
| constexpr detail::common_fn | jh::ranges::views::common {} |
User-facing common adaptor instance. | |
A unified common view adaptor for both std::ranges::range and jh::concepts::sequence types.
This header provides jh::ranges::views::common — a lightweight and compatible wrapper around the standard std::views::common adaptor (C++20). It extends the adaptor to support any type modeling jh::concepts::sequence, enabling third-party or user-defined sequence types to interoperate naturally with the standard range pipeline.
The adaptor normalizes iterator/sentinel categories without altering data ownership semantics. For standard ranges, it behaves identically to std::views::common. For types satisfying jh::concepts::sequence, it performs a promotion through jh::to_range() to obtain a valid range representation. Non-copyable or non-movable sequences are automatically proxied via std::ranges::subrange when required.
Behavior summary:
jh::concepts::sequence, it is promoted using jh::to_range() and wrapped by std::ranges::common_view. std::ranges::range, the adaptor forwards to std::views::common(). common_range types remain unchanged, except when proxied for non-copyable sources. Usage examples:
Notes:
common() to a temporary object results in a dangling view. Always ensure the source object outlives the resulting view. std::ranges::common_range, common() performs no semantic change; it may return a subrange proxy for non-copyable or non-movable sources. std::views::common(). 1.3.x
2025