Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:59:42

0001 #ifndef BOOST_RANGE_VALUE_HPP
0002 #define BOOST_RANGE_VALUE_HPP
0003 
0004 //  Copyright (c) 2015 Robert Ramey
0005 //
0006 // Distributed under the Boost Software License, Version 1.0. (See
0007 // accompanying file LICENSE_1_0.txt or copy at
0008 // http://www.boost.org/LICENSE_1_0.txt)
0009 
0010 #include <iosfwd>
0011 
0012 // print range and value to a standard stream
0013 // make a simple wrapper
0014 template<typename T>
0015 struct range_value {
0016     // type requirement - a numeric type
0017     const T & m_t;
0018 
0019     constexpr range_value(const T & t)
0020     :   m_t(t)
0021     {}
0022 
0023 };
0024 
0025 template<typename T>
0026 constexpr range_value<T> make_range_value(const T & t){
0027     return range_value<T>(t);
0028 }
0029 
0030 #include "interval.hpp"
0031 
0032 template<
0033     class CharT,
0034     class Traits,
0035     class T
0036 >
0037 std::basic_ostream<CharT, Traits> & operator<<(
0038     std::basic_ostream<CharT, Traits> & os,
0039     const range_value<T> & t
0040 ){
0041     return os
0042         << boost::safe_numerics::make_interval<T>()
0043         << t.m_t;
0044 }
0045 
0046 template<typename T>
0047 struct result_display {
0048     const T & m_t;
0049     result_display(const T & t) :
0050         m_t(t)
0051     {}
0052 };
0053 
0054 template<typename T>
0055 inline result_display<T> make_result_display(const T & t){
0056     return result_display<T>(t);
0057 }
0058 
0059 template<typename CharT, typename Traits, typename T>
0060 inline std::basic_ostream<CharT, Traits> &
0061 operator<<(
0062     std::basic_ostream<CharT, Traits> & os,
0063     const result_display<T> & r
0064 ){
0065     return os
0066         << std::hex
0067         << make_range_value(r.m_t)
0068         << "(" << std::dec << r.m_t << ")";
0069 }
0070 
0071 #endif  // BOOST_RANGE_VALUE_HPP