1. THIS DOESN'T WORK: undefined reference to `int asd<int, 0>(int*)'
  2.  
  3. #include <type_traits>
  4. #include <iostream>
  5. using namespace std;
  6.  
  7. template <typename T, typename enable_if< is_array<T>::value, int >::type =0 > int asd(T*){
  8. cout<<"This is for arrays"<<endl;
  9. return 0;
  10. }
  11.  
  12. template <typename T, typename enable_if< !is_array<T>::value, int >::type =0 > int asd(T*){
  13. cout<<"This is for NON arrays"<<endl;
  14. return 0;
  15. }
  16.  
  17. int main() {
  18. int dummy=3;
  19. int (*voided)(void*)=(int (*)(void*))asd<decltype(dummy)>;
  20. voided(&dummy);
  21. }
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28. THIS DOES:
  29.  
  30. #include <type_traits>
  31. #include <iostream>
  32. using namespace std;
  33.  
  34. template <typename T, typename enable_if< is_array<T>::value, int >::type =0 > int asd(T*){
  35. cout<<"This is for arrays"<<endl;
  36. return 0;
  37. }
  38.  
  39. template <typename T, typename enable_if< !is_array<T>::value, int >::type =0 > int asd(T*){
  40. cout<<"This is for NON arrays"<<endl;
  41. return 0;
  42. }
  43.  
  44. int main() {
  45. int dummy=3;
  46. int (*temp)(decltype(dummy)*)=asd<decltype(dummy)>;
  47. int (*voided)(void*)=(int (*)(void*))temp;
  48. voided(&dummy);
  49. }