c++ removing whitespace fails by using iterators

Not only the commented line, but another will also fail if there is space in the begin of string. First line fail (to compile) because string::find_first_not_of return size_t. And construct string from two size just make no sense. Second line may fail because string::substr accept length (not end) as it’s second parameter.

How can I override next() for jagged array java?

This might be a wrong answer to your question. I’ll remove it in that case, but maybe you can use it for what you want to achieve: int[][] it = {{1,2}, {3,4,5}}; OfInt iterator = Arrays.stream(it).flatMapToInt(x -> IntStream.of(x)).iterator(); iterator.forEachRemaining((IntConsumer) System.out::print); Stream the jagged array, flatmap it into one single IntStream and then do what you … Read more