Boost logo

Boost :

From: jk_at_[hidden]
Date: 2002-01-16 02:20:28


16 Jan 2002 06:52:11 +0300 Mac Murrett ÎÁÐÉÓÁÌ:
>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)); }

Then copying will occur. Wouldn't it be better to return by reference,
like below?

template<class Return_Type, class Argument_Type>
inline const Return_Type& force_cast(const Argument_Type &rSrc)
    { return(*reinterpret_cast<const Return_Type *>(&rSrc)); }

-- 
jk

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