1
0
mirror of https://git.suyu.dev/suyu/suyu synced 2025-09-06 14:26:32 -05:00

Initial commit

This commit is contained in:
Crimson-Hawk
2024-03-05 16:42:40 +08:00
commit f1e4595ebf
39576 changed files with 7006612 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
CRTLinkage: dynamic
LibraryLinkage: dynamic

View File

@@ -0,0 +1,8 @@
Package: boost-numeric-conversion
Version: 1.79.0
Depends: boost-config, boost-conversion, boost-core, boost-mpl, boost-preprocessor, boost-throw-exception, boost-type-traits, boost-vcpkg-helpers
Architecture: x64-windows
Multi-Arch: same
Abi: c7d1f700231348a54921287cb7cec7268ff76dcc995cb3242e25677261b23a02
Description: Boost numeric_conversion module
Type: Port

View File

@@ -0,0 +1,20 @@
// boost cast.hpp header file
//
// (C) Copyright Antony Polukhin 2014.
//
// 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.
// This is a DEPRECATED header file!
// Use <boost/polymorphic_cast.hpp> or <boost/numeric/conversion/cast.hpp> instead
#ifndef BOOST_CAST_HPP
#define BOOST_CAST_HPP
# include <boost/polymorphic_cast.hpp>
# include <boost/numeric/conversion/cast.hpp>
#endif // BOOST_CAST_HPP

View File

@@ -0,0 +1,24 @@
// (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_12NOV2002_HPP
#define BOOST_NUMERIC_CONVERSION_BOUNDS_12NOV2002_HPP
#include "boost/numeric/conversion/detail/bounds.hpp"
namespace boost { namespace numeric
{
template<class N>
struct bounds : boundsdetail::get_impl<N>::type
{} ;
} } // namespace boost::numeric
#endif

View File

@@ -0,0 +1,61 @@
// (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
//
//
// Revision History
//
// 19 Nov 2001 Syntatic changes as suggested by Darin Adler (Fernando Cacciola)
// 08 Nov 2001 Fixes to accommodate MSVC (Fernando Cacciola)
// 04 Nov 2001 Fixes to accommodate gcc2.92 (Fernando Cacciola)
// 30 Oct 2001 Some fixes suggested by Daryle Walker (Fernando Cacciola)
// 25 Oct 2001 Initial boostification (Fernando Cacciola)
// 23 Jan 2004 Inital add to cvs (post review)s
// 22 Jun 2011 Added support for specializing cast policies via numeric_cast_traits (Brandon Kohn).
//
#ifndef BOOST_NUMERIC_CONVERSION_CAST_25OCT2001_HPP
#define BOOST_NUMERIC_CONVERSION_CAST_25OCT2001_HPP
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x582))
# include<boost/numeric/conversion/detail/old_numeric_cast.hpp>
#else
#include <boost/type.hpp>
#include <boost/numeric/conversion/converter.hpp>
#include <boost/numeric/conversion/numeric_cast_traits.hpp>
namespace boost
{
template <typename Target, typename Source>
inline Target numeric_cast( Source arg )
{
typedef numeric::conversion_traits<Target, Source> conv_traits;
typedef numeric::numeric_cast_traits<Target, Source> cast_traits;
typedef boost::numeric::converter
<
Target,
Source,
conv_traits,
typename cast_traits::overflow_policy,
typename cast_traits::rounding_policy,
boost::numeric::raw_converter< conv_traits >,
typename cast_traits::range_checking_policy
> converter;
return converter::convert(arg);
}
using numeric::bad_numeric_cast;
} // namespace boost
#endif
#endif

View File

