fork download
  1. template<class _RanIt> inline
  2. void random_shuffle(_RanIt _First, _RanIt _Last)
  3. { // shuffle [_First, _Last)
  4. _DEBUG_RANGE(_First, _Last);
  5. if (_First != _Last)
  6. _Random_shuffle(_Unchecked(_First), _Unchecked(_Last),
  7. _Dist_type(_First)); // alogithm, line #2237
  8. }
  9.  
  10. template<class _RanIt,
  11. class _Diff> inline
  12. void _Random_shuffle(_RanIt _First, _RanIt _Last, _Diff *)
  13. { // shuffle [_First, _Last)
  14. const int _RANDOM_BITS = 15; // minimum random bits from rand()
  15. const int _RANDOM_MAX = (1U << _RANDOM_BITS) - 1;
  16.  
  17. _RanIt _Next = _First;
  18. for (unsigned long _Index = 2; ++_Next != _Last; ++_Index)
  19. { // assume unsigned long big enough for _Diff count
  20. unsigned long _Rm = _RANDOM_MAX;
  21. unsigned long _Rn = _CSTD rand() & _RANDOM_MAX;
  22. for (; _Rm < _Index && _Rm != ~0UL;
  23. _Rm = _Rm << _RANDOM_BITS | _RANDOM_MAX)
  24. _Rn = _Rn << _RANDOM_BITS
  25. | (_CSTD rand() & _RANDOM_MAX); // build random value
  26.  
  27. _STD iter_swap(_Next, _First + _Diff(_Rn % _Index)); // swap a pair <=== here the error, line 2228 of algorithm
  28. }
  29. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'void _Random_shuffle(_RanIt, _RanIt, _Diff*)':
prog.cpp:21:23: error: '_CSTD' was not declared in this scope
prog.cpp:21:29: error: expected ',' or ';' before 'rand'
prog.cpp:25:14: error: expected ')' before 'rand'
prog.cpp:27:3: error: '_STD' was not declared in this scope
prog.cpp:27:8: error: expected ';' before 'iter_swap'
stdout
Standard output is empty