Request Short Link
C++ 98
C++ 11
C++ 14
C++ 17
C++ 20
C++ 23
C++ 2c
for-loops as while-loops
array subscription
Show all implicit casts
Show all template parameters of a CallExpr
Use libc++
Transform std::initializer_list
Show noexcept internals
Show padding information
Show coroutine transformation
Show C++ to C transformation
Show object lifetime
Default
15
18
20
22
26
More
GitHub
Patreon
Issues
About
Policies
Examples
C++ Insights @ YouTube
Settings
Version
None
×
Made by
Andreas Fertig
Powered by
Flask
and
CodeMirror
Source:
#include <type_traits> void f() { int x1 = 1; short x2 = 1; x1 + x2; // Integer promotions applied and x2 will be promoted to int static_assert(std::is_same_v<decltype(x1+x2),int>); unsigned int x3 = 1; unsigned short x4 = 1; x3 + x4; // Integer promotions applied and x4 will be promoted to int // x4 will then be converted to unsigned int due to rule two // bullets further down static_assert(std::is_same_v<decltype(x3+x4),unsigned int>); unsigned short x5=0xFFFF; unsigned short x6=0xFFFF; auto z=x5*x6; // Integer promotions applied and x5 and x6 will be promoted to int // Result will be larger than std::numeric_limits<int>::max() and // thus will have signed integer overflow which is undefined behavior static_assert(std::is_same_v<decltype(x5*x6),int>); }
Insight:
Console: