C++ equivalent of Python String Slice?

前端 未结 6 1234
灰色年华
灰色年华 2021-01-01 13:30

In python I was able to slice part of a string; in other words just print the characters after a certain position. Is there an equivalent to this in C++?

Python Code

6条回答
  •  长发绾君心
    2021-01-01 13:57

    It looks like C++20 will have Ranges https://en.cppreference.com/w/cpp/ranges which are designed to provide, amongst other things, python-like slicing http://ericniebler.com/2014/12/07/a-slice-of-python-in-c/ So I'm waiting for it to land in my favorite compiler, and meanwhile use https://ericniebler.github.io/range-v3/

提交回复
热议问题