Boost logo

Boost Users :

From: Shawn Church (sl_church_at_[hidden])
Date: 2004-01-29 01:48:07

I may be missing something simple here but I have tried everything I can think
and cannot get the following to work (simplified from a project I am working

Given a class such as:

class foo{

foo(const char* name): _name(name) {}
const char* name() const {return _name.c_str();}

std::string _name;};

I can do the following without any problems:

std::vector<foo> Foos;
for_each(Foos.begin(), Foos.end(),cout << bind(&foo::name, _1) << "|");

This prints a list of all the names in the vector of Foo objects by calling
the Foo::name() method. It would be nice to be able to do something like the

for_each(Foos.begin(), Foos.end(), cout << format("%-10s|") % bind(&foo::name,

I have tried everything I can think of including extending the return type
deduction of the lambda library to include the "%" operator as used by format
and binding directly to the basic_format::operator% method. In every case I
get 40 or so compile errors explaining why my 30 character statement is wrong

Does anyone have an example of this usage that works? This is not a high
priority as I can obviously just format the value returned by the Foo::name()
method but it would be nice to have this technique available when the need

I adapated the code above from a test program that demonstrates the problem in
detail. I can provide the test program if anyone is interested (just tell me
what to do with it).

Thankyou for any help you can provide,

Shawn Church

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at