std::ranges...d_subrange_t(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

🌸 NAME 🌸

okay so bestie, this is the std::ranges...d_subrange_t(3) page from the C++ Standard Libary, and it’s literally about std::ranges::borrowed_iterator_t and std::ranges::borrowed_subrange_t πŸ¦‹. The NAME line goes: std::ranges::borrowed_iterator_t,std::ranges::borrowed_subrange_t - std::ranges::borrowed_iterator_t,std::ranges::borrowed_subrange_t β€” yes, it said it twice, main character energy ✨.

πŸ¦‹ Synopsis πŸ¦‹

Defined in header <ranges>

          template< ranges::range R >                  (1) (since C++20)
          using borrowed_iterator_t = /* see below */;
          template< ranges::range R >                  (2) (since C++20)
          using borrowed_subrange_t = /* see below */;
  • (1) β€” std::ranges::iterator_t<R> if R models borrowed_range, std::ranges::dangling otherwise.
  • (2) β€” std::ranges::subrange<std::ranges::iterator_t<R>> if R models borrowed_range, std::ranges::dangling otherwise.

These two alias templates are used by some constrained algorithms to avoid returning potentially dangling iterators or views. no cap, they’re literally the β€œdon’t hand out a dangling vibe” safety squad πŸ’….

πŸ’… Possible implementation πŸ’…

First version

          template< std::ranges::range R >
          using borrowed_iterator_t =
       std::conditional_t<std::ranges::borrowed_range<R>,
              std::ranges::iterator_t<R>, std::ranges::dangling>;

Second version

          template< std::ranges::range R >
          using borrowed_subrange_t =
       std::conditional_t<std::ranges::borrowed_range<R>,
              std::ranges::subrange<std::ranges::iterator_t<R>>,
       std::ranges::dangling>;

πŸ”₯ See also πŸ”₯

  • ranges::dangling (C++20) β€” a placeholder type indicating that an iterator or a subrange should not be returned since it would be dangling (class).

mwah πŸ’‹ that’s the whole page, bestie β€” source is http://cppreference.com, and the version/date is 2024.06.10. stay iconic and please do not return dangling iterators, periodt βœ¨πŸ‘‘

πŸ“¦ where this page comes from