]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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/special_functions/round.hpp> | |
14 | #include <boost/type_traits/is_convertible.hpp> | |
15 | ||
16 | namespace boost { namespace math { namespace detail{ | |
17 | ||
18 | template <class T, class Policy> | |
19 | inline int iconv_imp(T v, Policy const&, mpl::true_ const&) | |
20 | { | |
21 | return static_cast<int>(v); | |
22 | } | |
23 | ||
24 | template <class T, class Policy> | |
25 | inline int iconv_imp(T v, Policy const& pol, mpl::false_ const&) | |
26 | { | |
27 | BOOST_MATH_STD_USING | |
28 | return iround(v, pol); | |
29 | } | |
30 | ||
31 | template <class T, class Policy> | |
32 | inline int iconv(T v, Policy const& pol) | |
33 | { | |
34 | typedef typename boost::is_convertible<T, int>::type tag_type; | |
35 | return iconv_imp(v, pol, tag_type()); | |
36 | } | |
37 | ||
38 | ||
39 | }}} // namespaces | |
40 | ||
41 | #endif // BOOST_MATH_ICONV_HPP | |
42 |