fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. template <typename Element> bool IsArray (const vector <Element>& vec)
  6. {
  7. return true;
  8. }
  9.  
  10. template <typename Item> bool IsArray (const Item& item)
  11. {
  12. return false;
  13. }
  14.  
  15. int main()
  16. {
  17. int n = 42;
  18. cout << "An int is a vector: " << boolalpha << IsArray (n) << endl;
  19. vector <int> v;
  20. cout << "A vector <int> is a vector: " << boolalpha << IsArray (v) << endl;
  21. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
An int is a vector: false
A vector <int> is a vector: true