When they are of the same type you can do:
auto it = vec.begin(), itt = std::next(vec.begin()); it != vec.end() ...
--There is a fairly arbitrary (unless I missed an important argument) limitation on initialization clause for if statements.
- I have that
if (auto it = vec.begin(); it != vec.end()) {
- I want this
if (auto it = vec.begin() /*and*/ auto itt = ++vec.begin(); it != vec.end() && it != itt) {
So you end up using one of the workarounds, which are somewhat hacky imo :/
I'd like to release that restriction and have for example
if ({auto it = vec.begin();auto itt = ++vec.begin();}; it != vec.end() && it != itt) {
which can be desugared (desugarified ?) to e.g.
{
auto it = vec.begin();
auto itt = vec.begin();
if (it != vec.end()) {}
}
Colleague pointed me to a GCC expression statements extension which ?maybe? makes `if ({` ambiguous to parse, so I would have to look into that too…Cheers.
Is there any current proposal that aims to lift that restriction ?Sent from Gmail Mobile
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals