converter.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // (c) Copyright Fernando Luis Cacciola Carballal 2000-2004
  2. // Use, modification, and distribution is subject to the Boost Software
  3. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // See library home page at http://www.boost.org/libs/numeric/conversion
  6. //
  7. // Contact the author at: fernando_cacciola@hotmail.com
  8. //
  9. #ifndef BOOST_NUMERIC_CONVERSION_CONVERTER_FLC_12NOV2002_HPP
  10. #define BOOST_NUMERIC_CONVERSION_CONVERTER_FLC_12NOV2002_HPP
  11. #include "boost/numeric/conversion/conversion_traits.hpp"
  12. #include "boost/numeric/conversion/converter_policies.hpp"
  13. #include "boost/numeric/conversion/detail/converter.hpp"
  14. namespace boost { namespace numeric
  15. {
  16. template<class T,
  17. class S,
  18. class Traits = conversion_traits<T,S>,
  19. class OverflowHandler = def_overflow_handler,
  20. class Float2IntRounder = Trunc< BOOST_DEDUCED_TYPENAME Traits::source_type> ,
  21. class RawConverter = raw_converter<Traits>,
  22. class UserRangeChecker = UseInternalRangeChecker
  23. >
  24. struct converter : convdetail::get_converter_impl<Traits,
  25. OverflowHandler,
  26. Float2IntRounder,
  27. RawConverter,
  28. UserRangeChecker
  29. >::type
  30. {
  31. typedef Traits traits ;
  32. typedef typename Traits::argument_type argument_type ;
  33. typedef typename Traits::result_type result_type ;
  34. result_type operator() ( argument_type s ) const { return this->convert(s) ; }
  35. } ;
  36. template<class S,
  37. class OverflowHandler = def_overflow_handler,
  38. class Float2IntRounder = Trunc<S> ,
  39. class UserRangeChecker = UseInternalRangeChecker
  40. >
  41. struct make_converter_from
  42. {
  43. template<class T,
  44. class Traits = conversion_traits<T,S>,
  45. class RawConverter = raw_converter<Traits>
  46. >
  47. struct to
  48. {
  49. typedef converter<T,S,Traits,OverflowHandler,Float2IntRounder,RawConverter,UserRangeChecker> type ;
  50. } ;
  51. } ;
  52. } } // namespace boost::numeric
  53. #endif