/usr/include/boost/safe_numerics
Edit: /usr/include/boost/safe_numerics/range_value.hpp (1491B)
#ifndef BOOST_RANGE_VALUE_HPP
#define BOOST_RANGE_VALUE_HPP
// Copyright (c) 2015 Robert Ramey
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include
// print range and value to a standard stream
// make a simple wrapper
template
struct range_value {
// type requirement - a numeric type
const T & m_t;
constexpr range_value(const T & t)
: m_t(t)
{}
};
template
constexpr range_value make_range_value(const T & t){
return range_value(t);
}
#include "interval.hpp"
template<
class CharT,
class Traits,
class T
>
std::basic_ostream & operator<<(
std::basic_ostream & os,
const range_value & t
){
return os
<< boost::safe_numerics::make_interval()
<< t.m_t;
}
template
struct result_display {
const T & m_t;
result_display(const T & t) :
m_t(t)
{}
};
template
result_display make_result_display(const T & t){
return result_display(t);
}
template
inline std::basic_ostream &
operator<<(
std::basic_ostream & os,
const result_display & r
){
return os
<< std::hex
<< make_range_value(r.m_t)
<< "(" << std::dec << r.m_t << ")";
}
#endif // BOOST_RANGE_VALUE_HPP