123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- #ifndef BOOST_CAST_HPP
- #define BOOST_CAST_HPP
- # include <boost/config.hpp>
- # include <boost/assert.hpp>
- # include <typeinfo>
- # include <boost/type.hpp>
- # include <boost/limits.hpp>
- # include <boost/detail/select_type.hpp>
- # if defined(BOOST_MSVC) && BOOST_MSVC < 1300
- # define BOOST_EXPLICIT_DEFAULT_TARGET , ::boost::type<Target>* = 0
- # else
- # define BOOST_EXPLICIT_DEFAULT_TARGET
- # endif
- namespace boost
- {
-
-
-
- template <class Target, class Source>
- inline Target polymorphic_cast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET)
- {
- Target tmp = dynamic_cast<Target>(x);
- if ( tmp == 0 ) throw std::bad_cast();
- return tmp;
- }
-
-
-
-
-
-
- template <class Target, class Source>
- inline Target polymorphic_downcast(Source* x BOOST_EXPLICIT_DEFAULT_TARGET)
- {
- BOOST_ASSERT( dynamic_cast<Target>(x) == x );
- return static_cast<Target>(x);
- }
- # undef BOOST_EXPLICIT_DEFAULT_TARGET
- }
- # include <boost/numeric/conversion/cast.hpp>
- #endif
|