ACE has a truncate_cast. It is mostly useful for optimizing code like the following:
foo_t bar = ...;
short baz;
if (bar > SHORT_MAX)
baz = SHORT_MAX;
else
baz = static_cast<short> (bar);
This could be replaced by:
foo_t bar = ...;
short baz = ACE_Utils::truncate_cast<short> (bar);
Depending on the underlying type of foo_t, truncate_cast will optimize away the if() statement entirely, and also address compiler diagnostics resulting from comparison of signed and unsigned types. The choice of which way to go is performed at compile-time through a template metaprogram.
Ideally one should not need such a cast/truncation if compatible types are used correctly but sometimes there's no getting around incompatible types when working with legacy interfaces, particularly with low level OS calls.
Note that it's easy to abuse such a cast, which is why the authors explictly state it is meant for internal use, and that the cast shouldn't be used to work around compiler diagnostics.