30 Nisan 2021 Cuma

std::in_place

Örnek
Şöyle yaparız
struct Things
{
    Things(const char* msg1, const char* msg2) : one(msg1), two(msg2) {}
    Unmovable one;
    Unmovable two;
};

int main()
{
    std::optional<Things>{std::in_place, "jadda", "neida"};
}

28 Nisan 2021 Çarşamba

std::endian

Örnek
Şöyle yaparız
void convertBigToLittleEndianIfNecessary(uint32_t& code) {
  if constexpr (std::endian::native == std::endian::little) {
  code = ((code & 0xFF000000) >> 24) |
         ((code & 0x00FF0000) >> 8)  |
         ((code & 0x0000FF00) >> 8)  |
         ((code & 0x000000FF) >> 24);
    }
}

21 Nisan 2021 Çarşamba

std::bit_width

Giriş
Açıklaması şöyle
std::bit_width finds minimum bits required to represent an integral number x as 1+floor(log(x))