C++ Logo

std-proposals

Advanced search

[std-proposals] Helper type

From: organicoman <organicoman_at_[hidden]>
Date: Thu, 24 Nov 2022 04:01:59 +0400
Hello gents,I would like to suggest the following helper type:"null_iter"It is of type iterator but convertible to the boolean value "false", much like the type: "nullptr"This value "null_iter" is returned by all container iterators types (vector::iterator, list::iterator, set::iterator...etc) to denote the end of the container when you apply the increment or decrement operators.For exple:--------- code snippet -------std::vector<int> v{1,2,3,4};auto iter = v.begin();while(++iter){ //}------- end of snippet------ When "iter" hits "v.end()", it will return "null_iter" which will be converted to "false" then the loop stops.What do you think?NadirSent from my Galaxy

Received on 2022-11-24 00:02:09