std::sortable(3)

πŸ“¦
version 2024.07.05 Β· 3 versions
, in nixpkgs unstable, opensuse-leap 16.0

πŸŽ€ NAME πŸŽ€

okay so welcome to the std::sortable(3) page from the C++ Standard Libary πŸ’… bestie, this is the manual for std::sortable β€” yes, the NAME line is literally std::sortable - std::sortable, it's giving self-titled debut album and honestly? iconic ✨

🌸 Synopsis 🌸

std::sortable lives in the header <iterator>, and here's the exact signature vibe:

          Defined in header <iterator>
          template< class I, class Comp = ranges::less, class Proj =
          std::identity >

          concept sortable =
       (since C++20)
              std::permutable<I> &&

              std::indirect_strict_weak_order<Comp, std::projected<I, Proj>>;

So yeah: it's a concept (since C++20) and it's built from std::permutable<I> and std::indirect_strict_weak_order<Comp, std::projected<I, Proj>> β€” no cap, that's the whole formula 🧚

The sortable concept is basically the requirements checklist for algorithms that permute a range into an ordered range according to Comp. It's the vibe check for sort-ish algorithms πŸ‘‘

🧠 Semantic requirements 🧠

std::sortable<I, Comp, Proj> is modeled only if all concepts it subsumes are modeled. That's it, that's the rule β€” if the concepts it subsumes aren't modeled, it's not modeled either, periodt πŸ’€

πŸ‘€ See also πŸ‘€

  • ranges::sort β€” sorts a range into ascending order (C++20) (niebloid) πŸ”₯
  • ranges::stable_sort β€” sorts a range of elements while preserving order between equal elements (C++20) (niebloid) 🫢
  • ranges::partial_sort β€” sorts the first N elements of a range (C++20) (niebloid) ✨
  • ranges::nth_element β€” partially sorts the given range making sure that it is partitioned by the given element (C++20) (niebloid) πŸ¦‹
  • ranges::inplace_merge β€” merges two ordered ranges in-place (C++20) (niebloid) 🌈
  • ranges::push_heap β€” adds an element to a max heap (C++20) (niebloid) πŸ’–
  • ranges::pop_heap β€” removes the largest element from a max heap (C++20) (niebloid) πŸ’…
  • ranges::make_heap β€” creates a max heap out of a range of elements (C++20) (niebloid) πŸŽ€
  • ranges::sort_heap β€” turns a max heap into a range of elements sorted in ascending order (C++20) (niebloid) ⭐
  • ranges::next_permutation β€” generates the next greater lexicographic permutation of a range of elements (C++20) (niebloid) πŸ“
  • ranges::prev_permutation β€” generates the next smaller lexicographic permutation of a range of elements (C++20) (niebloid) 🧚

Signed, sealed, delivered: source/version http://cppreference.com, date 2024.06.10, page std::sortable(3) β€” bye bestie, go sort something cute πŸ’œπŸ«Ά

πŸ“¦ where this page comes from