44 lines · plain
1// Copyright (c) 2009 John Maddock2// Use, modification and distribution are subject to the3// Boost Software License, Version 1.0. (See accompanying file4// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)5 6#ifndef BOOST_MATH_ICONV_HPP7#define BOOST_MATH_ICONV_HPP8 9#ifdef _MSC_VER10#pragma once11#endif12 13#include <boost/math/tools/config.hpp>14#include <boost/math/tools/type_traits.hpp>15#include <boost/math/special_functions/round.hpp>16 17namespace boost { namespace math { namespace detail{18 19template <class T, class Policy>20BOOST_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 25template <class T, class Policy>26BOOST_MATH_GPU_ENABLED inline int iconv_imp(T v, Policy const& pol, boost::math::false_type const&)27{28 BOOST_MATH_STD_USING29 return iround(v, pol);30}31 32template <class T, class Policy>33BOOST_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}}} // namespaces41 42#endif // BOOST_MATH_ICONV_HPP43 44