#include <stdint.h> #include <type_traits> uint64_t foo(uint16_t a) { auto x = (a & 0xFFFF); static_assert(std::is_same<int32_t, decltype(x)>::value, "not an int32_t") static_assert(std::is_same<uint16_t, decltype(x)>::value, "not a uint16_t"); return x; }
Standard input is empty
prog.cpp: In function 'uint64_t foo(uint16_t)': prog.cpp:7:4: error: expected ';' before 'static_assert' static_assert(std::is_same<uint16_t, decltype(x)>::value, "not a uint16_t"); ^ prog.cpp:7:4: error: static assertion failed: not a uint16_t
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!