std::indirectly_swappable(3cxx)

πŸ“¦
version 16-20260322 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

✨ NAME ✨

std::indirectly_swappable β€” it's the [alg.req.ind.swap] concept, bestie, and yes its whole government name is indirectly_swappable πŸ’…

This page lives in the 3cxx manual (that's the libstdc++ one, iykyk).


🌸 SYNOPSIS 🌸

#include <iterator>

πŸ¦‹ Concept definition πŸ¦‹

template<typename _I1, typename _I2 _I1>
concept std::indirectly_swappable =  indirectly_readable<_I1> && indirectly_readable<_I2>
      && requires(const _I1 __i1, const _I2 __i2)
      {
        ranges::iter_swap(__i1, __i1);
        ranges::iter_swap(__i2, __i2);
        ranges::iter_swap(__i1, __i2);
        ranges::iter_swap(__i2, __i1);
      }
okay so real talk: that template line above is exactly what the source says, typo and all. I am not touching it. Not my business. Copy it verbatim or perish πŸ’€

πŸ’– DESCRIPTION πŸ’–

[alg.req.ind.swap], concept indirectly_swappable. That's the whole vibe β€” it's a concept, it's about swapping things indirectly, and it's living in the <iterator> header like the icon it is. πŸ‘‘

🌈 Detailed Description 🌈

[alg.req.ind.swap], concept indirectly_swappable.

Basically: this concept checks that both _I1 and _I2 are indirectly_readable, and then it demands proof β€” a requires expression with const _I1 __i1 and const _I2 __i2 β€” that all four of these actually compile:

  • ranges::iter_swap(__i1, __i1);
  • ranges::iter_swap(__i2, __i2);
  • ranges::iter_swap(__i1, __i2);
  • ranges::iter_swap(__i2, __i1);

All four, no skipping. If any one of them doesn't compile, the concept just says no and moves on. Periodt. ✨


🫢 AUTHOR 🫢

Generated automatically by Doxygen for libstdc++ from the source code. No human wrote this, it just appeared, main character energy fr fr 😭


k bye bestie, this page was served to you fresh from libstdc++ β€” go swap some iterators, you got this πŸ¦‹πŸ’–

πŸ“¦ where this page comes from