@@ -0,0 +1,32 @@
// (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_CONVERSION_TRAITS_FLC_12NOV2002_HPP
#define BOOST_NUMERIC_CONVERSION_CONVERSION_TRAITS_FLC_12NOV2002_HPP
#include "boost/numeric/conversion/detail/conversion_traits.hpp"
#include "boost/detail/workaround.hpp"
#include "boost/config.hpp"
namespace boost { namespace numeric
{
template<class T, class S>
struct conversion_traits
: convdetail::get_conversion_traits<T,S>::type
{
} ;
} } // namespace boost::numeric
#endif
//
///////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,68 @@
// (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_CONVERTER_FLC_12NOV2002_HPP
#define BOOST_NUMERIC_CONVERSION_CONVERTER_FLC_12NOV2002_HPP
#include "boost/numeric/conversion/conversion_traits.hpp"
#include "boost/numeric/conversion/converter_policies.hpp"
#include "boost/numeric/conversion/detail/converter.hpp"
namespace boost { namespace numeric
{
template<class T,
class S,
class Traits = conversion_traits<T,S>,
class OverflowHandler = def_overflow_handler,
class Float2IntRounder = Trunc< BOOST_DEDUCED_TYPENAME Traits::source_type> ,
class RawConverter = raw_converter<Traits>,
class UserRangeChecker = UseInternalRangeChecker
>
struct converter : convdetail::get_converter_impl<Traits,
OverflowHandler,
Float2IntRounder,
RawConverter,
UserRangeChecker
>::type
{
typedef Traits traits ;
typedef typename Traits::argument_type argument_type ;
typedef typename Traits::result_type result_type ;
result_type operator() ( argument_type s ) const { return this->convert(s) ; }
} ;
template<class S,
class OverflowHandler = def_overflow_handler,
class Float2IntRounder = Trunc<S> ,
class UserRangeChecker = UseInternalRangeChecker
>
struct make_converter_from
{
template<class T,
class Traits = conversion_traits<T,S>,
class RawConverter = raw_converter<Traits>
>
struct to
{
typedef converter<T,S,Traits,OverflowHandler,Float2IntRounder,RawConverter,UserRangeChecker> type ;
} ;
} ;
} } // namespace boost::numeric
#endif

View File

@@ -0,0 +1,194 @@
// (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_CONVERTER_POLICIES_FLC_12NOV2002_HPP
#define BOOST_NUMERIC_CONVERSION_CONVERTER_POLICIES_FLC_12NOV2002_HPP
#include <functional>
#include <typeinfo> // for std::bad_cast
#include <boost/config.hpp>
#include <boost/config/no_tr1/cmath.hpp> // for std::floor and std::ceil
#include <boost/throw_exception.hpp>
#include "boost/type_traits/is_arithmetic.hpp"
#include "boost/mpl/if.hpp"
#include "boost/mpl/integral_c.hpp"
namespace boost { namespace numeric
{
template<class S>
struct Trunc
{
typedef S source_type ;
typedef typename mpl::if_< is_arithmetic<S>,S,S const&>::type argument_type ;
static source_type nearbyint ( argument_type s )
{
#if !defined(BOOST_NO_STDC_NAMESPACE)
using std::floor ;
using std::ceil ;
#endif
return s < static_cast<S>(0) ? ceil(s) : floor(s) ;
}
typedef mpl::integral_c< std::float_round_style, std::round_toward_zero> round_style ;
} ;
template<class S>
struct Floor
{
typedef S source_type ;
typedef typename mpl::if_< is_arithmetic<S>,S,S const&>::type argument_type ;
static source_type nearbyint ( argument_type s )
{
#if !defined(BOOST_NO_STDC_NAMESPACE)
using std::floor ;
#endif
return floor(s) ;
}
typedef mpl::integral_c< std::float_round_style, std::round_toward_neg_infinity> round_style ;
} ;
template<class S>
struct Ceil
{
typedef S source_type ;
typedef typename mpl::if_< is_arithmetic<S>,S,S const&>::type argument_type ;
static source_type nearbyint ( argument_type s )
{
#if !defined(BOOST_NO_STDC_NAMESPACE)
using std::ceil ;
#endif
return ceil(s) ;
}
typedef mpl::integral_c< std::float_round_style, std::round_toward_infinity> round_style ;
} ;
template<class S>
struct RoundEven
{
typedef S source_type ;
typedef typename mpl::if_< is_arithmetic<S>,S,S const&>::type argument_type ;
static source_type nearbyint ( argument_type s )
{
// Algorithm contributed by Guillaume Melquiond
#if !defined(BOOST_NO_STDC_NAMESPACE)
using std::floor ;
using std::ceil ;
#endif
// only works inside the range not at the boundaries
S prev = floor(s);
S next = ceil(s);
S rt = (s - prev) - (next - s); // remainder type
S const zero(0.0);
S const two(2.0);
if ( rt < zero )
return prev;
else if ( rt > zero )
return next;
else
{
bool is_prev_even = two * floor(prev / two) == prev ;
return ( is_prev_even ? prev : next ) ;
}
}
typedef mpl::integral_c< std::float_round_style, std::round_to_nearest> round_style ;
} ;
enum range_check_result
{
cInRange = 0 ,
cNegOverflow = 1 ,
cPosOverflow = 2
} ;
class bad_numeric_cast : public std::bad_cast
{
public:
const char * what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE
{ return "bad numeric conversion: overflow"; }
};
class negative_overflow : public bad_numeric_cast
{
public:
const char * what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE
{ return "bad numeric conversion: negative overflow"; }
};
class positive_overflow : public bad_numeric_cast
{
public:
const char * what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE
{ return "bad numeric conversion: positive overflow"; }
};
struct def_overflow_handler
{
void operator() ( range_check_result r ) // throw(negative_overflow,positive_overflow)
{
#ifndef BOOST_NO_EXCEPTIONS
if ( r == cNegOverflow )
throw negative_overflow() ;
else if ( r == cPosOverflow )
throw positive_overflow() ;
#else
if ( r == cNegOverflow )
::boost::throw_exception(negative_overflow()) ;
else if ( r == cPosOverflow )
::boost::throw_exception(positive_overflow()) ;
#endif
}
} ;
struct silent_overflow_handler
{
void operator() ( range_check_result ) {} // throw()
} ;
template<class Traits>
struct raw_converter
{
typedef typename Traits::result_type result_type ;
typedef typename Traits::argument_type argument_type ;
static result_type low_level_convert ( argument_type s ) { return static_cast<result_type>(s) ; }
} ;
struct UseInternalRangeChecker {} ;
} } // namespace boost::numeric
#endif

