For instance: #include <ranges> constexpr std::string_view first_n_words(std::string_view str, size_t n) { namespace rv = std::views; auto first_n = str | rv::split(' ') | rv::take(n) | rv::join; return std::string_view(&*first_n.begin(), std::ranges::distance(first_n)); } constexpr std::string_view first4 = first_n_words("Hello to all you beautiful libstdc++ developers", 4); This doesn't compile because _M_emplace_deref isn't marked constexpr (probably becase P2231 isn't implemented yet, but thought I'd file a bug report anyway).
This is obviously a dup of PR101263 ;-)
dup *** This bug has been marked as a duplicate of bug 101263 ***