# Boolean literals

< cpp‎ | language

C++
 Language Headers Library concepts Language support library Diagnostics library Utilities library Strings library Containers library Algorithms library Iterators library Numerics library Input/output library Localizations library Regular expressions library (C++11) Atomic operations library (C++11) Thread support library (C++11) Filesystem library (C++17) Technical Specifications

Expressions
 General value categories (lvalue, rvalue, xvalue) order of evaluation (sequence points) constant expressions unevaluated expressions primary expressions lambda-expression(C++11) Literals integer literals floating-point literals boolean literals character literals including escape sequences string literals null pointer literal(C++11) user-defined literal(C++11) Operators Assignment operators: a=b, a+=b, a-=b, a*=b, a/=b, a%=b, a&=b, a|=b, a^=b, a<<=b, a>>=b Increment and decrement: ++a, --a, a++, a-- Arithmetic operators: +a, -a, a+b, a-b, a*b, a/b, a%b, ~a, a&b, a|b, a^b, a<>b Logical operators: a||b, a&&b, !a Comparison operators: a==b, a!=b, ab, a<=b, a>=b, a<=>b(C++20) Member access operators: a[b], *a, &a, a->b, a.b, a->*b, a.*b Other operators: a(...), a,b, a?b:c Default comparisons(C++20) Alternative representations of operators Precedence and associativity Fold expression(C++17) new-expression delete-expression throw-expression alignof sizeof sizeof...(C++11) typeid noexcept(C++11) Operator overloading Conversions Implicit conversions const_cast static_cast reinterpret_cast dynamic_cast Explicit conversions (T)a, T(a) User-defined conversion

## Contents

### Syntax

 true (1) false (2)

### Explanation

The Boolean literals are the keywords true and false. They are prvalues of type bool.

### Notes

See Integral conversions for implicit conversions from bool to other types and boolean conversions for the implicit conversions from other types to bool.

### Example

#include <iostream>

int main()
{
std::cout << std::boolalpha
<< true << '\n'
<< false << '\n'
<< std::noboolalpha
<< true << '\n'
<< false << '\n';
}

Output:

true
false
1
0