Is there a compact equivalent to Python range() in C++/STL

后端 未结 10 892
[愿得一人]
[愿得一人] 2020-12-04 21:23

How can I do the equivalent of the following using C++/STL? I want to fill a std::vector with a range of values [min, max).

# Python
>>>         


        
10条回答
  •  孤城傲影
    2020-12-04 21:52

    There is boost::irange:

    std::vector x;
    boost::push_back(x, boost::irange(0, 10));
    

提交回复
热议问题