Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 16th, 2012  |  syntax: None  |  size: 0.48 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. typename outside of template
  2. template<class T>
  3. struct Upcast;
  4.  
  5. template<>
  6. struct Upcast<signed char>
  7. {
  8.     typedef signed short type;
  9. };
  10.  
  11. template<>
  12. struct Upcast<char>
  13. {
  14.     typedef typename std::conditional<std::is_signed<char>::value,short, unsigned short>::type type;
  15. };
  16.  
  17. int main()
  18. {
  19.     Upcast<char>::type a;
  20.     return 0;
  21. }
  22.        
  23. Error   1   error C2899: typename cannot be used outside a template declaration
  24.        
  25. #include<vector>
  26.  
  27. int main() {
  28.   typename std::vector<int> v;
  29. }