Rev | Line | |
---|
[857] | 1 | // Copyright (C) 2001-2003
|
---|
| 2 | // Mac Murrett
|
---|
| 3 | //
|
---|
| 4 | // Distributed under the Boost Software License, Version 1.0. (See
|
---|
| 5 | // accompanying file LICENSE_1_0.txt or copy at
|
---|
| 6 | // http://www.boost.org/LICENSE_1_0.txt)
|
---|
| 7 | //
|
---|
| 8 | // See http://www.boost.org for most recent version including documentation.
|
---|
| 9 |
|
---|
| 10 | #ifndef BOOST_FORCE_CAST_MJM012402_HPP
|
---|
| 11 | #define BOOST_FORCE_CAST_MJM012402_HPP
|
---|
| 12 |
|
---|
| 13 | #include <boost/thread/detail/config.hpp>
|
---|
| 14 |
|
---|
| 15 | namespace boost {
|
---|
| 16 | namespace detail {
|
---|
| 17 | namespace thread {
|
---|
| 18 |
|
---|
| 19 | // force_cast will convert anything to anything.
|
---|
| 20 |
|
---|
| 21 | // general case
|
---|
| 22 | template<class Return_Type, class Argument_Type>
|
---|
| 23 | inline Return_Type &force_cast(Argument_Type &rSrc)
|
---|
| 24 | {
|
---|
| 25 | return(*reinterpret_cast<Return_Type *>(&rSrc));
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | // specialization for const
|
---|
| 29 | template<class Return_Type, class Argument_Type>
|
---|
| 30 | inline const Return_Type &force_cast(const Argument_Type &rSrc)
|
---|
| 31 | {
|
---|
| 32 | return(*reinterpret_cast<const Return_Type *>(&rSrc));
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | } // namespace thread
|
---|
| 36 | } // namespace detail
|
---|
| 37 | } // namespace boost
|
---|
| 38 |
|
---|
| 39 | #endif // BOOST_FORCE_CAST_MJM012402_HPP
|
---|
Note: See
TracBrowser
for help on using the repository browser.