Boost logo

Boost :

From: Darin Adler (darin_at_[hidden])
Date: 2002-01-15 17:30:23

On 1/15/02 2:27 PM, "Mac Murrett" <mmurrett_at_[hidden]> wrote:

> In a discussion with Bill Kempf about the Mac OS implementation of
> Boost.Threads, Bill suggested that a function that I had been using,
> force_cast<>, should either be hidden away in a detail namespace or split
> off onto its own. I am therefore proposing it as an addition to Boost, and
> will simply stuff it down to the bowels of boost::threads::detail::mac or
> something if nobody else sees value in it.
> Its purpose is to convert anything to anything, and it looks like this:
> // force_cast will convert anything to anything.
> template<class Return_Type, class Argument_Type>
> inline Return_Type force_cast(const Argument_Type &rSrc)
> { return(*reinterpret_cast<const Return_Type *>(&rSrc)); }
> I was using it to convert an UnsignedWide, which is a struct composed of two
> uint32_ts, to a uint64_t. This allowed for easier, more efficient math.

If you are doing this on Macintosh, is there a reason you can't use
UnsignedWideToUInt64 from <Math64.h>?

    -- Darin

Boost list run by bdawes at, gregod at, cpdaniel at, john at