How to count the number of files in a directory using standard?
<p>The new standard expected for 2017 adds <code>std::filesystem</code>. Using it, how can I count the number of files (including sub-directories) in a directory?</p>

<p>I know we can do:</p>

<pre><code>std::size_t number_of_files_in_directory(std::filesystem::path path)
{
    std::size_t number_of_files = 0u;
    for (auto const &amp; file : std::filesystem::directory_iterator(path))
    {
        ++number_of_files;
    }
    return number_of_files;
}
</code></pre>

<p>But that seems overkill. Does a simpler and faster way exist?</p>