View File

@@ -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
//
///////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -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

View File

@@ -0,0 +1,593 @@
// (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 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 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 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(BOOST_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

View File

@@ -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
//
///////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -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

View File

@@ -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(BOOST_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

View File

@@ -0,0 +1,138 @@
//
//! Copyright (c) 2011-2012
//! Brandon Kohn
//
// 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)
//
#if !defined(BOOST_NUMERIC_CONVERSION_DONT_USE_PREPROCESSED_FILES)
#include <boost/numeric/conversion/detail/preprocessed/numeric_cast_traits_common.hpp>
#if !defined(BOOST_NO_LONG_LONG)
#include <boost/numeric/conversion/detail/preprocessed/numeric_cast_traits_long_long.hpp>
#endif
#else
#if !BOOST_PP_IS_ITERATING
#include <boost/preprocessor/seq/elem.hpp>
#include <boost/preprocessor/seq/size.hpp>
#include <boost/preprocessor/iteration/iterate.hpp>
#if defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES)
#pragma wave option(preserve: 2, line: 0, output: "preprocessed/numeric_cast_traits_common.hpp")
#endif
//
//! Copyright (c) 2011-2012
//! Brandon Kohn
//
// 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)
//
#if defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES)
#pragma wave option(preserve: 1)
#endif
//! These are the assumed common built in fundamental types (not typedefs/macros.)
#define BOOST_NUMERIC_CONVERSION_BASE_BUILTIN_TYPES() \
(char) \
(signed char) \
(unsigned char) \
(short) \
(unsigned short) \
(int) \
(unsigned int) \
(long) \
(unsigned long) \
(float) \
(double) \
(long double) \
/***/
#define BOOST_NUMERIC_CONVERSION_SEQ_A() BOOST_NUMERIC_CONVERSION_BASE_BUILTIN_TYPES()
#define BOOST_NUMERIC_CONVERSION_SEQ_B() BOOST_NUMERIC_CONVERSION_BASE_BUILTIN_TYPES()
namespace boost { namespace numeric {
#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(BOOST_NUMERIC_CONVERSION_SEQ_A())), <boost/numeric/conversion/detail/numeric_cast_traits.hpp>))
#include BOOST_PP_ITERATE()
}}//namespace boost::numeric;
#if defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES)
#pragma wave option(output: null)
#endif
#if ( defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES) ) || !defined(BOOST_NO_LONG_LONG)
#undef BOOST_NUMERIC_CONVERSION_SEQ_A
#undef BOOST_NUMERIC_CONVERSION_SEQ_B
#if defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES)
#pragma wave option(preserve: 2, line: 0, output: "preprocessed/numeric_cast_traits_long_long.hpp")
#endif
//
//! Copyright (c) 2011-2012
//! Brandon Kohn
//
// 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)
//
#if defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES)
#pragma wave option(preserve: 1)
#endif
namespace boost { namespace numeric {
#define BOOST_NUMERIC_CONVERSION_SEQ_A() BOOST_NUMERIC_CONVERSION_BASE_BUILTIN_TYPES()(boost::long_long_type)(boost::ulong_long_type)
#define BOOST_NUMERIC_CONVERSION_SEQ_B() (boost::long_long_type)(boost::ulong_long_type)
#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(BOOST_NUMERIC_CONVERSION_SEQ_A())), <boost/numeric/conversion/detail/numeric_cast_traits.hpp>))
#include BOOST_PP_ITERATE()
}}//namespace boost::numeric;
#if defined(__WAVE__) && defined(BOOST_NUMERIC_CONVERSION_CREATE_PREPROCESSED_FILES)
#pragma wave option(output: null)
#endif
#endif
#undef BOOST_NUMERIC_CONVERSION_BASE_BUILTIN_TYPES
#undef BOOST_NUMERIC_CONVERSION_SEQ_A
#undef BOOST_NUMERIC_CONVERSION_SEQ_B
#elif BOOST_PP_ITERATION_DEPTH() == 1
#define BOOST_PP_ITERATION_PARAMS_2 (3, (0, BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(BOOST_NUMERIC_CONVERSION_SEQ_B())), <boost/numeric/conversion/detail/numeric_cast_traits.hpp>))
#include BOOST_PP_ITERATE()
#elif BOOST_PP_ITERATION_DEPTH() == 2
//! Generate default traits for the specified source and target.
#define BOOST_NUMERIC_CONVERSION_A BOOST_PP_FRAME_ITERATION(1)
#define BOOST_NUMERIC_CONVERSION_B BOOST_PP_FRAME_ITERATION(2)
template <>
struct numeric_cast_traits
<
BOOST_PP_SEQ_ELEM(BOOST_NUMERIC_CONVERSION_A, BOOST_NUMERIC_CONVERSION_SEQ_A())
, BOOST_PP_SEQ_ELEM(BOOST_NUMERIC_CONVERSION_B, BOOST_NUMERIC_CONVERSION_SEQ_B())
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<BOOST_PP_SEQ_ELEM(BOOST_NUMERIC_CONVERSION_B, BOOST_NUMERIC_CONVERSION_SEQ_B())> rounding_policy;
};
#undef BOOST_NUMERIC_CONVERSION_A
#undef BOOST_NUMERIC_CONVERSION_B
#endif//! Depth 2.
#endif// BOOST_NUMERIC_CONVERSION_DONT_USE_PREPROCESSED_FILES

