// BindDemo.cpp

// cl /EHsc /I \boost\boost_1_31_0 BindDemo.cpp

#include <iostream>
#include <vector>
#include <string>

#include <boost/tokenizer.hpp>
#include <boost/bind.hpp>

using namespace std;
using namespace boost;

class normalizer {
public:
  string normalize(const string& number) { 
    return string("+55 41 334 4") + number;
  }
};

class user {
public:
  bool set_attribute( const string& name, const string& value ) const {
    cout << "setting attribute <" << name << 
    "> with value <" << value << ">" << endl;
    return true;
  }

  void doit( const std::string& value ) {
    char_separator<char> sep(";");
    tokenizer< char_separator<char> > 
    tok( value, sep );
    normalizer n;

    for_each( tok.begin(), tok.end(), 
      bind( &user::set_attribute, 
      this, "NUMBER",
        bind( &normalizer::normalize, 
        &n, _1 )
      )
    );
  }
};

int main()
{
  user u;
  string vals = "123;456;678;890;";

  u.doit(vals);
}