For some reason, I fail to use boost::format
in a boost::lambda
. Here is a (hopefully) compilable simplification of my code :
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <boost/assign/list_of.hpp>
#include <boost/format.hpp>
#include <boost/lambda/lambda.hpp>
namespace bl = boost::lambda;
int main()
{
const std::vector<int> v = boost::assign::list_of(1)(2)(3);
std::for_each(v.begin(), v.end(), bl::var(std::cout) << std::setw(10) << bl::_1);
std::for_each(v.begin(), v.end(), bl::var(std::cout) << boost::format("%10d") % bl::_1);
}
- The first
std::for_each
produces the expected output - The second
std::for_each
only outputs whitespaces without any number
Why is that ? I'm really not familiar with boost::lambda
so I might be missing the obvious here.
Please do not suggest std::copy
based answers : my actual code does not work on std::vector
but on boost::fusion::vector
(and std::for_each
is in fact a boost::fusion::for_each
).