Skip to content
Snippets Groups Projects
Commit ffc35c33 authored by g0dil's avatar g0dil
Browse files

Fix bug in SocketPolicy::checkBaseOf

parent c29aec89
No related branches found
No related tags found
No related merge requests found
......@@ -41,7 +41,7 @@ checkBaseOf(SocketPolicyBase const & other)
// check, wether each policy of other is (dynamically!) convertible
// to the corresponding (static) policy of this class. Throws
// std::bad_cast on failure
# define SP_CheckPolicy(x1,x2,SomePolicy) (void) dynamic_cast<SomePolicy const &>(other.BOOST_PP_CAT(the,SomePolicy)());
# define SP_CheckPolicy(x1,x2,SomePolicy) (void) dynamic_cast<BOOST_PP_CAT(SomePolicy,_) const &>(other.BOOST_PP_CAT(the,SomePolicy)());
BOOST_PP_SEQ_FOR_EACH( SP_CheckPolicy, , SENF_SOCKET_POLICIES )
# undef SP_CheckPolicy
}
......
......@@ -83,7 +83,7 @@ namespace {
BOOST_AUTO_UNIT_TEST(socketPolicy)
{
// All these checks are really compile-time checks ...
// Most of these checks are really compile-time checks ...
typedef MakeSocketPolicy<
UnixAddressingPolicy,
......@@ -122,12 +122,22 @@ BOOST_AUTO_UNIT_TEST(socketPolicy)
// The following should fail at compile time
// BOOST_MPL_ASSERT(( SocketPolicyIsBaseOf<Policy1,Policy3> ));
ConvertibleValue<Policy1> p1;
ConvertibleValue<Policy3> p3(p1);
{
ConvertibleValue<Policy1> p1;
ConvertibleValue<Policy3> p3(p1);
p3 = p1;
// The following should fail at compile time
// p1 = p3;
}
{
Policy1 p1;
Policy3 p3;
p3 = p1;
// The following should fail at compile time
// p1 = p3;
BOOST_CHECK_THROW( Policy1::checkBaseOf(p3), std::bad_cast );
BOOST_CHECK_NO_THROW( Policy3::checkBaseOf(p1) );
}
}
///////////////////////////////cc.e////////////////////////////////////////
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment