Boost Users :
From: Samuel Krempp (krempp_at_[hidden])
Date: 2004-01-29 15:47:32
On Thu, 2004-01-29 at 18:10, Jaakko Jarvi wrote:
> format f("%-10s|") ;
> for_each(Foos.begin(), Foos.end(),
> cout << ret<format&>(var(f) % bind(&foo::name, _1)));
> // format defines operator% as a member, which takes precedence over
> // % defined by lambda. Therefore one must make the format object to
> // be a lambda functor. var does that.
> // Var, however, cannot take a temporary object (it holds a reference to
> // the wrapped object). That's why the variable f.
> // ret<format&> informs lambda about the return type of formats % operator.
ah I hadn't thought about the interaction of the operator% with lambda.
What would the situation be if the operator% were out of the class ?
If it improves the usability with lambda, that would seem a reason
enough, for me. In fact I had made it a member at first, because it
needs access to the private data, but I had to put the real code in
out-of-class functions anyhow because of msvc6 problems with member
function templates, so I might as well make the whole operator% declared
out of class.
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