xte::rotate_swap()

Defined in header <xte/func/rotate_swap.hpp>

Assigns each argument the value of the next argument. Uses the least number of temporary objects for swapping.


Definition

template<xte::uz distance = 1>
constexpr /* void */ rotate_swap(auto&... args) XTE_RETURNS(/* ... */);
distance is how far the next argument from which to get a value is.



Example

int a = 1;
int b = 2;
int c = 3;
int d = 4;
xte::rotate_swap(a, b, c, d);
std::println("a={}, b={}, c={}, d={}", a, b, c, d);
Output:
a=2, b=3, c=4, d=1
[View in Compiler Explorer]