
I have created a new example to demonstrate BOOST_TBD_METATEST_ASSERT_* in action. The example is a safe_cast free function which can only be used in place of static_cast, if there is zero possibility that the value will be changed upon conversion. As you can see in examples/safecast/boosttest_safecast.cpp (available at https://github.com/icaretaker/Metatest), there is a complete set of unit tests, written for the function, which provide full regression testing for that function, without requiring a build system that inverts the result of a failed compile. Here is one such test: BOOST_AUTO_TEST_CASE(rhs_signed8) { uint8_t unsigned8 = 0; uint16_t unsigned16 = 0; uint32_t unsigned32 = 0; int8_t signed8 = 0; int16_t signed16 = 0; int32_t signed32 = 0; BOOST_CHECK_THROW( unsigned8 = safe_cast<uint8_t>(signed8);, metatest_exception ); BOOST_CHECK_THROW( unsigned16 = safe_cast<uint16_t>(signed8);, metatest_exception ); BOOST_CHECK_THROW( unsigned32 = safe_cast<uint32_t>(signed8);, metatest_exception ); BOOST_CHECK_NO_THROW( signed8 = safe_cast<int8_t>(signed8); ); BOOST_CHECK_NO_THROW( signed16 = safe_cast<int16_t>(signed8); ); BOOST_CHECK_NO_THROW( signed32 = safe_cast<int32_t>(signed8); ); } A potential improvement to safe_cast, would be to allow casts from integers to floating point numbers, provided the number of bits in the mantissa were sufficient to support the integer. This additional capability can now be developed which under the full protection of unit tests for the existing capability, and new unit tests can be written for the new feature. In the opinion of the Boost community, does this new capability stand on its own as useful, such that inclusion into Boost would be warranted? Thank you, Ben Robinson, Ph.D.