Boost logo

Boost Users :

From: Matthias Kaeppler (nospam_at_[hidden])
Date: 2005-04-17 04:17:34


Hi,

in my program, I have this function to compute the sum of sizes of a
bunch of files:

Glib::ustring DirBrowser::get_total_file_size()
{
     using namespace boostfs; // boostfs = boost::filesystem
     using namespace lambda; // lambda = boost::lambda
     boost::intmax_t sum = 0;
     std::for_each(m_first_file,m_files.end(),sum+=bind(&file_size,*_1));
     return make_size_human_readable( sum );
}

The line with for_each computes the sum of file sizes, by iterating over
a container of pointers to boostfs::pathS, starting at the first file
(there are also directories, before the files), till the end, invoking
the lambda functor on each.

Since this method does not change the state of the object, I wanted to
declare it const, but suddenly the lambda expression starts complaining:
Somehow, those path objects inside the lambda expression become const
now, too, and it doesn't compile anymore.

How come?

-- 
Matthias Kaeppler

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net