Boost logo

Boost :

From: Mac Murrett (mmurrett_at_[hidden])
Date: 2002-01-15 17:27:26


Hello, Boosters,

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.

Is there any interest in this?

Thanks,
Mac Murrett.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk