1 #ifndef BOOST_SAFE_FORMAT_HPP
2 #define BOOST_SAFE_FORMAT_HPP
4 // Copyright (c) 2015 Robert Ramey
6 // Distributed under the Boost Software License, Version 1.0. (See
7 // accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
13 #include <boost/core/demangle.hpp>
14 #include <boost/safe_numerics/safe_common.hpp>
18 // create an output manipulator which prints variable type and limits
21 struct safe_format_impl {
23 safe_format_impl(const T & t) :
26 template <class charT, class Traits>
27 friend std::basic_ostream<charT,Traits> &
29 std::basic_ostream<charT,Traits> & os,
30 const safe_format_impl<T> & f
34 << boost::core::demangle(typeid(
35 typename boost::safe_numerics::base_type<T>::type
39 << std::numeric_limits<T>::min() << ","
40 << std::numeric_limits<T>::max() << "] = "
45 } // anonymous namespace
48 auto safe_format(const T & t){
49 return safe_format_impl<T>(t);
52 #endif // BOOST_SAFE_FORMAT_HPP