forked from boostorg/conversion
Set precision correctly for builtin and UDT floating types.
[SVN r35562]
This commit is contained in:
@ -5,8 +5,8 @@
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_DETAIL_LCAST_SET_PRECISION_HPP_INCLUDED
|
||||
#define BOOST_DETAIL_LCAST_SET_PRECISION_HPP_INCLUDED
|
||||
#ifndef BOOST_DETAIL_LCAST_PRECISION_HPP_INCLUDED
|
||||
#define BOOST_DETAIL_LCAST_PRECISION_HPP_INCLUDED
|
||||
|
||||
#include <climits>
|
||||
#include <ios>
|
||||
@ -28,7 +28,7 @@ namespace boost { namespace detail {
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (push)
|
||||
// conditional expression is constant (stream precision)
|
||||
// conditional expression is constant
|
||||
#pragma warning (disable : 4127)
|
||||
#endif
|
||||
|
||||
@ -85,7 +85,7 @@ inline std::streamsize lcast_get_precision()
|
||||
// radix = 10 and digits10 == the number of decimal digits.
|
||||
|
||||
return 6;
|
||||
} // template<class T> bool lcast_set_precision(std::ios_base& stream)
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void lcast_set_precision(std::ios_base& stream)
|
||||
@ -109,5 +109,5 @@ inline void lcast_set_precision(std::ios_base& stream)
|
||||
|
||||
#undef BOOST_DETAIL_LCAST_ASSERT
|
||||
|
||||
#endif // BOOST_DETAIL_LCAST_SET_PRECISION_HPP_INCLUDED
|
||||
#endif // BOOST_DETAIL_LCAST_PRECISION_HPP_INCLUDED
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
#include <boost/call_traits.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/detail/lcast_precision.hpp>
|
||||
|
||||
#ifdef BOOST_NO_STRINGSTREAM
|
||||
#include <strstream>
|
||||
@ -458,25 +459,7 @@ namespace boost
|
||||
lexical_stream(char_type* = 0, char_type* = 0)
|
||||
{
|
||||
stream.unsetf(std::ios::skipws);
|
||||
|
||||
#if (defined _MSC_VER)
|
||||
# pragma warning( push )
|
||||
// conditional expression is constant
|
||||
# pragma warning( disable : 4127 )
|
||||
#endif
|
||||
|
||||
typedef std::numeric_limits<Target> t;
|
||||
typedef std::numeric_limits<Source> s;
|
||||
|
||||
if(t::is_specialized)
|
||||
stream.precision(1 + t::digits10);
|
||||
else if(s::is_specialized)
|
||||
stream.precision(1 + s::digits10);
|
||||
|
||||
#if (defined _MSC_VER)
|
||||
# pragma warning( pop )
|
||||
#endif
|
||||
|
||||
lcast_set_precision<Source, Target>(stream);
|
||||
}
|
||||
~lexical_stream()
|
||||
{
|
||||
@ -626,8 +609,7 @@ namespace boost
|
||||
|
||||
typedef std::numeric_limits<InputStreamable> limits;
|
||||
|
||||
if(limits::is_specialized)
|
||||
stream.precision(limits::digits10 + 1);
|
||||
lcast_set_precision<InputStreamable>(stream);
|
||||
#if (defined _MSC_VER)
|
||||
# pragma warning( pop )
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user