Closed daaannieeellll closed 1 year ago
@daaannieeellll this needs to be merged lol I need this for my tooling. Also I have a question, is it a general c++ issue or exclusive to apple clang: for each is looking for begin/end method but can't use the capitalized ones Begin/End? I had to derive a custom class and define a lower case begin/end method than call Begin/End respectively.
@Cryptiiiic from my understanding range based for loops require both a begin and end function, either as member functions or found using argument-dependent lookup (ADL). This does not depend on the compiler, as it is standard behavior.
For this PR, however, I decided to use the capitalized function names for it to be more likely to be merged (looking at the used cpp code-style). Though, I could consider another PR with added lowercase members.
You can use the iterator-based for loop as an alternative for the range-based for loop:
{
auto &&range = /* range-expression */;
auto begin = range.Begin() ;
auto end = range.End() ;
for ( ; begin != end; ++begin)
{
/* range-declaration */ = *begin;
/* loop-statement */
}
}
Or if you’re using for-each, you can just provide the Begin and End functions as begin and end.
std::for_each(
/* PList object */.Begin(),
/* PList object */.End(),
/* function */
);
I'm not using the C++ extensions to be honest, but if you feel the lowercase ones would be more helpful, we can use the lowercase ones. This would allow stuff like this, if I am not mistaken:
for each (auto item in my_PList_array) {
}
Absolutely. So using these lowercase function names is more convenient and more readable. If you agree I can update this PR so that it contains both capitalized and lowercase function names (as renaming them might introduce breaking changes).
Go ahead. As for begin
and end
I don't see anything breaking.
Merged after rebase.
... returning both iterators and const_iterators: