fork(1) download
  1. #include <iostream>
  2.  
  3.  
  4. class test {
  5. public:
  6.  
  7. template<typename T>
  8. friend test& operator&(test& so, T const& t);
  9. };
  10.  
  11. template<typename T>
  12. inline test& operator&(test& so, T const& t) {
  13. std::cout << "is_pointer : " << std::is_pointer<T>::value << std::endl;
  14. static_assert(std::is_pointer<T>::value, "no operator overloaded for pointers.");
  15.  
  16. // some stuff
  17. return so;
  18. }
  19.  
  20. int main() {
  21. test t;
  22. t & 123;
  23. return 0;
  24. }
Compilation error #stdin compilation error #stdout 0s 3296KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of ‘test& operator&(test&, const T&) [with T = int]’:
prog.cpp:22:11:   required from here
prog.cpp:14:9: error: static assertion failed: no operator overloaded for pointers.
         static_assert(std::is_pointer<T>::value, "no operator overloaded for pointers.");
         ^
stdout
Standard output is empty