std::bit_floor
Min standard notice:
Header: <bit>
If x is not zero, calculates the largest integral power of two that is not greater than x. If x is zero, returns zero.
# Declarations
template< class T >
constexpr T bit_floor( T x ) noexcept;
(since C++20)
# Parameters
x: unsigned integer value
# Return value
Zero if x is zero; otherwise, the largest integral power of two that is not greater than x.
# Notes
Prior to P1956R1, the proposed name for this function template was floor2.
# Example
#include <bit>
#include <bitset>
#include <iostream>
int main()
{
using bin = std::bitset<8>;
for (unsigned x{}; x != 012; ++x)
std::cout << "bit_floor( " << bin(x) << " ) = "
<< bin(std::bit_floor(x)) << '\n';
}