Lucas Schatz - 2017-06-07

Hi, I'm trying to do some minor changes into void chat_room::deliver(const chat_message &msg) function, at the chat_server example code from boost examples.

At first I'm trying to change this line

//original code, works fine
typedef boost::shared_ptr<chat_participant> chat_participant_ptr;
std::set<chat_participant_ptr> participants_;
...
...
void chat_room::deliver(const chat_message &msg)
{
   std::for_each(participants_.begin(), participants_.end(),
                  **boost::bind(&chat_participant::deliver, _1, boost::ref(msg))**
                  );
}

but I just cannot split the for_each part, I tested some codes, but none worked (they compile and run, but chat_participant::deliver don't get to be executed!
here is the changed code:

void chat_room::deliver(const chat_message &msg)
{
//every loop interacts, but none executes the expected code
    for (auto &p : participants_){
        boost::bind(&chat_participant::deliver, boost::ref(p), boost::ref(msg));
     }

    for(chat_participant_ptr p : participants_) {
        boost::bind(&chat_participant::deliver, boost::ref(p), boost::ref(msg));
    }
    BOOST_FOREACH(chat_participant_ptr p , participants_){
        boost::bind(&chat_participant::deliver, p, boost::ref(msg));
    }

    std::for_each(participants_.begin(), participants_.end(), [msg, &_1](chat_participant_ptr p) {
        boost::bind(&chat_participant::deliver, boost::ref(p), boost::ref(msg));
                        }
                 );
}

Someone can help me?
Thanks!