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 >)’
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
#include
#include
#include
#include
#include
#include
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;
}