View File

@@ -0,0 +1,308 @@
// 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
// 02 Jun 14 Remove VC6 workarounds.
// 16 Jul 11 Bugfixes for VC6.
// 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>
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; }
};
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(BOOST_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(BOOST_BORLANDC)
# pragma option pop
# endif
} // namespace detail
#endif
template<typename Target, typename Source>
inline Target numeric_cast(Source arg)
{
// 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(BOOST_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(BOOST_BORLANDC)
#pragma option pop
# endif
#endif
{
throw bad_numeric_cast();
}
return static_cast<Target>(arg);
} // numeric_cast
} // namespace boost
#endif // BOOST_OLD_NUMERIC_CAST_HPP

View File

@@ -0,0 +1,347 @@
//
//! Copyright (c) 2011-2012
//! Brandon Kohn
//
// 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)
//
namespace boost { namespace numeric {
template <>
struct numeric_cast_traits
<
char
, boost::long_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::long_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
char
, boost::ulong_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::ulong_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
signed char
, boost::long_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::long_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
signed char
, boost::ulong_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::ulong_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
unsigned char
, boost::long_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::long_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
unsigned char
, boost::ulong_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::ulong_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
short
, boost::long_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::long_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
short
, boost::ulong_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::ulong_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
unsigned short
, boost::long_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::long_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
unsigned short
, boost::ulong_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::ulong_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
int
, boost::long_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::long_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
int
, boost::ulong_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::ulong_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
unsigned int
, boost::long_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::long_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
unsigned int
, boost::ulong_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::ulong_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
long
, boost::long_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::long_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
long
, boost::ulong_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::ulong_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
unsigned long
, boost::long_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::long_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
unsigned long
, boost::ulong_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::ulong_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
float
, boost::long_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::long_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
float
, boost::ulong_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::ulong_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
double
, boost::long_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::long_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
double
, boost::ulong_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::ulong_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
long double
, boost::long_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::long_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
long double
, boost::ulong_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::ulong_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
boost::long_long_type
, boost::long_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::long_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
boost::long_long_type
, boost::ulong_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::ulong_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
boost::ulong_long_type
, boost::long_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::long_long_type> rounding_policy;
};
template <>
struct numeric_cast_traits
<
boost::ulong_long_type
, boost::ulong_long_type
>
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<boost::ulong_long_type> rounding_policy;
};
}}

