// 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
}
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,
// 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////////////////////////////////////////