fork(5) download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. void foo(void* p) { std::cout << "foo() called. it better not try to modify *p!\n"; }
  5.  
  6. template<typename T>
  7. void Remove (T *p)
  8. {
  9. foo( const_cast< typename std::remove_const<T>::type *> (p) );
  10. }
  11.  
  12. int main()
  13. {
  14. const int *p;
  15. Remove(p);
  16. }
  17.  
Success #stdin #stdout 0s 2828KB
stdin
Standard input is empty
stdout
foo() called. it better not try to modify *p!