|
Boost Users : |
Subject: [Boost-users] boost lambda wiht bind to stringstream::str
From: Conoscenza Silente (abruzzoforteegentile_at_[hidden])
Date: 2010-07-15 18:37:44
Hi all
I am trying to get familiar with boost lambda.
Below I am using std::transform algorithm but when I try to call
std::stringstream::str() function using lambda::bind I receive the following
error message:
TestBoost15Jul.cpp:49: error: no matching function for call to
bind(<unresolved overloaded function type>, const
boost::reference_wrapper<std::basic_stringstream<char,
std::char_traits<char>, std::allocator<char> > >)
Do you also know if is the right way to return the string that must be
stored in the second vector used by std::transform?
Regards
AFG
// C++
#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
// boost
#include <boost/assign.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/assign/std/vector.hpp>
#include <boost/lambda/core.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/function.hpp>
int main( int argc, char** argv ){
namespace bl = boost::lambda;
using namespace boost::assign;
std::vector< std::string > vIn = list_of("a")("b")("c")("d");
std::vector< std::string > vOut;
std::stringstream outFmt;
int nCount = 2;
bl::var_type< int >::type _nCount( bl::var(nCount) );
bl::var_type< std::stringstream >::type _outFmt( bl::var(outFmt) );
std::transform( vIn.begin(), vIn.end(), vOut.begin(),
(
_outFmt << bl::_1 << "=%" << _nCount << "%",
_nCount++,
bl::bind( &std::stringstream::str , boost::ref(outFmt) )() //
this call to bind has some problem
) );
std::cout << outFmt.str() << std::endl;
return 1;
}
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