1

According to the docs here this iterator is a LegacyInputIterator, which is a LegacyIterator. Now, according to my understanding of the meaning of 'legacy', it means this:

In computing, a legacy system is an old method, technology, computer system, or application program, "of, relating to, or being a previous or outdated computer system,"[1] yet still in use. - Wikipedia

  1. of or pertaining to old or outdated computer hardware, software, or data that, while still functional, does not work well with up-to-date systems. - Dictionary

So in my code to iterator through some folders I do this:

std::filesystem::directory_iterator iter{ "c:/folder" };

while (iter != std::filesystem::directory_iterator{})
{
    // Do something with the file
    ++iter;
}

I'm just wondering if there's a better or newer way of doing this, as I have suspicions over the use of the term legacy for the iterators I'm using.

Zebrafish
  • 11,682
  • 3
  • 43
  • 119
  • Related: https://stackoverflow.com/questions/53970756/new-iterator-requirements – m88 Aug 27 '21 at 09:59

1 Answers1

4

The LegacyIterator is a named-requirement from the C++ standard. The "Legacy" part was added in C++20, to differentiate Concepts names from unchecked, named-requirements imposed by the previous standards on certain types.

It is just an old name from the standard for a set of requirements, that certain types have. You can use it without worry.

Kaznov
  • 1,035
  • 10
  • 17