#include <type_traits>#include <iostream> template <typename T> void cannot_take_pointer(T ptr){ static_assert(!std::is_pointer<T>::value, "cannot_take_pointer requires non-pointer argument"); std::cout << "ok\n";} int main(){ int x; cannot_take_pointer(x); cannot_take_pointer(&x); // fails to compile}
Standard input is empty
prog.cpp: In function 'void cannot_take_pointer(T) [with T = int*]': prog.cpp:16:27: instantiated from here prog.cpp:7:5: error: static assertion failed: "cannot_take_pointer requires non-pointer argument"
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!