M
Matthias Kaeppler
Hi,
in my program, I have this funtion to compute the sum 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:athS, 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?
in my program, I have this funtion to compute the sum 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:athS, 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?