Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/boost/implicit_cast.hpp @ 18

Last change on this file since 18 was 12, checked in by landauf, 17 years ago

added boost

  • Property svn:executable set to *
File size: 1.1 KB
Line 
1// Copyright David Abrahams 2003.
2// Distributed under the Boost Software License, Version 1.0. (See
3// accompanying file LICENSE_1_0.txt or copy at
4// http://www.boost.org/LICENSE_1_0.txt)
5#ifndef IMPLICIT_CAST_DWA200356_HPP
6# define IMPLICIT_CAST_DWA200356_HPP
7
8# include <boost/mpl/identity.hpp>
9
10namespace boost {
11
12// implementation originally suggested by C. Green in
13// http://lists.boost.org/MailArchives/boost/msg00886.php
14
15// The use of identity creates a non-deduced form, so that the
16// explicit template argument must be supplied
17template <typename T>
18inline T implicit_cast (typename mpl::identity<T>::type x) {
19    return x;
20}
21
22// incomplete return type now is here
23//template <typename T>
24//void implicit_cast (...);
25
26// Macro for when you need a constant expression (Gennaro Prota)
27#define BOOST_IMPLICIT_CAST(dst_type, expr)           \
28          ( sizeof( implicit_cast<dst_type>(expr) )   \
29                     ,                                \
30            static_cast<dst_type>(expr)               \
31          )
32
33} // namespace boost
34
35#endif // IMPLICIT_CAST_DWA200356_HPP
Note: See TracBrowser for help on using the repository browser.