View File

@@ -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
//
///////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -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

View File

@@ -0,0 +1,30 @@
// (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_INT_FLOAT_MIXTURE_FLC_12NOV2002_HPP
#define BOOST_NUMERIC_CONVERSION_INT_FLOAT_MIXTURE_FLC_12NOV2002_HPP
#include "boost/numeric/conversion/detail/int_float_mixture.hpp"
namespace boost { namespace numeric
{
template<class T, class S>
struct int_float_mixture
: convdetail::get_int_float_mixture< BOOST_DEDUCED_TYPENAME remove_cv<T>::type
,BOOST_DEDUCED_TYPENAME remove_cv<S>::type
>::type {} ;
} } // namespace boost::numeric
#endif
//
///////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,29 @@
// (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_INT_FLOAT_MIXTURE_ENUM_FLC_12NOV2002_HPP
#define BOOST_NUMERIC_CONVERSION_INT_FLOAT_MIXTURE_ENUM_FLC_12NOV2002_HPP
namespace boost { namespace numeric
{
enum int_float_mixture_enum
{
integral_to_integral
,integral_to_float
,float_to_integral
,float_to_float
} ;
} } // namespace boost::numeric
#endif
//
///////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,27 @@
// (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_IS_SUBRANGED_FLC_12NOV2002_HPP
#define BOOST_NUMERIC_CONVERSION_IS_SUBRANGED_FLC_12NOV2002_HPP
#include "boost/numeric/conversion/detail/is_subranged.hpp"
namespace boost { namespace numeric {
template<class T, class S>
struct is_subranged
: convdetail::get_is_subranged< BOOST_DEDUCED_TYPENAME remove_cv<T>::type
,BOOST_DEDUCED_TYPENAME remove_cv<S>::type
>::type {} ;
} } // namespace boost::numeric
#endif

View File

@@ -0,0 +1,31 @@
//
//! Copyright (c) 2011
//! Brandon Kohn
//
// 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)
//
#ifndef BOOST_NUMERIC_CAST_TRAITS_HPP
#define BOOST_NUMERIC_CAST_TRAITS_HPP
#include <boost/numeric/conversion/converter_policies.hpp>
namespace boost { namespace numeric {
template <typename Target, typename Source, typename EnableIf = void>
struct numeric_cast_traits
{
typedef def_overflow_handler overflow_policy;
typedef UseInternalRangeChecker range_checking_policy;
typedef Trunc<Source> rounding_policy;
};
}}//namespace boost::numeric;
#if !defined( BOOST_NUMERIC_CONVERSION_RELAX_BUILT_IN_CAST_TRAITS )
#include <boost/cstdint.hpp>
#include <boost/numeric/conversion/detail/numeric_cast_traits.hpp>
#endif//!defined BOOST_NUMERIC_CONVERSION_RELAX_BUILT_IN_CAST_TRAITS
#endif//BOOST_NUMERIC_CAST_TRAITS_HPP

View File

@@ -0,0 +1,30 @@
// (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_SIGN_MIXTURE_FLC_12NOV2002_HPP
#define BOOST_NUMERIC_CONVERSION_SIGN_MIXTURE_FLC_12NOV2002_HPP
#include "boost/numeric/conversion/detail/sign_mixture.hpp"
namespace boost { namespace numeric
{
template<class T, class S>
struct sign_mixture
: convdetail::get_sign_mixture< BOOST_DEDUCED_TYPENAME remove_cv<T>::type
,BOOST_DEDUCED_TYPENAME remove_cv<S>::type
>::type {} ;
} } // namespace boost::numeric
#endif
//
///////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,29 @@
// (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_SIGN_MIXTURE_ENUM_FLC_12NOV2002_HPP
#define BOOST_NUMERIC_CONVERSION_SIGN_MIXTURE_ENUM_FLC_12NOV2002_HPP
namespace boost { namespace numeric
{
enum sign_mixture_enum
{
unsigned_to_unsigned
,signed_to_signed
,signed_to_unsigned
,unsigned_to_signed
} ;
} } // namespace boost::numeric
#endif
//
///////////////////////////////////////////////////////////////////////////////////////////////

