Boost logo

Boost Users :

Subject: Re: [Boost-users] Phoenix question
From: Surya Kiran Gullapalli (suryakiran.gullapalli_at_[hidden])
Date: 2009-11-26 12:51:12


Can you provide the full code, including the #includes, and say which
> version of
> Boost you're using, and which compiler.
>
> - Rob.
>

Hello the complete code is given below. I'm using Boost 1.41.0 on VC9 and
VC8.

=============================================================================
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using std::cout ;
using std::endl ;

#include <boost/algorithm/string/trim.hpp>
#include <boost/spirit/include/phoenix.hpp>

namespace phx = boost::phoenix ;
namespace pha = phx::arg_names ;
namespace str_algo = boost::algorithm ;

void trim(std::string& s)
{
str_algo::trim(s) ;
}

int main (void)
{
std::vector<std::string> vs ;

vs.push_back (" String1 ") ;
vs.push_back (" String2 ") ;
vs.push_back (" String3 ") ;

phx::for_each (pha::arg1, phx::lambda[ cout << pha::arg1 << '\n' ])(vs) ;
cout << "===================================" << endl ;

// What I'm trying to do is call boost::algorithm::trim on all elements of
vector.
// the below given statement works without any problem.
std::for_each (vs.begin(), vs.end(), phx::bind(&trim, pha::arg1));
 //How do I call boost::algorithm::trim directly using Boost.Phoenix or
Boost.Lambda. Below
//I'm trying to do it using phoenix.
//std::for_each (vs.begin(), vs.end(), phx::bind(&str_algo::template trim,
pha::_1));
 phx::for_each (pha::arg1, phx::lambda[ cout << pha::arg1 << '\n' ])(vs) ;
cout << "===================================" << endl ;
}
===============================================================================



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