Thanks for your input. Unfortunately; no dice. It still doesn't
compile (below), and the error(also below) provides little insight in my
relatively inexperienced assessment. I have a feeling that the
enable_if mechanism is not behaving properly on my particular system.
(the fact that others have successfully compiled this implies that the
boost::function must have the correct signature to satisfy the
enable_if....)
----error
/usr/local/include/boost/asio/read_until.hpp: In instantiation of
`boost::asio::detail::has_result_type, bool>
()(boost::asio::buffers_iterator,
boost::asio::buffers_iterator)> >':
/usr/local/include/boost/asio/read_until.hpp:75: instantiated from
`boost::asio::is_match_condition, bool>
()(boost::asio::buffers_iterator,
boost::asio::buffers_iterator)> >'
/usr/local/include/boost/utility/enable_if.hpp:36: instantiated from
`boost::enable_if, bool>
()(boost::asio::buffers_iterator,
boost::asio::buffers_iterator)> >,
void>'
../src/temp.cpp:56: instantiated from here
/usr/local/include/boost/asio/read_until.hpp:60: error: call of
overloaded `helper(const
boost::function, bool>
()(boost::asio::buffers_iterator,
boost::asio::buffers_iterator)>&)'
is ambiguous
/usr/local/include/boost/asio/read_until.hpp:57: note: candidates are:
static boost::asio::detail::has_result_type<T>::big
boost::asio::detail::has_result_type<T>::helper(U, ...) [with U =
boost::function, bool>
()(boost::asio::buffers_iterator,
boost::asio::buffers_iterator)>, T =
boost::function, bool>
()(boost::asio::buffers_iterator,
boost::asio::buffers_iterator)>]
/usr/local/include/boost/asio/read_until.hpp:58: note:
static char boost::asio::detail::has_result_type<T>::helper(U, typename
U::result_type*) [with U =
boost::function, bool>
()(boost::asio::buffers_iterator,
boost::asio::buffers_iterator)>, T =
boost::function, bool>
()(boost::asio::buffers_iterator,
boost::asio::buffers_iterator)>]
/usr/local/include/boost/asio/read_until.hpp:60: error: enumerator value
for `value' not integer constant
../src/temp.cpp: In constructor `MyClass::MyClass()':
../src/temp.cpp:56: error: no matching function for call to
`read_until(boost::asio::serial_port&, boost::asio::streambuf&,
boost::function, bool>
()(boost::asio::buffers_iterator,
boost::asio::buffers_iterator)>&)'
----temp.cpp
#include
#include
#include
using namespace std;
class MyClass {
private:
boost::asio::serial_port _port;
boost::asio::io_service _service;
boost::asio::streambuf _readBuffer;
typedef
boost::asio::buffers_iteratorboost::asio::streambuf::const_buffers_type
t_Iterator;
typedef std::pair t_ConditionPair;
t_ConditionPair customCondition(t_Iterator i1, t_Iterator i2)
{
t_ConditionPair cond;
return cond;
}
public:
MyClass() :
_port(_service, "/dev/ttyS0")
{
boost::function cond =
boost::bind(
&MyClass::customCondition,
this,
_1,
_2
);
boost::asio::read_until(
_port,
_readBuffer,
cond
);
};
virtual ~MyClass()
{ };
};
On Sat, Feb 20, 2010 at 10:56 AM, Igor R mailto:boost.lists@gmail.com> wrote:
> 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?
It compiles well with MSVC9.0
As a workaround, try assigning the result of the bind to a
boost::function<> object of the appropriate type first, and then
passing that boost::function<> object by value into the asio method
Not sure if it will work, but if nothing else it might get the
compiler to give you a different error and you can figure something out.
------------------------------------------------------------------------
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users