View File

@@ -0,0 +1,28 @@
// (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_UDT_BUILTIN_MIXTURE_FLC_12NOV2002_HPP
#define BOOST_NUMERIC_CONVERSION_UDT_BUILTIN_MIXTURE_FLC_12NOV2002_HPP
#include "boost/numeric/conversion/detail/udt_builtin_mixture.hpp"
namespace boost { namespace numeric
{
template<class T, class S>
struct udt_builtin_mixture
: convdetail::get_udt_builtin_mixture< BOOST_DEDUCED_TYPENAME remove_cv<T>::type
,BOOST_DEDUCED_TYPENAME remove_cv<S>::type
>::type {} ;
} } // namespace boost::numeric
#endif

View File

@@ -0,0 +1,26 @@
// (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_UDT_BUILTIN_MIXTURE_ENUM_FLC_12NOV2002_HPP
#define BOOST_NUMERIC_CONVERSION_UDT_BUILTIN_MIXTURE_ENUM_FLC_12NOV2002_HPP
namespace boost { namespace numeric
{
enum udt_builtin_mixture_enum
{
builtin_to_builtin
,builtin_to_udt
,udt_to_builtin
,udt_to_udt
} ;
} } // namespace boost::numeric
#endif

View File

@@ -0,0 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,4 @@
The package boost is compatible with built-in CMake targets:
find_package(Boost REQUIRED [COMPONENTS <libs>...])
target_link_libraries(main PRIVATE Boost::boost Boost::<lib1> Boost::<lib2> ...)

View File

@@ -0,0 +1,115 @@
{
"$schema": "https://raw.githubusercontent.com/spdx/spdx-spec/v2.2.1/schemas/spdx-schema.json",
"spdxVersion": "SPDX-2.2",
"dataLicense": "CC0-1.0",
"SPDXID": "SPDXRef-DOCUMENT",
"documentNamespace": "https://spdx.org/spdxdocs/boost-numeric-conversion-x64-windows-1.79.0-0e5a2730-1dfe-4b9d-b78f-9d1f5e8af4b2",
"name": "boost-numeric-conversion:x64-windows@1.79.0 c7d1f700231348a54921287cb7cec7268ff76dcc995cb3242e25677261b23a02",
"creationInfo": {
"creators": [
"Tool: vcpkg-9268e366206712e38102b28dbd1617697a99ff2e"
],
"created": "2022-07-23T08:23:20Z"
},
"relationships": [
{
"spdxElementId": "SPDXRef-port",
"relationshipType": "GENERATES",
"relatedSpdxElement": "SPDXRef-binary"
},
{
"spdxElementId": "SPDXRef-port",
"relationshipType": "CONTAINS",
"relatedSpdxElement": "SPDXRef-file-0"
},
{
"spdxElementId": "SPDXRef-port",
"relationshipType": "CONTAINS",
"relatedSpdxElement": "SPDXRef-file-1"
},
{
"spdxElementId": "SPDXRef-binary",
"relationshipType": "GENERATED_FROM",
"relatedSpdxElement": "SPDXRef-port"
},
{
"spdxElementId": "SPDXRef-file-0",
"relationshipType": "CONTAINED_BY",
"relatedSpdxElement": "SPDXRef-port"
},
{
"spdxElementId": "SPDXRef-file-1",
"relationshipType": "CONTAINED_BY",
"relatedSpdxElement": "SPDXRef-port"
},
{
"spdxElementId": "SPDXRef-file-1",
"relationshipType": "DEPENDENCY_MANIFEST_OF",
"relatedSpdxElement": "SPDXRef-port"
}
],
"packages": [
{
"name": "boost-numeric-conversion",
"SPDXID": "SPDXRef-port",
"versionInfo": "1.79.0",
"downloadLocation": "NOASSERTION",
"homepage": "https://github.com/boostorg/numeric_conversion",
"licenseConcluded": "BSL-1.0",
"licenseDeclared": "NOASSERTION",
"copyrightText": "NOASSERTION",
"description": "Boost numeric_conversion module",
"comment": "This is the port (recipe) consumed by vcpkg."
},
{
"name": "boost-numeric-conversion:x64-windows",
"SPDXID": "SPDXRef-binary",
"versionInfo": "c7d1f700231348a54921287cb7cec7268ff76dcc995cb3242e25677261b23a02",
"downloadLocation": "NONE",
"licenseConcluded": "BSL-1.0",
"licenseDeclared": "NOASSERTION",
"copyrightText": "NOASSERTION",
"comment": "This is a binary package built by vcpkg."
},
{
"SPDXID": "SPDXRef-resource-1",
"name": "boostorg/numeric_conversion",
"downloadLocation": "git+https://github.com/boostorg/numeric_conversion@boost-1.79.0",
"licenseConcluded": "NOASSERTION",
"licenseDeclared": "NOASSERTION",
"copyrightText": "NOASSERTION",
"checksums": [
{
"algorithm": "SHA512",
"checksumValue": "87b357355ddf1dfb565e770dbbbaf6b8b3d7005237ab01610170152d9cf4d6f3d7ba4bec8b127bce876abaf322af46e92f921f39b3ae41bd150ed29ff53b021e"
}
]
}
],
"files": [
{
"fileName": "./portfile.cmake",
"SPDXID": "SPDXRef-file-0",
"checksums": [
{
"algorithm": "SHA256",
"checksumValue": "25a884bd1ef91ff8872b5eefd67a4a1b5e2a84ab511744751619884575bd7884"
}
],
"licenseConcluded": "NOASSERTION",
"copyrightText": "NOASSERTION"
},
{
"fileName": "./vcpkg.json",
"SPDXID": "SPDXRef-file-1",
"checksums": [
{
"algorithm": "SHA256",
"checksumValue": "ff3f33fdf755737aeb7b781c9f4ad10c50d018571bc0adf6e3ce32630fb76201"
}
],
"licenseConcluded": "NOASSERTION",
"copyrightText": "NOASSERTION"
}
]
}

