Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:58:31

0001 //  (c) Copyright Fernando Luis Cacciola Carballal 2000-2004
0002 //  Use, modification, and distribution is subject to the Boost Software
0003 //  License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0004 //  http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 //  See library home page at http://www.boost.org/libs/numeric/conversion
0007 //
0008 // Contact the author at: fernando_cacciola@hotmail.com
0009 //
0010 //
0011 //  Revision History
0012 //
0013 //    19 Nov 2001 Syntatic changes as suggested by Darin Adler (Fernando Cacciola)
0014 //    08 Nov 2001 Fixes to accommodate MSVC (Fernando Cacciola)
0015 //    04 Nov 2001 Fixes to accommodate gcc2.92 (Fernando Cacciola)
0016 //    30 Oct 2001 Some fixes suggested by Daryle Walker (Fernando Cacciola)
0017 //    25 Oct 2001 Initial boostification (Fernando Cacciola)
0018 //    23 Jan 2004 Inital add to cvs (post review)s
0019 //    22 Jun 2011 Added support for specializing cast policies via numeric_cast_traits (Brandon Kohn).
0020 //
0021 #ifndef BOOST_NUMERIC_CONVERSION_CAST_25OCT2001_HPP
0022 #define BOOST_NUMERIC_CONVERSION_CAST_25OCT2001_HPP
0023 
0024 #include <boost/detail/workaround.hpp>
0025 
0026 #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x582))
0027 
0028 #  include<boost/numeric/conversion/detail/old_numeric_cast.hpp>
0029 
0030 #else
0031 
0032 #include <boost/type.hpp>
0033 #include <boost/numeric/conversion/converter.hpp>
0034 #include <boost/numeric/conversion/numeric_cast_traits.hpp>
0035 
0036 namespace boost
0037 {
0038     template <typename Target, typename Source> 
0039     inline Target numeric_cast( Source arg )
0040     {
0041         typedef numeric::conversion_traits<Target, Source>   conv_traits;
0042         typedef numeric::numeric_cast_traits<Target, Source> cast_traits;
0043         typedef boost::numeric::converter
0044             <
0045                 Target,
0046                 Source, 
0047                 conv_traits,
0048                 typename cast_traits::overflow_policy, 
0049                 typename cast_traits::rounding_policy, 
0050                 boost::numeric::raw_converter< conv_traits >,
0051                 typename cast_traits::range_checking_policy
0052             > converter;
0053         return converter::convert(arg);
0054     }
0055     
0056     using numeric::bad_numeric_cast;
0057 } // namespace boost
0058 
0059 #endif
0060 
0061 #endif