У меня есть следующее for each кода C++:
for (auto item : myVector)
{
std::cout << item;
if (item == orderBy.IsLast()) // <--- Check if this is the last element
std::cout << "(Is last element) " << std::endl;
else if (item == orderBy.IsFirst()) // <-- Check if this is the first element
std::cout << "(Is first element)" << std::endl;
}
Конечно, IfLast() и IfFirst() не существуют в std::vector. Есть ли собственный std:: way для проверки первого и последнего элемента?