View File

@@ -0,0 +1,19 @@
boost-config 797535e8975ed7cf5bbe11d9f7fe26caa5da8fe819888564758d82a21109fade
boost-conversion be5f99a73be1cda28552c3d6efdaf39ed065f34c78fcd7d45a71d30610fcfc26
boost-core 498aea0b6b68bcfe1ec683e76c2f0d32477dfe9ba958f518980ff806b6faba90
boost-mpl 89695bf75ab1fa2b706b2a0c2ef28c6726c3abd61ff51fb0966e3270153a6cd9
boost-preprocessor bf16615c7acc80769793c4f62c492a31cf3d22cd0d8393ccfd77d192da7c41b2
boost-throw-exception 4bb4a0182f0f071c3c1ffd9cbd82fbc3bc7db4a35346f930bbe504e7e3a94e0a
boost-type-traits 74f62124585467fbb6c4fa16015164d11e1a079d6bdb70ec1c3fe7cf65b9a594
boost-vcpkg-helpers c81c7b003df356a1a120a7c0c2f5a2ac95f3c33b006a2a5b4c02dcf0c9f3deaa
cmake 3.23.2
features core
portfile.cmake 25a884bd1ef91ff8872b5eefd67a4a1b5e2a84ab511744751619884575bd7884
ports.cmake 366c60b768113102408b32ac1d7c7b48ef7d30a477af2a220ecc222d9ffa3166
post_build_checks 2
powershell 7.2.5
triplet x64-windows
triplet_abi 4556164a2cd3dd6f4742101eabb46def7e71b6e5856faa88e5d005aac12a803c-c0600b35e024ce0485ed253ef5419f3686f7257cfb58cb6a24febcb600fc4b4c-27ebd443f77a6c449168adfa6ce8def60cf46e88
vcpkg.json ff3f33fdf755737aeb7b781c9f4ad10c50d018571bc0adf6e3ce32630fb76201
vcpkg_from_git 0aab20e34e84d52ba4763f009e539bfa8f418c41c918c8cf700156f1a8551a10
vcpkg_from_github b743742296a114ea1b18ae99672e02f142c4eb2bef7f57d36c038bedbfb0502f