fork(3) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. typedef struct {
  5. unsigned v;
  6. } GPIO_typedef;
  7.  
  8.  
  9. #define PORTA ((GPIO_typedef*)0x04)
  10. #define PORTB ((GPIO_typedef*)0x08)
  11.  
  12. template< GPIO_typedef* T >
  13. inline
  14. unsigned getPortFlag()
  15. {
  16. //static_assert(false, "not implemented for this target");
  17. return 0;
  18. }
  19.  
  20. template< >
  21. inline
  22. unsigned getPortFlag< PORTA >()
  23. {
  24. return 1;
  25. }
  26.  
  27.  
  28.  
  29. int main() {
  30. // your code goes here
  31.  
  32. cout<<"Port A flag: "<<getPortFlag<PORTA>()<<"\n";
  33. cout<<"Port B flag: "<<getPortFlag<PORTB>()<<"\n";
  34. return 0;
  35. }
  36.  
  37.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:22:10: error: template-id ‘getPortFlag<4u>’ for ‘unsigned int getPortFlag()’ does not match any template declaration
 unsigned getPortFlag< PORTA >()
          ^~~~~~~~~~~~~~~~~~~~
prog.cpp:14:10: note: candidate is: template<GPIO_typedef* T> unsigned int getPortFlag()
 unsigned getPortFlag()
          ^~~~~~~~~~~
prog.cpp: In function ‘int main()’:
prog.cpp:32:44: error: no matching function for call to ‘getPortFlag()’
  cout<<"Port A flag: "<<getPortFlag<PORTA>()<<"\n";
                                            ^
prog.cpp:14:10: note: candidate: template<GPIO_typedef* T> unsigned int getPortFlag()
 unsigned getPortFlag()
          ^~~~~~~~~~~
prog.cpp:14:10: note:   template argument deduction/substitution failed:
prog.cpp:32:44: error: ‘4u’ is not a valid template argument for ‘GPIO_typedef*’ because it is not the address of a variable
  cout<<"Port A flag: "<<getPortFlag<PORTA>()<<"\n";
                                            ^
prog.cpp:33:44: error: no matching function for call to ‘getPortFlag()’
  cout<<"Port B flag: "<<getPortFlag<PORTB>()<<"\n";
                                            ^
prog.cpp:14:10: note: candidate: template<GPIO_typedef* T> unsigned int getPortFlag()
 unsigned getPortFlag()
          ^~~~~~~~~~~
prog.cpp:14:10: note:   template argument deduction/substitution failed:
prog.cpp:33:44: error: ‘8u’ is not a valid template argument for ‘GPIO_typedef*’ because it is not the address of a variable
  cout<<"Port B flag: "<<getPortFlag<PORTB>()<<"\n";
                                            ^
stdout
Standard output is empty