fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<typename T>
  5. struct add_const_deep {
  6. using type = const T;
  7. };
  8.  
  9. template<typename T>
  10. struct add_const_deep<T*> {
  11. using type = typename add_const_deep<T>::type*;
  12. };
  13.  
  14. template<typename T>
  15. struct add_const_deep<T&> {
  16. using type = typename add_const_deep<T>::type&;
  17. };
  18.  
  19.  
  20. int main() {
  21. add_const_deep<int ***>::type a;
  22.  
  23. ***a = 0;
  24.  
  25. return 0;
  26. }
Compilation error #stdin compilation error #stdout 0s 3456KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:23:7: error: assignment of read-only location '* * * a'
  ***a = 0;
       ^
stdout
Standard output is empty