C++ Logo


Advanced search

Re: Rotate Bits Left or Right

From: Magnus Fromreide <magfr_at_[hidden]>
Date: Sun, 26 Jan 2020 10:11:36 +0100
On Sun, Jan 26, 2020 at 09:03:29AM +0100, Kjetil Kristoffer Solberg via Std-Proposals wrote:
> Hi!
> Shouldn't there be a rotate bits left and rotate bits right operator? The
> way I have seen rotate done
> is pretty ugly. There are instructions in x86 and other instructions sets
> for rotation. Why not have it in the C++ standard?
> NB! I have not checked if this question have been asked a million times
> before.

The question have been asked many times and in fact C++20 adds the functions
std::rotl and std::rotr among others to the <bit> header.


Received on 2020-01-26 03:14:15