cpp / latest / keyword / compl.html /

C++ keywords: compl

Usage

Example

#include <iostream>
#include <bitset>
 
using bin = std::bitset<8>;
 
void show(bin z, const char* s, int n)
{
    if (n == 0) std::cout << "┌─────────┬──────────┐\n";
    if (n <= 2) std::cout << "│ "<<s<<" │ " <<z<<" │\n";
    if (n == 2) std::cout << "└─────────┴──────────┘\n";
}
 
int main()
{
    bin x{ "01011010" }; show(x, "x      ", 0);
    bin z = compl x;     show(z, "compl x", 2);
}

Output:

┌─────────┬──────────┐
│ x       │ 01011010 │
│ compl x │ 10100101 │
└─────────┴──────────┘

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/keyword/compl