Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5849963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:04:28+00:00 2026-05-22T13:04:28+00:00

I am given a boost::filesystem::path. Is there a fast way to get the number

  • 0

I am given a boost::filesystem::path. Is there a fast way to get the number of files in the directory pointed to by the path?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T13:04:28+00:00Added an answer on May 22, 2026 at 1:04 pm

    Here’s one-liner in Standard C++:

    #include <iostream>
    #include <boost/filesystem.hpp>
    #include <boost/lambda/bind.hpp>
    
    int main()
    {
        using namespace boost::filesystem;
        using namespace boost::lambda;
    
        path the_path( "/home/myhome" );
    
        int cnt = std::count_if(
            directory_iterator(the_path),
            directory_iterator(),
            static_cast<bool(*)(const path&)>(is_regular_file) );
    
        // a little explanation is required here,
        // we need to use static_cast to specify which version of
        // `is_regular_file` function we intend to use
        // and implicit conversion from `directory_entry` to the
        // `filesystem::path` will occur
    
        std::cout << cnt << std::endl;
    
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given: filesystem::path toDir(./); ptime oldTime; ptime now(second_clock::local_time()); How can I determine which files were
Is there a method in boost::filesystem that gives the file system type for a
I call boost::asio::serial_port::async_write_some() and asio::io_service::run() in the other thread. There is a callback given
In my program I would like to manipulate boost::filesystem::path elements of a vector in
Given two identical boost::variant instances a and b , the expression ( a ==
Given a date range how to calculate the number of weekends partially or wholly
Given an interface or interfaces, what is the best way to generate an class
Given a sequence (for example a string Xa), I want to get the next
I've used boost::gregorian::date a bit now. I can see that there are the related
Is there an existing function (in boost mpl or fusion) to splat meta-vector to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.