/usr/include/boost/multiprecision/detail
Edit: /usr/include/boost/multiprecision/detail/min_max.hpp (5120B)
///////////////////////////////////////////////////////////////////////////////
// Copyright 2016 John Maddock. 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)
#ifndef BOOST_MP_MIN_MAX_HPP
#define BOOST_MP_MIN_MAX_HPP
#include
namespace boost { namespace multiprecision {
//
// Expression template overloads for (min) and (max):
//
// Introduced in response to https://svn.boost.org/trac/boost/ticket/11149
// note that these can not legally be injected into namespace std, and that doing so
// may break future enhancements to the standard. None the less adding
// namespace std{ using boost::multiprecision::(min); using boost::multiprecision::(max); }
// to your code may get some generic code working that wouldn't work otherwise.
//
// The use of enable_if on the return type is to avoid poisoning std::min/max,
// otherwise attempting to make an explicit call to min(a, b) when these and std
// versions are in scope, will cause the compiler to try to instantiate the signatures
// for our versions as well as the std ones, which in turn instantiates number
// which fails to compile as "long" is not a valid backend type.
//
template
inline typename boost::enable_if_c::value, const number&>::type(min)(const number& a, const number& b)
{
return a < b ? a : b;
}
template
inline typename boost::enable_if_c::value, const number >::type(min)(const number& a, const detail::expression& b)
{
number t(b);
if (a < t)
return a;
return BOOST_MP_MOVE(t);
}
template
inline typename boost::enable_if_c::value, const number >::type(min)(const detail::expression& a, const number& b)
{
number t(a);
if (t < b)
return BOOST_MP_MOVE(t);
return b;
}
template
inline typename detail::expression::result_type(min)(const detail::expression& a, const detail::expression& b)
{
typename detail::expression::result_type t1(a), t2(b);
if (t1 < t2)
return BOOST_MP_MOVE(t1);
return BOOST_MP_MOVE(t2);
}
template
inline typename detail::expression::result_type(min)(const detail::expression& a, const detail::expression& b)
{
typename detail::expression::result_type t1(a), t2(b);
if (t1 < t2)
return BOOST_MP_MOVE(t1);
return BOOST_MP_MOVE(t2);
}
template
inline typename boost::enable_if_c::value, const number&>::type(max)(const number& a, const number& b)
{
return a > b ? a : b;
}
template
inline typename boost::enable_if_c::value, const number >::type(max)(const number& a, const detail::expression& b)
{
number t(b);
if (a > t)
return a;
return BOOST_MP_MOVE(t);
}
template
inline typename boost::enable_if_c::value, const number >::type(max)(const detail::expression& a, const number& b)
{
number t(a);
if (t > b)
return BOOST_MP_MOVE(t);
return b;
}
template
inline typename detail::expression::result_type(max)(const detail::expression& a, const detail::expression& b)
{
typename detail::expression::result_type t1(a), t2(b);
if (t1 > t2)
return BOOST_MP_MOVE(t1);
return BOOST_MP_MOVE(t2);
}
template
inline typename detail::expression::result_type(max)(const detail::expression& a, const detail::expression& b)
{
typename detail::expression::result_type t1(a), t2(b);
if (t1 > t2)
return BOOST_MP_MOVE(t1);
return BOOST_MP_MOVE(t2);
}
}} // namespace boost::multiprecision
#endif