from here : http://www.boost.org/doc/libs/1_53_0/doc/html/boost_asio/example/chat/chat_server.cpp
std::set<chat_participant_ptr> participants_;
....
participants_.insert(participant);
....
void deliver(const chat_message& msg, chat_participant_ptr participant)
{
recent_msgs_.push_back(msg);
while (recent_msgs_.size() > max_recent_msgs)
recent_msgs_.pop_front();
// I want to call the deliver method on all members of set except the participant passed to this function, how to do this?
std::for_each(participants_.begin(), participants_.end(),
boost::bind(&chat_participant::deliver, _1, boost::ref(msg)));
}
I want to call the deliver method on all members of set except the participant passed to this function, how to do this in vs2008?
A simple for loop using an iterator should do the trick.
std::set<chat_participant_ptr>::iterator iter;
for(iter = participants_.begin();iter != participants_.end();++iter)
{
if(participant != iter)
{
call deliver function on *iter
}
}