Debian Codegraph @

third-party/boost-math/include/boost/math/special_functions/detail/iconv.hpp

raw
1 // Copyright (c) 2009 John Maddock
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #ifndef BOOST_MATH_ICONV_HPP
7 #define BOOST_MATH_ICONV_HPP
8
9 #ifdef _MSC_VER
10 #pragma once
11 #endif
12
13 #include <boost/math/tools/config.hpp>
14 #include <boost/math/tools/type_traits.hpp>
15 #include <boost/math/special_functions/round.hpp>
16
17 namespace boost { namespace math { namespace detail{
18
19 template <class T, class Policy>
20 BOOST_MATH_GPU_ENABLED inline int iconv_imp(T v, Policy const&, boost::math::true_type const&)
21 {
22 return static_cast<int>(v);
23 }
24
25 template <class T, class Policy>
26 BOOST_MATH_GPU_ENABLED inline int iconv_imp(T v, Policy const& pol, boost::math::false_type const&)
27 {
28 BOOST_MATH_STD_USING
29 return iround(v, pol);
30 }
31
32 template <class T, class Policy>
33 BOOST_MATH_GPU_ENABLED inline int iconv(T v, Policy const& pol)
34 {
35 typedef typename boost::math::is_convertible<T, int>::type tag_type;
36 return iconv_imp(v, pol, tag_type());
37 }
38
39
40 }}} // namespaces
41
42 #endif // BOOST_MATH_ICONV_HPP
43