Boost logo

Boost Users :

From: Eric MALENFANT (Eric.Malenfant_at_[hidden])
Date: 2007-04-16 17:15:56


boost-users-bounces_at_[hidden], le :
> Thanks Peter, this makes sense. But just image I cannot change the
> print function's interface. For example I have to interface with MFC's
> CComboBox::AddString( LPCTSTR lpszString ) . Do you think there is
> still a way to have just one for_each() loop? My guts tell me no.

A while ago, I posted a very similar question, which was not answered:
http://groups.google.ca/group/boost-list/browse_thread/thread/c24afb8e21
26fc88/b372145c0385d381?lnk=st&q=emalenfant+boost&rnum=1&hl=fr#b372145c0
385d381.

In there, I was asking for comments about 2 workarounds which, adapted
to your case would be:

1)
    var_type<std::string>::type temp(var(std::string()));

    std::for_each(
        begin, end,
        (
            temp = bind(&A::name, _1),
            bind(Print, bind(&std::string::c_str, temp))
        )
    );

2)
    var_type<std::string>::type temp(var(std::string()));

    std::for_each(
        begin, end,
        bind(Print,
            bind(&std::string::c_str,
                (temp = bind(&A::name, _1))
            )
        )
    );

Note that this is more "for fun" than, anything. None of these is very
elegant, or efficient...


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