1 // Copyright (c) 2018 Robert Ramey
3 // Distributed under the Boost Software License, Version 1.0. (See
4 // accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef BOOST_SAFE_FORMAT_HPP
8 #define BOOST_SAFE_FORMAT_HPP
10 // Copyright (c) 2015 Robert Ramey
12 // Distributed under the Boost Software License, Version 1.0. (See
13 // accompanying file LICENSE_1_0.txt or copy at
14 // http://www.boost.org/LICENSE_1_0.txt)
19 #include <boost/core/demangle.hpp>
20 #include <boost/safe_numerics/safe_common.hpp>
24 // create an output manipulator which prints variable type and limits
27 struct safe_format_impl {
29 safe_format_impl(const T & t) :
32 template <class charT, class Traits>
33 friend std::basic_ostream<charT,Traits> &
35 std::basic_ostream<charT,Traits> & os,
36 const safe_format_impl<T> & f
40 << boost::core::demangle(typeid(
41 typename boost::safe_numerics::base_type<T>::type
45 << std::numeric_limits<T>::min() << ","
46 << std::numeric_limits<T>::max() << "] = "
51 } // anonymous namespace
54 auto safe_format(const T & t){
55 return safe_format_impl<T>(t);
58 #endif // BOOST_SAFE_FORMAT_HPP