I can't consider the basic loops 'out of fashion' because they are large used and they are the simple and best way to interate over primitive elements or keep a flow control.
Just for example, I have a template function where I receive an array and I want to print the number of index elements
//1. While -----------------------------------------------------------------------------------------------------------
template <typename obj, size_t S, enable_if_t <S != 0, size_t> = 1>
void WhileDescending(const array<obj, S>& Obj) {
size_t Size = Obj.size();
while (Size) {
--Size;
cout << Size;
}
}
//2. do ---------------------------------------------------------------------------------------------------------------
template <typename obj, size_t S, enable_if_t <S != 0, size_t> = 1>
void DoDescending(const array<obj, S>& Obj) {
size_t Size = Obj.size();
do {
--Size;
cout << Size;
} while (Size);
}
//3. for ----------------------------------------------------------------------------------------------------------------
template <typename obj, size_t S, enable_if_t <S != 0, size_t> = 1>
void ForDescending(const array<obj, S>& Obj) {
for (size_t Size = Obj.size() - 1; Size != numeric_limits<size_t>::max(); --Size)
cout << Size;
}
//The proposal 'dofor' ---------------------------------------------------------------------------------------------
template <typename obj, size_t S, enable_if_t <S != 0, size_t> = 1>
void DoForDescending(const array<obj, S>& Obj) {
dofor (size_t Size = Obj.size(); --Size; Size >= 0)
cout << Size;
}