#include <iostream>#include <type_traits> const int* func() { return nullptr; } int main() { const auto p = func(); static_assert(std::is_same<decltype(p), const int* const>::value, "unexpected type"); p = nullptr; // error: assignment of read-only variable āpā}
Standard input is empty
prog.cpp: In function ‘int main()’: prog.cpp:9:7: error: assignment of read-only variable ‘p’ p = nullptr; // error: assignment of read-only variable ‘p’ ^~~~~~~
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!