diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-06-01 08:48:42 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-06-01 09:24:28 (GMT) |
commit | 2812bddd81f8a1b804c7460f4e14cd0aa393d129 (patch) | |
tree | d46294f35150c4f0f43deaf2d31fceaf945ae715 /3rdParty/Boost/boost/numeric/conversion/detail | |
download | swift-2812bddd81f8a1b804c7460f4e14cd0aa393d129.zip swift-2812bddd81f8a1b804c7460f4e14cd0aa393d129.tar.bz2 |
Import.
Diffstat (limited to '3rdParty/Boost/boost/numeric/conversion/detail')
9 files changed, 1663 insertions, 0 deletions
diff --git a/3rdParty/Boost/boost/numeric/conversion/detail/bounds.hpp b/3rdParty/Boost/boost/numeric/conversion/detail/bounds.hpp new file mode 100644 index 0000000..67342b8 --- /dev/null +++ b/3rdParty/Boost/boost/numeric/conversion/detail/bounds.hpp @@ -0,0 +1,58 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_BOUNDS_DETAIL_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_BOUNDS_DETAIL_FLC_12NOV2002_HPP + +#include "boost/limits.hpp" +#include "boost/config.hpp" +#include "boost/mpl/if.hpp" + +namespace boost { namespace numeric { namespace boundsdetail +{ + template<class N> + class Integral + { + typedef std::numeric_limits<N> limits ; + + public : + + static N lowest () { return limits::min BOOST_PREVENT_MACRO_SUBSTITUTION (); } + static N highest () { return limits::max BOOST_PREVENT_MACRO_SUBSTITUTION (); } + static N smallest() { return static_cast<N>(1); } + } ; + + template<class N> + class Float + { + typedef std::numeric_limits<N> limits ; + + public : + + static N lowest () { return static_cast<N>(-limits::max BOOST_PREVENT_MACRO_SUBSTITUTION ()) ; } + static N highest () { return limits::max BOOST_PREVENT_MACRO_SUBSTITUTION (); } + static N smallest() { return limits::min BOOST_PREVENT_MACRO_SUBSTITUTION (); } + } ; + + template<class N> + struct get_impl + { + typedef mpl::bool_< ::std::numeric_limits<N>::is_integer > is_int ; + + typedef Integral<N> impl_int ; + typedef Float <N> impl_float ; + + typedef typename mpl::if_<is_int,impl_int,impl_float>::type type ; + } ; + +} } } // namespace boost::numeric::boundsdetail. + +#endif +// +/////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/3rdParty/Boost/boost/numeric/conversion/detail/conversion_traits.hpp b/3rdParty/Boost/boost/numeric/conversion/detail/conversion_traits.hpp new file mode 100644 index 0000000..ed25349 --- /dev/null +++ b/3rdParty/Boost/boost/numeric/conversion/detail/conversion_traits.hpp @@ -0,0 +1,97 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_DETAIL_CONVERSION_TRAITS_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_DETAIL_CONVERSION_TRAITS_FLC_12NOV2002_HPP + +#include "boost/type_traits/is_arithmetic.hpp" +#include "boost/type_traits/is_same.hpp" +#include "boost/type_traits/remove_cv.hpp" + +#include "boost/numeric/conversion/detail/meta.hpp" +#include "boost/numeric/conversion/detail/int_float_mixture.hpp" +#include "boost/numeric/conversion/detail/sign_mixture.hpp" +#include "boost/numeric/conversion/detail/udt_builtin_mixture.hpp" +#include "boost/numeric/conversion/detail/is_subranged.hpp" + +namespace boost { namespace numeric { namespace convdetail +{ + //------------------------------------------------------------------- + // Implementation of the Conversion Traits for T != S + // + // This is a VISIBLE base class of the user-level conversion_traits<> class. + //------------------------------------------------------------------- + template<class T,class S> + struct non_trivial_traits_impl + { + typedef typename get_int_float_mixture <T,S>::type int_float_mixture ; + typedef typename get_sign_mixture <T,S>::type sign_mixture ; + typedef typename get_udt_builtin_mixture <T,S>::type udt_builtin_mixture ; + + typedef typename get_is_subranged<T,S>::type subranged ; + + typedef mpl::false_ trivial ; + + typedef T target_type ; + typedef S source_type ; + typedef T result_type ; + + typedef typename mpl::if_< is_arithmetic<S>, S, S const&>::type argument_type ; + + typedef typename mpl::if_<subranged,S,T>::type supertype ; + typedef typename mpl::if_<subranged,T,S>::type subtype ; + } ; + + //------------------------------------------------------------------- + // Implementation of the Conversion Traits for T == S + // + // This is a VISIBLE base class of the user-level conversion_traits<> class. + //------------------------------------------------------------------- + template<class N> + struct trivial_traits_impl + { + typedef typename get_int_float_mixture <N,N>::type int_float_mixture ; + typedef typename get_sign_mixture <N,N>::type sign_mixture ; + typedef typename get_udt_builtin_mixture<N,N>::type udt_builtin_mixture ; + + typedef mpl::false_ subranged ; + typedef mpl::true_ trivial ; + + typedef N target_type ; + typedef N source_type ; + typedef N const& result_type ; + typedef N const& argument_type ; + + typedef N supertype ; + typedef N subtype ; + + } ; + + //------------------------------------------------------------------- + // Top level implementation selector. + //------------------------------------------------------------------- + template<class T, class S> + struct get_conversion_traits + { + typedef typename remove_cv<T>::type target_type ; + typedef typename remove_cv<S>::type source_type ; + + typedef typename is_same<target_type,source_type>::type is_trivial ; + + typedef trivial_traits_impl <target_type> trivial_imp ; + typedef non_trivial_traits_impl<target_type,source_type> non_trivial_imp ; + + typedef typename mpl::if_<is_trivial,trivial_imp,non_trivial_imp>::type type ; + } ; + +} } } // namespace boost::numeric::convdetail + +#endif + + diff --git a/3rdParty/Boost/boost/numeric/conversion/detail/converter.hpp b/3rdParty/Boost/boost/numeric/conversion/detail/converter.hpp new file mode 100644 index 0000000..10550f8 --- /dev/null +++ b/3rdParty/Boost/boost/numeric/conversion/detail/converter.hpp @@ -0,0 +1,602 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_DETAIL_CONVERTER_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_DETAIL_CONVERTER_FLC_12NOV2002_HPP + +#include <functional> + +#include "boost/numeric/conversion/detail/meta.hpp" +#include "boost/numeric/conversion/detail/conversion_traits.hpp" +#include "boost/numeric/conversion/bounds.hpp" + +#include "boost/type_traits/is_same.hpp" + +#include "boost/mpl/integral_c.hpp" + +namespace boost { namespace numeric { namespace convdetail +{ + // Integral Constants representing rounding modes + typedef mpl::integral_c<std::float_round_style, std::round_toward_zero> round2zero_c ; + typedef mpl::integral_c<std::float_round_style, std::round_to_nearest> round2nearest_c ; + typedef mpl::integral_c<std::float_round_style, std::round_toward_infinity> round2inf_c ; + typedef mpl::integral_c<std::float_round_style, std::round_toward_neg_infinity> round2neg_inf_c ; + + // Metafunction: + // + // for_round_style<RoundStyle,RoundToZero,RoundToNearest,RoundToInf,RoundToNegInf>::type + // + // {RoundStyle} Integral Constant specifying a round style as declared above. + // {RoundToZero,RoundToNearest,RoundToInf,RoundToNegInf} arbitrary types. + // + // Selects one of the 4 types according to the value of RoundStyle. + // + template<class RoundStyle,class RoundToZero,class RoundToNearest,class RoundToInf,class RoundToNegInf> + struct for_round_style + { + typedef ct_switch4<RoundStyle + , round2zero_c, round2nearest_c, round2inf_c // round2neg_inf_c + , RoundToZero , RoundToNearest , RoundToInf , RoundToNegInf + > selector ; + + typedef typename selector::type type ; + } ; + + + + + + + + + + + + + + + + + + +//-------------------------------------------------------------------------- +// Range Checking Logic. +// +// The range checking logic is built up by combining 1 or 2 predicates. +// Each predicate is encapsulated in a template class and exposes +// the static member function 'apply'. +// +//-------------------------------------------------------------------------- + + + // Because a particular logic can combine either 1 or two predicates, the following + // tags are used to allow the predicate applier to receive 2 preds, but optimize away + // one of them if it is 'non-applicable' + struct non_applicable { typedef mpl::false_ do_apply ; } ; + struct applicable { typedef mpl::true_ do_apply ; } ; + + + //-------------------------------------------------------------------------- + // + // Range Checking Logic implementations. + // + // The following classes, collectivelly named 'Predicates', are instantiated within + // the corresponding range checkers. + // Their static member function 'apply' is called to perform the actual range checking logic. + //-------------------------------------------------------------------------- + + // s < Lowest(T) ? cNegOverflow : cInRange + // + template<class Traits> + struct LT_LoT : applicable + { + typedef typename Traits::target_type T ; + typedef typename Traits::source_type S ; + typedef typename Traits::argument_type argument_type ; + + static range_check_result apply ( argument_type s ) + { + return s < static_cast<S>(bounds<T>::lowest()) ? cNegOverflow : cInRange ; + } + } ; + + // s < 0 ? cNegOverflow : cInRange + // + template<class Traits> + struct LT_Zero : applicable + { + typedef typename Traits::source_type S ; + typedef typename Traits::argument_type argument_type ; + + static range_check_result apply ( argument_type s ) + { + return s < static_cast<S>(0) ? cNegOverflow : cInRange ; + } + } ; + + // s <= Lowest(T)-1 ? cNegOverflow : cInRange + // + template<class Traits> + struct LE_PrevLoT : applicable + { + typedef typename Traits::target_type T ; + typedef typename Traits::source_type S ; + typedef typename Traits::argument_type argument_type ; + + static range_check_result apply ( argument_type s ) + { + return s <= static_cast<S>(bounds<T>::lowest()) - static_cast<S>(1.0) + ? cNegOverflow : cInRange ; + } + } ; + + // s < Lowest(T)-0.5 ? cNegOverflow : cInRange + // + template<class Traits> + struct LT_HalfPrevLoT : applicable + { + typedef typename Traits::target_type T ; + typedef typename Traits::source_type S ; + typedef typename Traits::argument_type argument_type ; + + static range_check_result apply ( argument_type s ) + { + return s < static_cast<S>(bounds<T>::lowest()) - static_cast<S>(0.5) + ? cNegOverflow : cInRange ; + } + } ; + + // s > Highest(T) ? cPosOverflow : cInRange + // + template<class Traits> + struct GT_HiT : applicable + { + typedef typename Traits::target_type T ; + typedef typename Traits::source_type S ; + typedef typename Traits::argument_type argument_type ; + + static range_check_result apply ( argument_type s ) + { + return s > static_cast<S>(bounds<T>::highest()) + ? cPosOverflow : cInRange ; + } + } ; + + // s >= Lowest(T) + 1 ? cPosOverflow : cInRange + // + template<class Traits> + struct GE_SuccHiT : applicable + { + typedef typename Traits::target_type T ; + typedef typename Traits::source_type S ; + typedef typename Traits::argument_type argument_type ; + + static range_check_result apply ( argument_type s ) + { + return s >= static_cast<S>(bounds<T>::highest()) + static_cast<S>(1.0) + ? cPosOverflow : cInRange ; + } + } ; + + // s >= Lowest(T) + 0.5 ? cPosgOverflow : cInRange + // + template<class Traits> + struct GT_HalfSuccHiT : applicable + { + typedef typename Traits::target_type T ; + typedef typename Traits::source_type S ; + typedef typename Traits::argument_type argument_type ; + + static range_check_result apply ( argument_type s ) + { + return s >= static_cast<S>(bounds<T>::highest()) + static_cast<S>(0.5) + ? cPosOverflow : cInRange ; + } + } ; + + + //-------------------------------------------------------------------------- + // + // Predicate Combiner. + // + // This helper classes are used to possibly combine the range checking logic + // individually performed by the predicates + // + //-------------------------------------------------------------------------- + + + // Applies both predicates: first 'PredA', and if it equals 'cInRange', 'PredB' + template<class PredA, class PredB> + struct applyBoth + { + typedef typename PredA::argument_type argument_type ; + + static range_check_result apply ( argument_type s ) + { + range_check_result r = PredA::apply(s) ; + if ( r == cInRange ) + r = PredB::apply(s); + return r ; + } + } ; + + template<class PredA, class PredB> + struct combine + { + typedef applyBoth<PredA,PredB> Both ; + typedef void NNone ; // 'None' is defined as a macro in (/usr/X11R6/include/X11/X.h) + + typedef typename PredA::do_apply do_applyA ; + typedef typename PredB::do_apply do_applyB ; + + typedef typename for_both<do_applyA, do_applyB, Both, PredA, PredB, NNone>::type type ; + } ; + + + + + + + + + + + + +//-------------------------------------------------------------------------- +// Range Checker classes. +// +// The following classes are VISIBLE base classes of the user-level converter<> class. +// They supply the optimized 'out_of_range()' and 'validate_range()' static member functions +// visible in the user interface. +// +//-------------------------------------------------------------------------- + + // Dummy range checker. + template<class Traits> + struct dummy_range_checker + { + typedef typename Traits::argument_type argument_type ; + + static range_check_result out_of_range ( argument_type ) { return cInRange ; } + static void validate_range ( argument_type ) {} + } ; + + // Generic range checker. + // + // All the range checking logic for all possible combinations of source and target + // can be arranged in terms of one or two predicates, which test overflow on both neg/pos 'sides' + // of the ranges. + // + // These predicates are given here as IsNegOverflow and IsPosOverflow. + // + template<class Traits, class IsNegOverflow, class IsPosOverflow, class OverflowHandler> + struct generic_range_checker + { + typedef OverflowHandler overflow_handler ; + + typedef typename Traits::argument_type argument_type ; + + static range_check_result out_of_range ( argument_type s ) + { + typedef typename combine<IsNegOverflow,IsPosOverflow>::type Predicate ; + + return Predicate::apply(s); + } + + static void validate_range ( argument_type s ) + { OverflowHandler()( out_of_range(s) ) ; } + } ; + + + +//-------------------------------------------------------------------------- +// +// Selectors for the optimized Range Checker class. +// +//-------------------------------------------------------------------------- + + template<class Traits,class OverflowHandler> + struct GetRC_Sig2Sig_or_Unsig2Unsig + { + typedef dummy_range_checker<Traits> Dummy ; + + typedef LT_LoT<Traits> Pred1 ; + typedef GT_HiT<Traits> Pred2 ; + + typedef generic_range_checker<Traits,Pred1,Pred2,OverflowHandler> Normal ; + + typedef typename Traits::subranged subranged ; + + typedef typename mpl::if_<subranged,Normal,Dummy>::type type ; + } ; + + template<class Traits, class OverflowHandler> + struct GetRC_Sig2Unsig + { + typedef LT_Zero<Traits> Pred1 ; + typedef GT_HiT <Traits> Pred2 ; + + typedef generic_range_checker<Traits,Pred1,Pred2,OverflowHandler> ChoiceA ; + + typedef generic_range_checker<Traits,Pred1,non_applicable,OverflowHandler> ChoiceB ; + + typedef typename Traits::target_type T ; + typedef typename Traits::source_type S ; + + typedef typename subranged_Unsig2Sig<S,T>::type oposite_subranged ; + + typedef typename mpl::not_<oposite_subranged>::type positively_subranged ; + + typedef typename mpl::if_<positively_subranged,ChoiceA,ChoiceB>::type type ; + } ; + + template<class Traits, class OverflowHandler> + struct GetRC_Unsig2Sig + { + typedef GT_HiT<Traits> Pred1 ; + + typedef generic_range_checker<Traits,non_applicable,Pred1,OverflowHandler> type ; + } ; + + template<class Traits,class OverflowHandler> + struct GetRC_Int2Int + { + typedef GetRC_Sig2Sig_or_Unsig2Unsig<Traits,OverflowHandler> Sig2SigQ ; + typedef GetRC_Sig2Unsig <Traits,OverflowHandler> Sig2UnsigQ ; + typedef GetRC_Unsig2Sig <Traits,OverflowHandler> Unsig2SigQ ; + typedef Sig2SigQ Unsig2UnsigQ ; + + typedef typename Traits::sign_mixture sign_mixture ; + + typedef typename + for_sign_mixture<sign_mixture,Sig2SigQ,Sig2UnsigQ,Unsig2SigQ,Unsig2UnsigQ>::type + selector ; + + typedef typename selector::type type ; + } ; + + template<class Traits> + struct GetRC_Int2Float + { + typedef dummy_range_checker<Traits> type ; + } ; + + template<class Traits, class OverflowHandler, class Float2IntRounder> + struct GetRC_Float2Int + { + typedef LE_PrevLoT <Traits> Pred1 ; + typedef GE_SuccHiT <Traits> Pred2 ; + typedef LT_HalfPrevLoT<Traits> Pred3 ; + typedef GT_HalfSuccHiT<Traits> Pred4 ; + typedef GT_HiT <Traits> Pred5 ; + typedef LT_LoT <Traits> Pred6 ; + + typedef generic_range_checker<Traits,Pred1,Pred2,OverflowHandler> ToZero ; + typedef generic_range_checker<Traits,Pred3,Pred4,OverflowHandler> ToNearest ; + typedef generic_range_checker<Traits,Pred1,Pred5,OverflowHandler> ToInf ; + typedef generic_range_checker<Traits,Pred6,Pred2,OverflowHandler> ToNegInf ; + + typedef typename Float2IntRounder::round_style round_style ; + + typedef typename for_round_style<round_style,ToZero,ToNearest,ToInf,ToNegInf>::type type ; + } ; + + template<class Traits, class OverflowHandler> + struct GetRC_Float2Float + { + typedef dummy_range_checker<Traits> Dummy ; + + typedef LT_LoT<Traits> Pred1 ; + typedef GT_HiT<Traits> Pred2 ; + + typedef generic_range_checker<Traits,Pred1,Pred2,OverflowHandler> Normal ; + + typedef typename Traits::subranged subranged ; + + typedef typename mpl::if_<subranged,Normal,Dummy>::type type ; + } ; + + template<class Traits, class OverflowHandler, class Float2IntRounder> + struct GetRC_BuiltIn2BuiltIn + { + typedef GetRC_Int2Int<Traits,OverflowHandler> Int2IntQ ; + typedef GetRC_Int2Float<Traits> Int2FloatQ ; + typedef GetRC_Float2Int<Traits,OverflowHandler,Float2IntRounder> Float2IntQ ; + typedef GetRC_Float2Float<Traits,OverflowHandler> Float2FloatQ ; + + typedef typename Traits::int_float_mixture int_float_mixture ; + + typedef typename for_int_float_mixture<int_float_mixture, Int2IntQ, Int2FloatQ, Float2IntQ, Float2FloatQ>::type selector ; + + typedef typename selector::type type ; + } ; + + template<class Traits, class OverflowHandler, class Float2IntRounder> + struct GetRC + { + typedef GetRC_BuiltIn2BuiltIn<Traits,OverflowHandler,Float2IntRounder> BuiltIn2BuiltInQ ; + + typedef dummy_range_checker<Traits> Dummy ; + + typedef mpl::identity<Dummy> DummyQ ; + + typedef typename Traits::udt_builtin_mixture udt_builtin_mixture ; + + typedef typename for_udt_builtin_mixture<udt_builtin_mixture,BuiltIn2BuiltInQ,DummyQ,DummyQ,DummyQ>::type selector ; + + typedef typename selector::type type ; + } ; + + + + +//-------------------------------------------------------------------------- +// Converter classes. +// +// The following classes are VISIBLE base classes of the user-level converter<> class. +// They supply the optimized 'nearbyint()' and 'convert()' static member functions +// visible in the user interface. +// +//-------------------------------------------------------------------------- + + // + // Trivial Converter : used when (cv-unqualified) T == (cv-unqualified) S + // + template<class Traits> + struct trivial_converter_impl : public std::unary_function< BOOST_DEDUCED_TYPENAME Traits::argument_type + ,BOOST_DEDUCED_TYPENAME Traits::result_type + > + ,public dummy_range_checker<Traits> + { + typedef Traits traits ; + + typedef typename Traits::source_type source_type ; + typedef typename Traits::argument_type argument_type ; + typedef typename Traits::result_type result_type ; + + static result_type low_level_convert ( argument_type s ) { return s ; } + static source_type nearbyint ( argument_type s ) { return s ; } + static result_type convert ( argument_type s ) { return s ; } + } ; + + + // + // Rounding Converter : used for float to integral conversions. + // + template<class Traits,class RangeChecker,class RawConverter,class Float2IntRounder> + struct rounding_converter : public std::unary_function< BOOST_DEDUCED_TYPENAME Traits::argument_type + ,BOOST_DEDUCED_TYPENAME Traits::result_type + > + ,public RangeChecker + ,public Float2IntRounder + ,public RawConverter + { + typedef RangeChecker RangeCheckerBase ; + typedef Float2IntRounder Float2IntRounderBase ; + typedef RawConverter RawConverterBase ; + + typedef Traits traits ; + + typedef typename Traits::source_type source_type ; + typedef typename Traits::argument_type argument_type ; + typedef typename Traits::result_type result_type ; + + static result_type convert ( argument_type s ) + { + RangeCheckerBase::validate_range(s); + source_type s1 = Float2IntRounderBase::nearbyint(s); + return RawConverterBase::low_level_convert(s1); + } + } ; + + + // + // Non-Rounding Converter : used for all other conversions. + // + template<class Traits,class RangeChecker,class RawConverter> + struct non_rounding_converter : public std::unary_function< BOOST_DEDUCED_TYPENAME Traits::argument_type + ,BOOST_DEDUCED_TYPENAME Traits::result_type + > + ,public RangeChecker + ,public RawConverter + { + typedef RangeChecker RangeCheckerBase ; + typedef RawConverter RawConverterBase ; + + typedef Traits traits ; + + typedef typename Traits::source_type source_type ; + typedef typename Traits::argument_type argument_type ; + typedef typename Traits::result_type result_type ; + + static source_type nearbyint ( argument_type s ) { return s ; } + + static result_type convert ( argument_type s ) + { + RangeCheckerBase::validate_range(s); + return RawConverterBase::low_level_convert(s); + } + } ; + + + + +//-------------------------------------------------------------------------- +// +// Selectors for the optimized Converter class. +// +//-------------------------------------------------------------------------- + + template<class Traits,class OverflowHandler,class Float2IntRounder,class RawConverter, class UserRangeChecker> + struct get_non_trivial_converter + { + typedef GetRC<Traits,OverflowHandler,Float2IntRounder> InternalRangeCheckerQ ; + + typedef is_same<UserRangeChecker,UseInternalRangeChecker> use_internal_RC ; + + typedef mpl::identity<UserRangeChecker> UserRangeCheckerQ ; + + typedef typename + mpl::eval_if<use_internal_RC,InternalRangeCheckerQ,UserRangeCheckerQ>::type + RangeChecker ; + + typedef non_rounding_converter<Traits,RangeChecker,RawConverter> NonRounding ; + typedef rounding_converter<Traits,RangeChecker,RawConverter,Float2IntRounder> Rounding ; + + typedef mpl::identity<NonRounding> NonRoundingQ ; + typedef mpl::identity<Rounding> RoundingQ ; + + typedef typename Traits::int_float_mixture int_float_mixture ; + + typedef typename + for_int_float_mixture<int_float_mixture, NonRoundingQ, NonRoundingQ, RoundingQ, NonRoundingQ>::type + selector ; + + typedef typename selector::type type ; + } ; + + template< class Traits + ,class OverflowHandler + ,class Float2IntRounder + ,class RawConverter + ,class UserRangeChecker + > + struct get_converter_impl + { +#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT( 0x0561 ) ) + // bcc55 prefers sometimes template parameters to be explicit local types. + // (notice that is is illegal to reuse the names like this) + typedef Traits Traits ; + typedef OverflowHandler OverflowHandler ; + typedef Float2IntRounder Float2IntRounder ; + typedef RawConverter RawConverter ; + typedef UserRangeChecker UserRangeChecker ; +#endif + + typedef trivial_converter_impl<Traits> Trivial ; + typedef mpl::identity <Trivial> TrivialQ ; + + typedef get_non_trivial_converter< Traits + ,OverflowHandler + ,Float2IntRounder + ,RawConverter + ,UserRangeChecker + > NonTrivialQ ; + + typedef typename Traits::trivial trivial ; + + typedef typename mpl::eval_if<trivial,TrivialQ,NonTrivialQ>::type type ; + } ; + +} } } // namespace boost::numeric::convdetail + +#endif + + diff --git a/3rdParty/Boost/boost/numeric/conversion/detail/int_float_mixture.hpp b/3rdParty/Boost/boost/numeric/conversion/detail/int_float_mixture.hpp new file mode 100644 index 0000000..464e527 --- /dev/null +++ b/3rdParty/Boost/boost/numeric/conversion/detail/int_float_mixture.hpp @@ -0,0 +1,72 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_DETAIL_INT_FLOAT_MIXTURE_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_DETAIL_INT_FLOAT_MIXTURE_FLC_12NOV2002_HPP + +#include "boost/config.hpp" +#include "boost/limits.hpp" + +#include "boost/numeric/conversion/int_float_mixture_enum.hpp" +#include "boost/numeric/conversion/detail/meta.hpp" + +#include "boost/mpl/integral_c.hpp" + +namespace boost { namespace numeric { namespace convdetail +{ + // Integral Constants for 'IntFloatMixture' + typedef mpl::integral_c<int_float_mixture_enum, integral_to_integral> int2int_c ; + typedef mpl::integral_c<int_float_mixture_enum, integral_to_float> int2float_c ; + typedef mpl::integral_c<int_float_mixture_enum, float_to_integral> float2int_c ; + typedef mpl::integral_c<int_float_mixture_enum, float_to_float> float2float_c ; + + // Metafunction: + // + // get_int_float_mixture<T,S>::type + // + // Selects the appropriate Int-Float Mixture Integral Constant for the combination T,S. + // + template<class T,class S> + struct get_int_float_mixture + { + typedef mpl::bool_< ::std::numeric_limits<S>::is_integer > S_int ; + typedef mpl::bool_< ::std::numeric_limits<T>::is_integer > T_int ; + + typedef typename + for_both<S_int, T_int, int2int_c, int2float_c, float2int_c, float2float_c>::type + type ; + } ; + + // Metafunction: + // + // for_int_float_mixture<Mixture,int_int,int_float,float_int,float_float>::type + // + // {Mixture} is one of the Integral Constants for Mixture, declared above. + // {int_int,int_float,float_int,float_float} are aribtrary types. (not metafunctions) + // + // According to the value of 'IntFloatMixture', selects the corresponding type. + // + template<class IntFloatMixture, class Int2Int, class Int2Float, class Float2Int, class Float2Float> + struct for_int_float_mixture + { + typedef typename + ct_switch4<IntFloatMixture + ,int2int_c, int2float_c, float2int_c // default + ,Int2Int , Int2Float , Float2Int , Float2Float + >::type + type ; + } ; + +} } } // namespace boost::numeric::convdetail + +#endif +// +/////////////////////////////////////////////////////////////////////////////////////////////// + + diff --git a/3rdParty/Boost/boost/numeric/conversion/detail/is_subranged.hpp b/3rdParty/Boost/boost/numeric/conversion/detail/is_subranged.hpp new file mode 100644 index 0000000..b5e7fe8 --- /dev/null +++ b/3rdParty/Boost/boost/numeric/conversion/detail/is_subranged.hpp @@ -0,0 +1,234 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_DETAIL_IS_SUBRANGED_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_DETAIL_IS_SUBRANGED_FLC_12NOV2002_HPP + +#include "boost/config.hpp" +#include "boost/limits.hpp" + +#include "boost/mpl/int.hpp" +#include "boost/mpl/multiplies.hpp" +#include "boost/mpl/less.hpp" +#include "boost/mpl/equal_to.hpp" + +#include "boost/type_traits/is_same.hpp" + +#include "boost/numeric/conversion/detail/meta.hpp" +#include "boost/numeric/conversion/detail/int_float_mixture.hpp" +#include "boost/numeric/conversion/detail/sign_mixture.hpp" +#include "boost/numeric/conversion/detail/udt_builtin_mixture.hpp" + +namespace boost { namespace numeric { namespace convdetail +{ + //--------------------------------------------------------------- + // Implementations of the compile time predicate "T is subranged" + //--------------------------------------------------------------- + + // for integral to integral conversions + template<class T,class S> + struct subranged_Sig2Unsig + { + // Signed to unsigned conversions are 'subranged' because of possible loose + // of negative values. + typedef mpl::true_ type ; + } ; + + // for unsigned integral to signed integral conversions + template<class T,class S> + struct subranged_Unsig2Sig + { + // IMPORTANT NOTE: + // + // This code assumes that signed/unsigned integral values are represented + // such that: + // + // numeric_limits<signed T>::digits + 1 == numeric_limits<unsigned T>::digits + // + // The '+1' is required since numeric_limits<>::digits gives 1 bit less for signed integral types. + // + // This fact is used by the following logic: + // + // if ( (numeric_limits<T>::digits+1) < (2*numeric_limits<S>::digits) ) + // then the conversion is subranged. + // + + typedef mpl::int_< ::std::numeric_limits<S>::digits > S_digits ; + typedef mpl::int_< ::std::numeric_limits<T>::digits > T_digits ; + + // T is signed, so take digits+1 + typedef typename T_digits::next u_T_digits ; + + typedef mpl::int_<2> Two ; + + typedef typename mpl::multiplies<S_digits,Two>::type S_digits_times_2 ; + + typedef typename mpl::less<u_T_digits,S_digits_times_2>::type type ; + } ; + + // for integral to integral conversions of the same sign. + template<class T,class S> + struct subranged_SameSign + { + // An integral conversion of the same sign is subranged if digits(T) < digits(S). + + typedef mpl::int_< ::std::numeric_limits<S>::digits > S_digits ; + typedef mpl::int_< ::std::numeric_limits<T>::digits > T_digits ; + + typedef typename mpl::less<T_digits,S_digits>::type type ; + } ; + + // for integral to float conversions + template<class T,class S> + struct subranged_Int2Float + { + typedef mpl::false_ type ; + } ; + + // for float to integral conversions + template<class T,class S> + struct subranged_Float2Int + { + typedef mpl::true_ type ; + } ; + + // for float to float conversions + template<class T,class S> + struct subranged_Float2Float + { + // If both T and S are floats, + // compare exponent bits and if they match, mantisa bits. + + typedef mpl::int_< ::std::numeric_limits<S>::digits > S_mantisa ; + typedef mpl::int_< ::std::numeric_limits<T>::digits > T_mantisa ; + + typedef mpl::int_< ::std::numeric_limits<S>::max_exponent > S_exponent ; + typedef mpl::int_< ::std::numeric_limits<T>::max_exponent > T_exponent ; + + typedef typename mpl::less<T_exponent,S_exponent>::type T_smaller_exponent ; + + typedef typename mpl::equal_to<T_exponent,S_exponent>::type equal_exponents ; + + typedef mpl::less<T_mantisa,S_mantisa> T_smaller_mantisa ; + + typedef mpl::eval_if<equal_exponents,T_smaller_mantisa,mpl::false_> not_bigger_exponent_case ; + + typedef typename + mpl::eval_if<T_smaller_exponent,mpl::true_,not_bigger_exponent_case>::type + type ; + } ; + + // for Udt to built-in conversions + template<class T,class S> + struct subranged_Udt2BuiltIn + { + typedef mpl::true_ type ; + } ; + + // for built-in to Udt conversions + template<class T,class S> + struct subranged_BuiltIn2Udt + { + typedef mpl::false_ type ; + } ; + + // for Udt to Udt conversions + template<class T,class S> + struct subranged_Udt2Udt + { + typedef mpl::false_ type ; + } ; + + //------------------------------------------------------------------- + // Selectors for the implementations of the subranged predicate + //------------------------------------------------------------------- + + template<class T,class S> + struct get_subranged_Int2Int + { + typedef subranged_SameSign<T,S> Sig2Sig ; + typedef subranged_Sig2Unsig<T,S> Sig2Unsig ; + typedef subranged_Unsig2Sig<T,S> Unsig2Sig ; + typedef Sig2Sig Unsig2Unsig ; + + typedef typename get_sign_mixture<T,S>::type sign_mixture ; + + typedef typename + for_sign_mixture<sign_mixture, Sig2Sig, Sig2Unsig, Unsig2Sig, Unsig2Unsig>::type + type ; + } ; + + template<class T,class S> + struct get_subranged_BuiltIn2BuiltIn + { + typedef get_subranged_Int2Int<T,S> Int2IntQ ; + + typedef subranged_Int2Float <T,S> Int2Float ; + typedef subranged_Float2Int <T,S> Float2Int ; + typedef subranged_Float2Float<T,S> Float2Float ; + + typedef mpl::identity<Int2Float > Int2FloatQ ; + typedef mpl::identity<Float2Int > Float2IntQ ; + typedef mpl::identity<Float2Float> Float2FloatQ ; + + typedef typename get_int_float_mixture<T,S>::type int_float_mixture ; + + typedef for_int_float_mixture<int_float_mixture, Int2IntQ, Int2FloatQ, Float2IntQ, Float2FloatQ> for_ ; + + typedef typename for_::type selected ; + + typedef typename selected::type type ; + } ; + + template<class T,class S> + struct get_subranged + { + typedef get_subranged_BuiltIn2BuiltIn<T,S> BuiltIn2BuiltInQ ; + + typedef subranged_BuiltIn2Udt<T,S> BuiltIn2Udt ; + typedef subranged_Udt2BuiltIn<T,S> Udt2BuiltIn ; + typedef subranged_Udt2Udt<T,S> Udt2Udt ; + + typedef mpl::identity<BuiltIn2Udt> BuiltIn2UdtQ ; + typedef mpl::identity<Udt2BuiltIn> Udt2BuiltInQ ; + typedef mpl::identity<Udt2Udt > Udt2UdtQ ; + + typedef typename get_udt_builtin_mixture<T,S>::type udt_builtin_mixture ; + + typedef typename + for_udt_builtin_mixture<udt_builtin_mixture, BuiltIn2BuiltInQ, BuiltIn2UdtQ, Udt2BuiltInQ, Udt2UdtQ>::type + selected ; + + typedef typename selected::type selected2 ; + + typedef typename selected2::type type ; + } ; + + + //------------------------------------------------------------------- + // Top level implementation selector. + //------------------------------------------------------------------- + template<class T, class S> + struct get_is_subranged + { + typedef get_subranged<T,S> non_trivial_case ; + typedef mpl::identity<mpl::false_> trivial_case ; + + typedef is_same<T,S> is_trivial ; + + typedef typename mpl::if_<is_trivial,trivial_case,non_trivial_case>::type selected ; + + typedef typename selected::type type ; + } ; + +} } } // namespace boost::numeric::convdetail + +#endif + + diff --git a/3rdParty/Boost/boost/numeric/conversion/detail/meta.hpp b/3rdParty/Boost/boost/numeric/conversion/detail/meta.hpp new file mode 100644 index 0000000..246a1b4 --- /dev/null +++ b/3rdParty/Boost/boost/numeric/conversion/detail/meta.hpp @@ -0,0 +1,120 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_DETAIL_META_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_DETAIL_META_FLC_12NOV2002_HPP + +#include "boost/type_traits/remove_cv.hpp" + +#include "boost/mpl/if.hpp" +#include "boost/mpl/eval_if.hpp" +#include "boost/mpl/equal_to.hpp" +#include "boost/mpl/not.hpp" +#include "boost/mpl/and.hpp" +#include "boost/mpl/bool.hpp" +#include "boost/mpl/identity.hpp" + +namespace boost { namespace numeric { namespace convdetail +{ + template< class T1, class T2> + struct equal_to + { + #if !defined(__BORLANDC__) + + enum { x = ( BOOST_MPL_AUX_VALUE_WKND(T1)::value == BOOST_MPL_AUX_VALUE_WKND(T2)::value ) }; + + BOOST_STATIC_CONSTANT(bool, value = x); + + typedef mpl::bool_<value> type; + + #else + + BOOST_STATIC_CONSTANT(bool, value = ( + BOOST_MPL_AUX_VALUE_WKND(T1)::value + == BOOST_MPL_AUX_VALUE_WKND(T2)::value + )); + + typedef mpl::bool_<( + BOOST_MPL_AUX_VALUE_WKND(T1)::value + == BOOST_MPL_AUX_VALUE_WKND(T2)::value + )> type; + #endif + }; + +// Metafunction: + // + // ct_switch4<Value,Case0Val,Case1Val,Case2Val,Case0Type,Case1Type,Case2Type,DefaultType>::type + // + // {Value,Case(X)Val} are Integral Constants (such as: mpl::int_<>) + // {Case(X)Type,DefaultType} are arbitrary types. (not metafunctions) + // + // Returns Case(X)Type if Val==Case(X)Val; DefaultType otherwise. + // + template<class Value, + class Case0Val, + class Case1Val, + class Case2Val, + class Case0Type, + class Case1Type, + class Case2Type, + class DefaultType + > + struct ct_switch4 + { + typedef mpl::identity<Case0Type> Case0TypeQ ; + typedef mpl::identity<Case1Type> Case1TypeQ ; + + typedef equal_to<Value,Case0Val> is_case0 ; + typedef equal_to<Value,Case1Val> is_case1 ; + typedef equal_to<Value,Case2Val> is_case2 ; + + typedef mpl::if_<is_case2,Case2Type,DefaultType> choose_2_3Q ; + typedef mpl::eval_if<is_case1,Case1TypeQ,choose_2_3Q> choose_1_2_3Q ; + + typedef typename + mpl::eval_if<is_case0,Case0TypeQ,choose_1_2_3Q>::type + type ; + } ; + + + + + // Metafunction: + // + // for_both<expr0,expr1,TT,TF,FT,FF>::type + // + // {exp0,expr1} are Boolean Integral Constants + // {TT,TF,FT,FF} are aribtrary types. (not metafunctions) + // + // According to the combined boolean value of 'expr0 && expr1', selects the corresponding type. + // + template<class expr0, class expr1, class TT, class TF, class FT, class FF> + struct for_both + { + typedef mpl::identity<TF> TF_Q ; + typedef mpl::identity<TT> TT_Q ; + + typedef typename mpl::not_<expr0>::type not_expr0 ; + typedef typename mpl::not_<expr1>::type not_expr1 ; + + typedef typename mpl::and_<expr0,expr1>::type caseTT ; + typedef typename mpl::and_<expr0,not_expr1>::type caseTF ; + typedef typename mpl::and_<not_expr0,expr1>::type caseFT ; + + typedef mpl::if_<caseFT,FT,FF> choose_FT_FF_Q ; + typedef mpl::eval_if<caseTF,TF_Q,choose_FT_FF_Q> choose_TF_FT_FF_Q ; + + typedef typename mpl::eval_if<caseTT,TT_Q,choose_TF_FT_FF_Q>::type type ; + } ; + +} } } // namespace boost::numeric::convdetail + +#endif + + diff --git a/3rdParty/Boost/boost/numeric/conversion/detail/old_numeric_cast.hpp b/3rdParty/Boost/boost/numeric/conversion/detail/old_numeric_cast.hpp new file mode 100644 index 0000000..47b86d2 --- /dev/null +++ b/3rdParty/Boost/boost/numeric/conversion/detail/old_numeric_cast.hpp @@ -0,0 +1,339 @@ +// boost cast.hpp header file ----------------------------------------------// + +// (C) Copyright Kevlin Henney and Dave Abrahams 1999. +// Distributed under the Boost +// Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +// See http://www.boost.org/libs/conversion for Documentation. + +// Revision History +// 23 JUN 05 Code extracted from /boost/cast.hpp into this new header. +// Keeps this legacy version of numeric_cast<> for old compilers +// wich can't compile the new version in /boost/numeric/conversion/cast.hpp +// (Fernando Cacciola) +// 02 Apr 01 Removed BOOST_NO_LIMITS workarounds and included +// <boost/limits.hpp> instead (the workaround did not +// actually compile when BOOST_NO_LIMITS was defined in +// any case, so we loose nothing). (John Maddock) +// 21 Jan 01 Undid a bug I introduced yesterday. numeric_cast<> never +// worked with stock GCC; trying to get it to do that broke +// vc-stlport. +// 20 Jan 01 Moved BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS to config.hpp. +// Removed unused BOOST_EXPLICIT_TARGET macro. Moved +// boost::detail::type to boost/type.hpp. Made it compile with +// stock gcc again (Dave Abrahams) +// 29 Nov 00 Remove nested namespace cast, cleanup spacing before Formal +// Review (Beman Dawes) +// 19 Oct 00 Fix numeric_cast for floating-point types (Dave Abrahams) +// 15 Jul 00 Suppress numeric_cast warnings for GCC, Borland and MSVC +// (Dave Abrahams) +// 30 Jun 00 More MSVC6 wordarounds. See comments below. (Dave Abrahams) +// 28 Jun 00 Removed implicit_cast<>. See comment below. (Beman Dawes) +// 27 Jun 00 More MSVC6 workarounds +// 15 Jun 00 Add workarounds for MSVC6 +// 2 Feb 00 Remove bad_numeric_cast ";" syntax error (Doncho Angelov) +// 26 Jan 00 Add missing throw() to bad_numeric_cast::what(0 (Adam Levar) +// 29 Dec 99 Change using declarations so usages in other namespaces work +// correctly (Dave Abrahams) +// 23 Sep 99 Change polymorphic_downcast assert to also detect M.I. errors +// as suggested Darin Adler and improved by Valentin Bonnard. +// 2 Sep 99 Remove controversial asserts, simplify, rename. +// 30 Aug 99 Move to cast.hpp, replace value_cast with numeric_cast, +// place in nested namespace. +// 3 Aug 99 Initial version + +#ifndef BOOST_OLD_NUMERIC_CAST_HPP +#define BOOST_OLD_NUMERIC_CAST_HPP + +# include <boost/config.hpp> +# include <cassert> +# include <typeinfo> +# include <boost/type.hpp> +# include <boost/limits.hpp> +# include <boost/numeric/conversion/converter_policies.hpp> + +// It has been demonstrated numerous times that MSVC 6.0 fails silently at link +// time if you use a template function which has template parameters that don't +// appear in the function's argument list. +// +// TODO: Add this to config.hpp? +// FLC: This macro is repeated in boost/cast.hpp but only locally (is undefined at the bottom) +// so is OK to reproduce it here. +# 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 +{ + using numeric::bad_numeric_cast; + +// LEGACY numeric_cast [only for some old broken compilers] --------------------------------------// + +// Contributed by Kevlin Henney + +// numeric_cast ------------------------------------------------------------// + +#if !defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) || defined(BOOST_SGI_CPP_LIMITS) + + namespace detail + { + template <class T> + struct signed_numeric_limits : std::numeric_limits<T> + { + static inline T min BOOST_PREVENT_MACRO_SUBSTITUTION () + { + return (std::numeric_limits<T>::min)() >= 0 + // unary minus causes integral promotion, thus the static_cast<> + ? static_cast<T>(-(std::numeric_limits<T>::max)()) + : (std::numeric_limits<T>::min)(); + }; + }; + + // Move to namespace boost in utility.hpp? + template <class T, bool specialized> + struct fixed_numeric_limits_base + : public if_true< std::numeric_limits<T>::is_signed > + ::BOOST_NESTED_TEMPLATE then< signed_numeric_limits<T>, + std::numeric_limits<T> + >::type + {}; + + template <class T> + struct fixed_numeric_limits + : fixed_numeric_limits_base<T,(std::numeric_limits<T>::is_specialized)> + {}; + +# ifdef BOOST_HAS_LONG_LONG + // cover implementations which supply no specialization for long + // long / unsigned long long. Not intended to be full + // numeric_limits replacements, but good enough for numeric_cast<> + template <> + struct fixed_numeric_limits_base< ::boost::long_long_type, false> + { + BOOST_STATIC_CONSTANT(bool, is_specialized = true); + BOOST_STATIC_CONSTANT(bool, is_signed = true); + static ::boost::long_long_type max BOOST_PREVENT_MACRO_SUBSTITUTION () + { +# ifdef LONGLONG_MAX + return LONGLONG_MAX; +# else + return 9223372036854775807LL; // hope this is portable +# endif + } + + static ::boost::long_long_type min BOOST_PREVENT_MACRO_SUBSTITUTION () + { +# ifdef LONGLONG_MIN + return LONGLONG_MIN; +# else + return -( 9223372036854775807LL )-1; // hope this is portable +# endif + } + }; + + template <> + struct fixed_numeric_limits_base< ::boost::ulong_long_type, false> + { + BOOST_STATIC_CONSTANT(bool, is_specialized = true); + BOOST_STATIC_CONSTANT(bool, is_signed = false); + static ::boost::ulong_long_type max BOOST_PREVENT_MACRO_SUBSTITUTION () + { +# ifdef ULONGLONG_MAX + return ULONGLONG_MAX; +# else + return 0xffffffffffffffffULL; // hope this is portable +# endif + } + + static ::boost::ulong_long_type min BOOST_PREVENT_MACRO_SUBSTITUTION () { return 0; } + }; +# endif + } // namespace detail + +// less_than_type_min - + // x_is_signed should be numeric_limits<X>::is_signed + // y_is_signed should be numeric_limits<Y>::is_signed + // y_min should be numeric_limits<Y>::min() + // + // check(x, y_min) returns true iff x < y_min without invoking comparisons + // between signed and unsigned values. + // + // "poor man's partial specialization" is in use here. + template <bool x_is_signed, bool y_is_signed> + struct less_than_type_min + { + template <class X, class Y> + static bool check(X x, Y y_min) + { return x < y_min; } + }; + + template <> + struct less_than_type_min<false, true> + { + template <class X, class Y> + static bool check(X, Y) + { return false; } + }; + + template <> + struct less_than_type_min<true, false> + { + template <class X, class Y> + static bool check(X x, Y) + { return x < 0; } + }; + + // greater_than_type_max - + // same_sign should be: + // numeric_limits<X>::is_signed == numeric_limits<Y>::is_signed + // y_max should be numeric_limits<Y>::max() + // + // check(x, y_max) returns true iff x > y_max without invoking comparisons + // between signed and unsigned values. + // + // "poor man's partial specialization" is in use here. + template <bool same_sign, bool x_is_signed> + struct greater_than_type_max; + + template<> + struct greater_than_type_max<true, true> + { + template <class X, class Y> + static inline bool check(X x, Y y_max) + { return x > y_max; } + }; + + template <> + struct greater_than_type_max<false, true> + { + // What does the standard say about this? I think it's right, and it + // will work with every compiler I know of. + template <class X, class Y> + static inline bool check(X x, Y) + { return x >= 0 && static_cast<X>(static_cast<Y>(x)) != x; } + +# if defined(BOOST_MSVC) && BOOST_MSVC < 1300 + // MSVC6 can't static_cast unsigned __int64 -> floating types +# define BOOST_UINT64_CAST(src_type) \ + static inline bool check(src_type x, unsigned __int64) \ + { \ + if (x < 0) return false; \ + unsigned __int64 y = static_cast<unsigned __int64>(x); \ + bool odd = y & 0x1; \ + __int64 div2 = static_cast<__int64>(y >> 1); \ + return ((static_cast<src_type>(div2) * 2.0) + odd) != x; \ + } + + BOOST_UINT64_CAST(long double); + BOOST_UINT64_CAST(double); + BOOST_UINT64_CAST(float); +# undef BOOST_UINT64_CAST +# endif + }; + + template<> + struct greater_than_type_max<true, false> + { + template <class X, class Y> + static inline bool check(X x, Y y_max) + { return x > y_max; } + }; + + template <> + struct greater_than_type_max<false, false> + { + // What does the standard say about this? I think it's right, and it + // will work with every compiler I know of. + template <class X, class Y> + static inline bool check(X x, Y) + { return static_cast<X>(static_cast<Y>(x)) != x; } + }; + +#else // use #pragma hacks if available + + namespace detail + { +# if BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4018) +# pragma warning(disable : 4146) +#elif defined(__BORLANDC__) +# pragma option push -w-8041 +# endif + + // Move to namespace boost in utility.hpp? + template <class T> + struct fixed_numeric_limits : public std::numeric_limits<T> + { + static inline T min BOOST_PREVENT_MACRO_SUBSTITUTION () + { + return std::numeric_limits<T>::is_signed && (std::numeric_limits<T>::min)() >= 0 + ? T(-(std::numeric_limits<T>::max)()) : (std::numeric_limits<T>::min)(); + } + }; + +# if BOOST_MSVC +# pragma warning(pop) +#elif defined(__BORLANDC__) +# pragma option pop +# endif + } // namespace detail + +#endif + + template<typename Target, typename Source> + inline Target numeric_cast(Source arg BOOST_EXPLICIT_DEFAULT_TARGET) + { + // typedefs abbreviating respective trait classes + typedef detail::fixed_numeric_limits<Source> arg_traits; + typedef detail::fixed_numeric_limits<Target> result_traits; + +#if defined(BOOST_STRICT_CONFIG) \ + || (!defined(__HP_aCC) || __HP_aCC > 33900) \ + && (!defined(BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS) \ + || defined(BOOST_SGI_CPP_LIMITS)) + // typedefs that act as compile time assertions + // (to be replaced by boost compile time assertions + // as and when they become available and are stable) + typedef bool argument_must_be_numeric[arg_traits::is_specialized]; + typedef bool result_must_be_numeric[result_traits::is_specialized]; + + const bool arg_is_signed = arg_traits::is_signed; + const bool result_is_signed = result_traits::is_signed; + const bool same_sign = arg_is_signed == result_is_signed; + + if (less_than_type_min<arg_is_signed, result_is_signed>::check(arg, (result_traits::min)()) + || greater_than_type_max<same_sign, arg_is_signed>::check(arg, (result_traits::max)()) + ) + +#else // We need to use #pragma hacks if available + +# if BOOST_MSVC +# pragma warning(push) +# pragma warning(disable : 4018) +#elif defined(__BORLANDC__) +#pragma option push -w-8012 +# endif + if ((arg < 0 && !result_traits::is_signed) // loss of negative range + || (arg_traits::is_signed && arg < (result_traits::min)()) // underflow + || arg > (result_traits::max)()) // overflow +# if BOOST_MSVC +# pragma warning(pop) +#elif defined(__BORLANDC__) +#pragma option pop +# endif +#endif + { + throw bad_numeric_cast(); + } + return static_cast<Target>(arg); + } // numeric_cast + +# undef BOOST_EXPLICIT_DEFAULT_TARGET + +} // namespace boost + +#endif // BOOST_OLD_NUMERIC_CAST_HPP diff --git a/3rdParty/Boost/boost/numeric/conversion/detail/sign_mixture.hpp b/3rdParty/Boost/boost/numeric/conversion/detail/sign_mixture.hpp new file mode 100644 index 0000000..c7f9e42 --- /dev/null +++ b/3rdParty/Boost/boost/numeric/conversion/detail/sign_mixture.hpp @@ -0,0 +1,72 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_DETAIL_SIGN_MIXTURE_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_DETAIL_SIGN_MIXTURE_FLC_12NOV2002_HPP + +#include "boost/config.hpp" +#include "boost/limits.hpp" + +#include "boost/numeric/conversion/sign_mixture_enum.hpp" +#include "boost/numeric/conversion/detail/meta.hpp" + +#include "boost/mpl/integral_c.hpp" + +namespace boost { namespace numeric { namespace convdetail +{ + // Integral Constants for 'SignMixture' + typedef mpl::integral_c<sign_mixture_enum, unsigned_to_unsigned> unsig2unsig_c ; + typedef mpl::integral_c<sign_mixture_enum, signed_to_signed> sig2sig_c ; + typedef mpl::integral_c<sign_mixture_enum, signed_to_unsigned> sig2unsig_c ; + typedef mpl::integral_c<sign_mixture_enum, unsigned_to_signed> unsig2sig_c ; + + // Metafunction: + // + // get_sign_mixture<T,S>::type + // + // Selects the appropriate SignMixture Integral Constant for the combination T,S. + // + template<class T,class S> + struct get_sign_mixture + { + typedef mpl::bool_< ::std::numeric_limits<S>::is_signed > S_signed ; + typedef mpl::bool_< ::std::numeric_limits<T>::is_signed > T_signed ; + + typedef typename + for_both<S_signed, T_signed, sig2sig_c, sig2unsig_c, unsig2sig_c, unsig2unsig_c>::type + type ; + } ; + + // Metafunction: + // + // for_sign_mixture<SignMixture,Sig2Sig,Sig2Unsig,Unsig2Sig,Unsig2Unsig>::type + // + // {SignMixture} is one of the Integral Constants for SignMixture, declared above. + // {Sig2Sig,Sig2Unsig,Unsig2Sig,Unsig2Unsig} are aribtrary types. (not metafunctions) + // + // According to the value of 'SignMixture', selects the corresponding type. + // + template<class SignMixture, class Sig2Sig, class Sig2Unsig, class Unsig2Sig, class Unsig2Unsig> + struct for_sign_mixture + { + typedef typename + ct_switch4<SignMixture + , sig2sig_c, sig2unsig_c, unsig2sig_c // default + , Sig2Sig , Sig2Unsig , Unsig2Sig , Unsig2Unsig + >::type + type ; + } ; + +} } } // namespace boost::numeric::convdetail + +#endif +// +/////////////////////////////////////////////////////////////////////////////////////////////// + + diff --git a/3rdParty/Boost/boost/numeric/conversion/detail/udt_builtin_mixture.hpp b/3rdParty/Boost/boost/numeric/conversion/detail/udt_builtin_mixture.hpp new file mode 100644 index 0000000..36dbc49 --- /dev/null +++ b/3rdParty/Boost/boost/numeric/conversion/detail/udt_builtin_mixture.hpp @@ -0,0 +1,69 @@ +// (c) Copyright Fernando Luis Cacciola Carballal 2000-2004 +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/numeric/conversion +// +// Contact the author at: fernando_cacciola@hotmail.com +// +#ifndef BOOST_NUMERIC_CONVERSION_DETAIL_UDT_BUILTIN_MIXTURE_FLC_12NOV2002_HPP +#define BOOST_NUMERIC_CONVERSION_DETAIL_UDT_BUILTIN_MIXTURE_FLC_12NOV2002_HPP + +#include "boost/type_traits/is_arithmetic.hpp" + +#include "boost/numeric/conversion/udt_builtin_mixture_enum.hpp" +#include "boost/numeric/conversion/detail/meta.hpp" + +#include "boost/mpl/integral_c.hpp" + +namespace boost { namespace numeric { namespace convdetail +{ + // Integral Constants for 'UdtMixture' + typedef mpl::integral_c<udt_builtin_mixture_enum, builtin_to_builtin> builtin2builtin_c ; + typedef mpl::integral_c<udt_builtin_mixture_enum, builtin_to_udt> builtin2udt_c ; + typedef mpl::integral_c<udt_builtin_mixture_enum, udt_to_builtin> udt2builtin_c ; + typedef mpl::integral_c<udt_builtin_mixture_enum, udt_to_udt> udt2udt_c ; + + // Metafunction: + // + // for_udt_mixture<UdtMixture,BuiltIn2BuiltIn,BuiltIn2Udt,Udt2BuiltIn,Udt2Udt>::type + // + // {UdtMixture} is one of the Integral Constants for UdMixture, declared above. + // {BuiltIn2BuiltIn,BuiltIn2Udt,Udt2BuiltIn,Udt2Udt} are aribtrary types. (not metafunctions) + // + // According to the value of 'UdtMixture', selects the corresponding type. + // + template<class UdtMixture, class BuiltIn2BuiltIn, class BuiltIn2Udt, class Udt2BuiltIn, class Udt2Udt> + struct for_udt_builtin_mixture + { + typedef typename + ct_switch4<UdtMixture + , builtin2builtin_c, builtin2udt_c, udt2builtin_c // default + , BuiltIn2BuiltIn , BuiltIn2Udt , Udt2BuiltIn , Udt2Udt + >::type + type ; + } ; + + // Metafunction: + // + // get_udt_mixture<T,S>::type + // + // Selects the appropriate UdtMixture Integral Constant for the combination T,S. + // + template<class T,class S> + struct get_udt_builtin_mixture + { + typedef is_arithmetic<S> S_builtin ; + typedef is_arithmetic<T> T_builtin ; + + typedef typename + for_both<S_builtin, T_builtin, builtin2builtin_c, builtin2udt_c, udt2builtin_c, udt2udt_c>::type + type ; + } ; + +} } } // namespace boost::numeric::convdetail + +#endif + + |