Boost logo

Boost Users :

Subject: [Boost-users] boost::asio::read_until w/ boost::function
From: marty (marty_at_[hidden])
Date: 2010-02-19 14:22:00


I'm having some trouble resolving the call to read_until
(see snippet below)

Is there some reason I am not be able to use a boost::function
as the MatchCondition object?

Thanks,
...m

_______________
[MyClass.h]
class MyClass {
...
typedef
boost::asio::buffers_iterator<boost::asio::streambuf::const_buffers_type>
t_Iterator;
typedef std::pair<t_Iterator, bool> t_ConditionPair;

boost::asio::serial_port _port;
boost::asio::streambuf _readBuffer;

t_ConditionPair myCondition(t_Iterator begin, t_Iterator end);
void doRead();
...
};

[MyClass.cpp]
MyClass::t_ConditionPair myCondition(t_Iterator begin, t_Iterator end)
{
    t_ConditionPair theCondition;
    theCondition.first = end;
    theCondition.second = true;
    return theCondition;
}

void MyClass::doRead() {
    ...
    boost::asio::read_until(
        _port,
        _readBuffer,
        boost::bind(
            &MyClass::myCondition,
            this,
            _1,
            _2
            )
        );
    ...
}


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