const int Size=100; std::random_device rd; std::mt19937 gen(rd()); std::uniform_int_distribution<> dis(0, 1000); int main() { list<double>a(Size); iota(a.begin(), a.end(), 2); shuffle(a.begin(),a.end(),dis(gen)); } 

Error: error: no match for 'operator+' (operand types are 'std::_List_iterator<double>' and 'int')

    2 answers 2

    Go to the std :: shuffle documentation :

    ...

     template< class RandomIt, class URNG > void shuffle( RandomIt first, RandomIt last, URNG&& g ); 

    ...

    Type Requirements

    -RandomIt must meet the requirements of ValueSwappable and RandomAccessIterator .

    -URNG must comply with UniformRandomNumberGenerator requirements.

    Those. the passed iterators must have an overloaded operator +, which the iterator’s std :: list does not have, which itself is a sequential-access container.

      list does not provide an iterator with random access, shuffle not applicable to it (the + operator, which is referred to in the error message, is not defined for the list container iterator).

      Use vector<double> .