3 #ifndef CPPQEDCORE_UTILS_CONVERSIONS_H_INCLUDED
4 #define CPPQEDCORE_UTILS_CONVERSIONS_H_INCLUDED
6 #include "ConversionsFwd.h"
8 #include <boost/mpl/identity.hpp>
10 #include <boost/numeric/conversion/converter.hpp>
21 struct DummyRangeCheckerPolicy
23 typedef typename T::argument_type argument_type;
24 static boost::numeric::range_check_result out_of_range(argument_type) {
return boost::numeric::cInRange;}
25 static void validate_range(argument_type) {}
31 boost::numeric:: def_overflow_handler
33 boost::numeric::silent_overflow_handler
38 template<
class T>
struct RangeCheckerMF : boost::mpl::identity<
40 boost::numeric::UseInternalRangeChecker
42 DummyRangeCheckerPolicy<T>
52 template<
typename T,
typename S>
54 boost::numeric::conversion_traits<T,S>,
55 cpputils::details::OverflowHandler,
56 boost::numeric::Trunc<typename boost::numeric::conversion_traits<T,S>::source_type>,
57 boost::numeric::raw_converter<boost::numeric::conversion_traits<T,S> >,
58 typename cpputils::details::RangeCheckerMF<boost::numeric::conversion_traits<T,S> >::type
68 typedef boost::numeric::converter<int,
70 boost::numeric::conversion_traits<int,double>,
71 cpputils::details::OverflowHandler,
72 boost::numeric::Trunc<boost::numeric::conversion_traits<int,double>::source_type>,
73 boost::numeric::raw_converter<boost::numeric::conversion_traits<int,double> >,
74 cpputils::details::RangeCheckerMF<boost::numeric::conversion_traits<int,double> >::type
77 const Double2Int double2Int=Double2Int();
82 typedef boost::numeric::converter<int,
84 boost::numeric::conversion_traits<int,long>,
85 cpputils::details::OverflowHandler,
86 boost::numeric::Trunc<boost::numeric::conversion_traits<int,long>::source_type>,
87 boost::numeric::raw_converter<boost::numeric::conversion_traits<int,long> >,
88 cpputils::details::RangeCheckerMF<boost::numeric::conversion_traits<int,long> >::type
91 const Long2Int long2Int=Long2Int();
96 typedef boost::numeric::converter<int,
98 boost::numeric::conversion_traits<int,size_t>,
99 cpputils::details::OverflowHandler,
100 boost::numeric::Trunc<boost::numeric::conversion_traits<int,size_t>::source_type>,
101 boost::numeric::raw_converter<boost::numeric::conversion_traits<int,size_t> >,
102 cpputils::details::RangeCheckerMF<boost::numeric::conversion_traits<int,size_t> >::type
105 const Size2Int size2Int=Size2Int();
110 typedef boost::numeric::converter<int,
112 boost::numeric::conversion_traits<int,ptrdiff_t>,
113 cpputils::details::OverflowHandler,
114 boost::numeric::Trunc<boost::numeric::conversion_traits<int,ptrdiff_t>::source_type>,
115 boost::numeric::raw_converter<boost::numeric::conversion_traits<int,ptrdiff_t> >,
116 cpputils::details::RangeCheckerMF<boost::numeric::conversion_traits<int,ptrdiff_t> >::type
119 const Idx2Int idx2Int=Idx2Int();
124 typedef boost::numeric::converter<size_t,
126 boost::numeric::conversion_traits<size_t,int>,
127 cpputils::details::OverflowHandler,
128 boost::numeric::Trunc<boost::numeric::conversion_traits<size_t,int>::source_type>,
129 boost::numeric::raw_converter<boost::numeric::conversion_traits<size_t,int> >,
130 cpputils::details::RangeCheckerMF<boost::numeric::conversion_traits<size_t,int> >::type
133 const Int2Size int2Size=Int2Size();
138 typedef boost::numeric::converter<double,
140 boost::numeric::conversion_traits<double,size_t>,
141 cpputils::details::OverflowHandler,
142 boost::numeric::Trunc<boost::numeric::conversion_traits<double,size_t>::source_type>,
143 boost::numeric::raw_converter<boost::numeric::conversion_traits<double,size_t> >,
144 cpputils::details::RangeCheckerMF<boost::numeric::conversion_traits<double,size_t> >::type
147 const Size2Double size2Double=Size2Double();
149 #endif // CPPQEDCORE_UTILS_CONVERSIONS_H_INCLUDED
Namespace comprising otherwise hard-to-classify generic utilities.