|
Boost : |
From: Berserker (berserker_r_at_[hidden])
Date: 2008-06-13 04:26:03
In my project (using asio) I have something like this:
void Foo::myCallback(const boost::system::error_code &e)
{
if(e == boost::asio::error::operation_aborted)
{
// bla bla...
}
}
This call is made across a shared dll and I notice that for a "strange" reason e == boost::asio::error::operation_aborted was always false.
I discover that when the temporary object boost::system::error_code is constructed from the constants boost::asio::error::operation_aborted the error_code's costructor take a pointer to a "error_category" and the comparison operator is (m_cat is an error_category pointer):
inline friend bool operator==( const error_code & lhs, const error_code & rhs )
{
return lhs.m_cat == rhs.m_cat && lhs.m_val == rhs.m_val;
}
In my situation (using shared modules) lhs.m_cat == rhs.m_cat points to differents memory regions (even if are of the same type "system_category") because of the static initialization in the function "get_system_category".
The problem exist in the comparison operator of error_category too:
bool operator==(const error_category & rhs) const { return this == &rhs; }
I suggest to change the comparison criteria (for example using an enumerated value)
_________________________________________________________________
Sai che con Messenger guardi la TV con i tuoi amici?
http://www.messenger.it/messengertv.html
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk