fork download
  1. bool CompareVariantsAscending( const _variant_t lhs, const _variant_t rhs )
  2. {
  3. switch ( lhs.vt )
  4. {
  5. case VT_R8: case VT_I4: case VT_DATE: case VT_I2: case VT_R4: case VT_CY: case VT_UI1: case VT_DECIMAL:
  6. switch ( rhs.vt )
  7. {
  8. case VT_NULL: return false;
  9. case VT_EMPTY: case VT_BSTR: case VT_ERROR: case VT_BOOL: return true;
  10. default:
  11. return 0 == VarCmp( &(_variant_t) lhs, &(_variant_t) rhs, LOCALE_USER_DEFAULT, NORM_IGNORECASE );
  12. }
  13.  
  14. case VT_BSTR:
  15. switch ( rhs.vt )
  16. {
  17. case VT_BSTR:
  18. return 0 == VarCmp( &(_variant_t) lhs, &(_variant_t) rhs, LOCALE_USER_DEFAULT, NORM_IGNORECASE );
  19. case VT_EMPTY: case VT_ERROR: case VT_BOOL: return true;
  20. default: return false;
  21. }
  22.  
  23. case VT_BOOL:
  24. switch ( rhs.vt )
  25. {
  26. case VT_EMPTY: case VT_ERROR: return true;
  27. case VT_BOOL: return lhs.boolVal > rhs.boolVal;
  28. default: return false;
  29. }
  30.  
  31. case VT_ERROR:
  32. return ( rhs.vt == VT_EMPTY ) ? true : false;
  33.  
  34. // always last
  35. case VT_EMPTY: return false;
  36.  
  37. // always first
  38. case VT_NULL: return true;
  39.  
  40. default: return false;
  41. }
  42. }
  43.  
  44. bool CompareVariantsDescending( const _variant_t lhs, const _variant_t rhs )
  45. {
  46. switch ( lhs.vt )
  47. {
  48. case VT_R8: case VT_I4: case VT_DATE: case VT_I2: case VT_R4: case VT_CY: case VT_UI1: case VT_DECIMAL:
  49. switch ( rhs.vt )
  50. {
  51. case VT_NULL: case VT_BSTR: case VT_BOOL: case VT_ERROR: return false;
  52. case VT_EMPTY: return true;
  53. default:
  54. return 0 < VarCmp( &(_variant_t) lhs, &(_variant_t) rhs, LOCALE_USER_DEFAULT, NORM_IGNORECASE );
  55. }
  56.  
  57. case VT_BSTR:
  58. switch ( rhs.vt )
  59. {
  60. case VT_BSTR:
  61. return 0 < VarCmp( &(_variant_t) lhs, &(_variant_t) rhs, LOCALE_USER_DEFAULT, NORM_IGNORECASE );
  62. case VT_ERROR: case VT_BOOL: case VT_NULL: return false;
  63. default: return true;
  64. }
  65.  
  66. case VT_BOOL:
  67. switch ( rhs.vt )
  68. {
  69. case VT_BOOL: return lhs.boolVal < rhs.boolVal;
  70. case VT_ERROR: case VT_NULL: return false;
  71. default: return true;
  72. }
  73.  
  74. case VT_ERROR:
  75. return ( rhs.vt == VT_NULL || rhs.vt == VT_ERROR ) ? false : true;
  76.  
  77. // always last
  78. case VT_EMPTY: return false;
  79.  
  80. // always first
  81. case VT_NULL: return true;
  82.  
  83. default: return false;
  84. }
  85. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:38: error: ‘_variant_t’ does not name a type
 bool CompareVariantsAscending( const _variant_t lhs, const _variant_t rhs )
                                      ^~~~~~~~~~
prog.cpp:1:60: error: ‘_variant_t’ does not name a type
 bool CompareVariantsAscending( const _variant_t lhs, const _variant_t rhs )
                                                            ^~~~~~~~~~
prog.cpp: In function ‘bool CompareVariantsAscending(int, int)’:
prog.cpp:3:15: error: request for member ‘vt’ in ‘lhs’, which is of non-class type ‘const int’
  switch ( lhs.vt )
               ^~
prog.cpp:5:7: error: ‘VT_R8’ was not declared in this scope
  case VT_R8: case VT_I4: case VT_DATE: case VT_I2: case VT_R4: case VT_CY: case VT_UI1: case VT_DECIMAL:
       ^~~~~
prog.cpp:5:19: error: ‘VT_I4’ was not declared in this scope
  case VT_R8: case VT_I4: case VT_DATE: case VT_I2: case VT_R4: case VT_CY: case VT_UI1: case VT_DECIMAL:
                   ^~~~~
prog.cpp:5:31: error: ‘VT_DATE’ was not declared in this scope
  case VT_R8: case VT_I4: case VT_DATE: case VT_I2: case VT_R4: case VT_CY: case VT_UI1: case VT_DECIMAL:
                               ^~~~~~~
prog.cpp:5:45: error: ‘VT_I2’ was not declared in this scope
  case VT_R8: case VT_I4: case VT_DATE: case VT_I2: case VT_R4: case VT_CY: case VT_UI1: case VT_DECIMAL:
                                             ^~~~~
prog.cpp:5:57: error: ‘VT_R4’ was not declared in this scope
  case VT_R8: case VT_I4: case VT_DATE: case VT_I2: case VT_R4: case VT_CY: case VT_UI1: case VT_DECIMAL:
                                                         ^~~~~
prog.cpp:5:69: error: ‘VT_CY’ was not declared in this scope
  case VT_R8: case VT_I4: case VT_DATE: case VT_I2: case VT_R4: case VT_CY: case VT_UI1: case VT_DECIMAL:
                                                                     ^~~~~
prog.cpp:5:81: error: ‘VT_UI1’ was not declared in this scope
  case VT_R8: case VT_I4: case VT_DATE: case VT_I2: case VT_R4: case VT_CY: case VT_UI1: case VT_DECIMAL:
                                                                                 ^~~~~~
prog.cpp:5:94: error: ‘VT_DECIMAL’ was not declared in this scope
  case VT_R8: case VT_I4: case VT_DATE: case VT_I2: case VT_R4: case VT_CY: case VT_UI1: case VT_DECIMAL:
                                                                                              ^~~~~~~~~~
prog.cpp:6:16: error: request for member ‘vt’ in ‘rhs’, which is of non-class type ‘const int’
   switch ( rhs.vt )
                ^~
prog.cpp:8:8: error: ‘VT_NULL’ was not declared in this scope
   case VT_NULL: return false;
        ^~~~~~~
prog.cpp:9:8: error: ‘VT_EMPTY’ was not declared in this scope
   case VT_EMPTY: case VT_BSTR: case VT_ERROR: case VT_BOOL: return true;
        ^~~~~~~~
prog.cpp:9:23: error: ‘VT_BSTR’ was not declared in this scope
   case VT_EMPTY: case VT_BSTR: case VT_ERROR: case VT_BOOL: return true;
                       ^~~~~~~
prog.cpp:9:37: error: ‘VT_ERROR’ was not declared in this scope
   case VT_EMPTY: case VT_BSTR: case VT_ERROR: case VT_BOOL: return true;
                                     ^~~~~~~~
prog.cpp:9:52: error: ‘VT_BOOL’ was not declared in this scope
   case VT_EMPTY: case VT_BSTR: case VT_ERROR: case VT_BOOL: return true;
                                                    ^~~~~~~
prog.cpp:11:26: error: ‘_variant_t’ was not declared in this scope
    return 0 == VarCmp( &(_variant_t) lhs, &(_variant_t) rhs, LOCALE_USER_DEFAULT, NORM_IGNORECASE );
                          ^~~~~~~~~~
prog.cpp:11:62: error: ‘LOCALE_USER_DEFAULT’ was not declared in this scope
    return 0 == VarCmp( &(_variant_t) lhs, &(_variant_t) rhs, LOCALE_USER_DEFAULT, NORM_IGNORECASE );
                                                              ^~~~~~~~~~~~~~~~~~~
prog.cpp:11:83: error: ‘NORM_IGNORECASE’ was not declared in this scope
    return 0 == VarCmp( &(_variant_t) lhs, &(_variant_t) rhs, LOCALE_USER_DEFAULT, NORM_IGNORECASE );
                                                                                   ^~~~~~~~~~~~~~~
prog.cpp:11:99: error: ‘VarCmp’ was not declared in this scope
    return 0 == VarCmp( &(_variant_t) lhs, &(_variant_t) rhs, LOCALE_USER_DEFAULT, NORM_IGNORECASE );
                                                                                                   ^
prog.cpp:14:7: error: ‘VT_BSTR’ was not declared in this scope
  case VT_BSTR:
       ^~~~~~~
prog.cpp:15:16: error: request for member ‘vt’ in ‘rhs’, which is of non-class type ‘const int’
   switch ( rhs.vt )
                ^~
prog.cpp:17:8: error: the value of ‘VT_BSTR’ is not usable in a constant expression
   case VT_BSTR:
        ^~~~~~~
prog.cpp:14:7: note: ‘VT_BSTR’ was not declared ‘constexpr’
  case VT_BSTR:
       ^~~~~~~
prog.cpp:18:26: error: ‘_variant_t’ was not declared in this scope
    return 0 == VarCmp( &(_variant_t) lhs, &(_variant_t) rhs, LOCALE_USER_DEFAULT, NORM_IGNORECASE );
                          ^~~~~~~~~~
prog.cpp:18:62: error: ‘LOCALE_USER_DEFAULT’ was not declared in this scope
    return 0 == VarCmp( &(_variant_t) lhs, &(_variant_t) rhs, LOCALE_USER_DEFAULT, NORM_IGNORECASE );
                                                              ^~~~~~~~~~~~~~~~~~~
prog.cpp:18:83: error: ‘NORM_IGNORECASE’ was not declared in this scope
    return 0 == VarCmp( &(_variant_t) lhs, &(_variant_t) rhs, LOCALE_USER_DEFAULT, NORM_IGNORECASE );
                                                                                   ^~~~~~~~~~~~~~~
prog.cpp:18:99: error: ‘VarCmp’ was not declared in this scope
    return 0 == VarCmp( &(_variant_t) lhs, &(_variant_t) rhs, LOCALE_USER_DEFAULT, NORM_IGNORECASE );
                                                                                                   ^
prog.cpp:19:8: error: ‘VT_EMPTY’ was not declared in this scope
   case VT_EMPTY: case VT_ERROR: case VT_BOOL: return true;
        ^~~~~~~~
prog.cpp:19:23: error: ‘VT_ERROR’ was not declared in this scope
   case VT_EMPTY: case VT_ERROR: case VT_BOOL: return true;
                       ^~~~~~~~
prog.cpp:19:38: error: ‘VT_BOOL’ was not declared in this scope
   case VT_EMPTY: case VT_ERROR: case VT_BOOL: return true;
                                      ^~~~~~~
prog.cpp:23:7: error: ‘VT_BOOL’ was not declared in this scope
  case VT_BOOL:
       ^~~~~~~
prog.cpp:24:16: error: request for member ‘vt’ in ‘rhs’, which is of non-class type ‘const int’
   switch ( rhs.vt )
                ^~
prog.cpp:26:8: error: ‘VT_EMPTY’ was not declared in this scope
   case VT_EMPTY: case VT_ERROR: return true;
        ^~~~~~~~
prog.cpp:26:23: error: ‘VT_ERROR’ was not declared in this scope
   case VT_EMPTY: case VT_ERROR: return true;
                       ^~~~~~~~
prog.cpp:27:8: error: the value of ‘VT_BOOL’ is not usable in a constant expression
   case VT_BOOL: return lhs.boolVal > rhs.boolVal;
        ^~~~~~~
prog.cpp:23:7: note: ‘VT_BOOL’ was not declared ‘constexpr’
  case VT_BOOL:
       ^~~~~~~
prog.cpp:27:28: error: request for member ‘boolVal’ in ‘lhs’, which is of non-class type ‘const int’
   case VT_BOOL: return lhs.boolVal > rhs.boolVal;
                            ^~~~~~~
prog.cpp:27:42: error: request for member ‘boolVal’ in ‘rhs’, which is of non-class type ‘const int’
   case VT_BOOL: return lhs.boolVal > rhs.boolVal;
                                          ^~~~~~~
prog.cpp:31:7: error: ‘VT_ERROR’ was not declared in this scope
  case VT_ERROR:
       ^~~~~~~~
prog.cpp:32:16: error: request for member ‘vt’ in ‘rhs’, which is of non-class type ‘const int’
   return ( rhs.vt == VT_EMPTY ) ? true : false;
                ^~
prog.cpp:32:22: error: ‘VT_EMPTY’ was not declared in this scope
   return ( rhs.vt == VT_EMPTY ) ? true : false;
                      ^~~~~~~~
prog.cpp:35:7: error: the value of ‘VT_EMPTY’ is not usable in a constant expression
  case VT_EMPTY: return false;
       ^~~~~~~~
prog.cpp:32:22: note: ‘VT_EMPTY’ was not declared ‘constexpr’
   return ( rhs.vt == VT_EMPTY ) ? true : false;
                      ^~~~~~~~
prog.cpp:38:7: error: ‘VT_NULL’ was not declared in this scope
  case VT_NULL: return true;
       ^~~~~~~
prog.cpp: At global scope:
prog.cpp:44:39: error: ‘_variant_t’ does not name a type
 bool CompareVariantsDescending( const _variant_t lhs, const _variant_t rhs )
                                       ^~~~~~~~~~
prog.cpp:44:61: error: ‘_variant_t’ does not name a type
 bool CompareVariantsDescending( const _variant_t lhs, const _variant_t rhs )
                                                             ^~~~~~~~~~
prog.cpp: In function ‘bool CompareVariantsDescending(int, int)’:
prog.cpp:46:15: error: request for member ‘vt’ in ‘lhs’, which is of non-class type ‘const int’
  switch ( lhs.vt )
               ^~
prog.cpp:48:7: error: ‘VT_R8’ was not declared in this scope
  case VT_R8: case VT_I4: case VT_DATE: case VT_I2: case VT_R4: case VT_CY: case VT_UI1: case VT_DECIMAL:
       ^~~~~
prog.cpp:48:19: error: ‘VT_I4’ was not declared in this scope
  case VT_R8: case VT_I4: case VT_DATE: case VT_I2: case VT_R4: case VT_CY: case VT_UI1: case VT_DECIMAL:
                   ^~~~~
prog.cpp:48:31: error: ‘VT_DATE’ was not declared in this scope
  case VT_R8: case VT_I4: case VT_DATE: case VT_I2: case VT_R4: case VT_CY: case VT_UI1: case VT_DECIMAL:
                               ^~~~~~~
prog.cpp:48:45: error: ‘VT_I2’ was not declared in this scope
  case VT_R8: case VT_I4: case VT_DATE: case VT_I2: case VT_R4: case VT_CY: case VT_UI1: case VT_DECIMAL:
                                             ^~~~~
prog.cpp:48:57: error: ‘VT_R4’ was not declared in this scope
  case VT_R8: case VT_I4: case VT_DATE: case VT_I2: case VT_R4: case VT_CY: case VT_UI1: case VT_DECIMAL:
                                                         ^~~~~
prog.cpp:48:69: error: ‘VT_CY’ was not declared in this scope
  case VT_R8: case VT_I4: case VT_DATE: case VT_I2: case VT_R4: case VT_CY: case VT_UI1: case VT_DECIMAL:
                                                                     ^~~~~
prog.cpp:48:81: error: ‘VT_UI1’ was not declared in this scope
  case VT_R8: case VT_I4: case VT_DATE: case VT_I2: case VT_R4: case VT_CY: case VT_UI1: case VT_DECIMAL:
                                                                                 ^~~~~~
prog.cpp:48:94: error: ‘VT_DECIMAL’ was not declared in this scope
  case VT_R8: case VT_I4: case VT_DATE: case VT_I2: case VT_R4: case VT_CY: case VT_UI1: case VT_DECIMAL:
                                                                                              ^~~~~~~~~~
prog.cpp:49:16: error: request for member ‘vt’ in ‘rhs’, which is of non-class type ‘const int’
   switch ( rhs.vt )
                ^~
prog.cpp:51:8: error: ‘VT_NULL’ was not declared in this scope
   case VT_NULL: case VT_BSTR: case VT_BOOL: case VT_ERROR: return false;
        ^~~~~~~
prog.cpp:51:22: error: ‘VT_BSTR’ was not declared in this scope
   case VT_NULL: case VT_BSTR: case VT_BOOL: case VT_ERROR: return false;
                      ^~~~~~~
prog.cpp:51:36: error: ‘VT_BOOL’ was not declared in this scope
   case VT_NULL: case VT_BSTR: case VT_BOOL: case VT_ERROR: return false;
                                    ^~~~~~~
prog.cpp:51:50: error: ‘VT_ERROR’ was not declared in this scope
   case VT_NULL: case VT_BSTR: case VT_BOOL: case VT_ERROR: return false;
                                                  ^~~~~~~~
prog.cpp:52:8: error: ‘VT_EMPTY’ was not declared in this scope
   case VT_EMPTY: return true;
        ^~~~~~~~
prog.cpp:54:25: error: ‘_variant_t’ was not declared in this scope
    return 0 < VarCmp( &(_variant_t) lhs, &(_variant_t) rhs, LOCALE_USER_DEFAULT, NORM_IGNORECASE );
                         ^~~~~~~~~~
prog.cpp:54:61: error: ‘LOCALE_USER_DEFAULT’ was not declared in this scope
    return 0 < VarCmp( &(_variant_t) lhs, &(_variant_t) rhs, LOCALE_USER_DEFAULT, NORM_IGNORECASE );
                                                             ^~~~~~~~~~~~~~~~~~~
prog.cpp:54:82: error: ‘NORM_IGNORECASE’ was not declared in this scope
    return 0 < VarCmp( &(_variant_t) lhs, &(_variant_t) rhs, LOCALE_USER_DEFAULT, NORM_IGNORECASE );
                                                                                  ^~~~~~~~~~~~~~~
prog.cpp:54:98: error: ‘VarCmp’ was not declared in this scope
    return 0 < VarCmp( &(_variant_t) lhs, &(_variant_t) rhs, LOCALE_USER_DEFAULT, NORM_IGNORECASE );
                                                                                                  ^
prog.cpp:57:7: error: ‘VT_BSTR’ was not declared in this scope
  case VT_BSTR:
       ^~~~~~~
prog.cpp:58:16: error: request for member ‘vt’ in ‘rhs’, which is of non-class type ‘const int’
   switch ( rhs.vt )
                ^~
prog.cpp:60:8: error: the value of ‘VT_BSTR’ is not usable in a constant expression
   case VT_BSTR:
        ^~~~~~~
prog.cpp:57:7: note: ‘VT_BSTR’ was not declared ‘constexpr’
  case VT_BSTR:
       ^~~~~~~
prog.cpp:61:25: error: ‘_variant_t’ was not declared in this scope
    return 0 < VarCmp( &(_variant_t) lhs, &(_variant_t) rhs, LOCALE_USER_DEFAULT, NORM_IGNORECASE );
                         ^~~~~~~~~~
prog.cpp:61:61: error: ‘LOCALE_USER_DEFAULT’ was not declared in this scope
    return 0 < VarCmp( &(_variant_t) lhs, &(_variant_t) rhs, LOCALE_USER_DEFAULT, NORM_IGNORECASE );
                                                             ^~~~~~~~~~~~~~~~~~~
prog.cpp:61:82: error: ‘NORM_IGNORECASE’ was not declared in this scope
    return 0 < VarCmp( &(_variant_t) lhs, &(_variant_t) rhs, LOCALE_USER_DEFAULT, NORM_IGNORECASE );
                                                                                  ^~~~~~~~~~~~~~~
prog.cpp:61:98: error: ‘VarCmp’ was not declared in this scope
    return 0 < VarCmp( &(_variant_t) lhs, &(_variant_t) rhs, LOCALE_USER_DEFAULT, NORM_IGNORECASE );
                                                                                                  ^
prog.cpp:62:8: error: ‘VT_ERROR’ was not declared in this scope
   case VT_ERROR: case VT_BOOL: case VT_NULL: return false;
        ^~~~~~~~
prog.cpp:62:23: error: ‘VT_BOOL’ was not declared in this scope
   case VT_ERROR: case VT_BOOL: case VT_NULL: return false;
                       ^~~~~~~
prog.cpp:62:37: error: ‘VT_NULL’ was not declared in this scope
   case VT_ERROR: case VT_BOOL: case VT_NULL: return false;
                                     ^~~~~~~
prog.cpp:66:7: error: ‘VT_BOOL’ was not declared in this scope
  case VT_BOOL:
       ^~~~~~~
prog.cpp:67:16: error: request for member ‘vt’ in ‘rhs’, which is of non-class type ‘const int’
   switch ( rhs.vt )
                ^~
prog.cpp:69:8: error: the value of ‘VT_BOOL’ is not usable in a constant expression
   case VT_BOOL: return lhs.boolVal < rhs.boolVal;
        ^~~~~~~
prog.cpp:66:7: note: ‘VT_BOOL’ was not declared ‘constexpr’
  case VT_BOOL:
       ^~~~~~~
prog.cpp:69:28: error: request for member ‘boolVal’ in ‘lhs’, which is of non-class type ‘const int’
   case VT_BOOL: return lhs.boolVal < rhs.boolVal;
                            ^~~~~~~
prog.cpp:69:42: error: request for member ‘boolVal’ in ‘rhs’, which is of non-class type ‘const int’
   case VT_BOOL: return lhs.boolVal < rhs.boolVal;
                                          ^~~~~~~
prog.cpp:70:8: error: ‘VT_ERROR’ was not declared in this scope
   case VT_ERROR: case VT_NULL: return false;
        ^~~~~~~~
prog.cpp:70:23: error: ‘VT_NULL’ was not declared in this scope
   case VT_ERROR: case VT_NULL: return false;
                       ^~~~~~~
prog.cpp:74:7: error: ‘VT_ERROR’ was not declared in this scope
  case VT_ERROR:
       ^~~~~~~~
prog.cpp:75:16: error: request for member ‘vt’ in ‘rhs’, which is of non-class type ‘const int’
   return ( rhs.vt == VT_NULL || rhs.vt == VT_ERROR ) ? false : true;
                ^~
prog.cpp:75:22: error: ‘VT_NULL’ was not declared in this scope
   return ( rhs.vt == VT_NULL || rhs.vt == VT_ERROR ) ? false : true;
                      ^~~~~~~
prog.cpp:75:37: error: request for member ‘vt’ in ‘rhs’, which is of non-class type ‘const int’
   return ( rhs.vt == VT_NULL || rhs.vt == VT_ERROR ) ? false : true;
                                     ^~
prog.cpp:78:7: error: ‘VT_EMPTY’ was not declared in this scope
  case VT_EMPTY: return false;
       ^~~~~~~~
prog.cpp:81:7: error: the value of ‘VT_NULL’ is not usable in a constant expression
  case VT_NULL: return true;
       ^~~~~~~
prog.cpp:75:22: note: ‘VT_NULL’ was not declared ‘constexpr’
   return ( rhs.vt == VT_NULL || rhs.vt == VT_ERROR ) ? false : true;
                      ^~~~~~~
stdout
Standard output is empty