annotate DEPENDENCIES/generic/include/boost/graph/numeric_values.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // (C) Copyright 2007-2009 Andrew Sutton
Chris@16 2 //
Chris@16 3 // Use, modification and distribution are subject to the
Chris@16 4 // Boost Software License, Version 1.0 (See accompanying file
Chris@16 5 // LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
Chris@16 6
Chris@16 7 #ifndef BOOST_GRAPH_NUMERIC_VALUES_HPP
Chris@16 8 #define BOOST_GRAPH_NUMERIC_VALUES_HPP
Chris@16 9
Chris@16 10 #include <limits>
Chris@16 11
Chris@16 12 namespace boost
Chris@16 13 {
Chris@16 14
Chris@16 15 #define BOOST_GRAPH_SPECIALIZE_NUMERIC_FLOAT(type) \
Chris@16 16 template <> struct numeric_values<type> { \
Chris@16 17 typedef type value_type; \
Chris@16 18 static type zero() { return 0.0; } \
Chris@16 19 static type infinity() { return std::numeric_limits<type>::infinity(); } \
Chris@16 20 };
Chris@16 21
Chris@16 22 /**
Chris@16 23 * This generic type reports various numeric values for some type. In the
Chris@16 24 * general case, numeric values simply treat their maximum value as infinity
Chris@16 25 * and the default-constructed value as 0.
Chris@16 26 *
Chris@16 27 * Specializations of this template can redefine the notions of zero and
Chris@16 28 * infinity for various types. For example, the class is specialized for
Chris@16 29 * floating point types to use the built in notion of infinity.
Chris@16 30 */
Chris@16 31 template <typename T>
Chris@16 32 struct numeric_values
Chris@16 33 {
Chris@16 34 typedef T value_type;
Chris@16 35
Chris@16 36 static T zero()
Chris@16 37 { return T(); }
Chris@16 38
Chris@16 39 static T infinity()
Chris@16 40 { return (std::numeric_limits<T>::max)(); }
Chris@16 41 };
Chris@16 42
Chris@16 43 // Specializations for floating point types refer to 0.0 and their infinity
Chris@16 44 // value defined by numeric_limits.
Chris@16 45 BOOST_GRAPH_SPECIALIZE_NUMERIC_FLOAT(float)
Chris@16 46 BOOST_GRAPH_SPECIALIZE_NUMERIC_FLOAT(double)
Chris@16 47 BOOST_GRAPH_SPECIALIZE_NUMERIC_FLOAT(long double)
Chris@16 48
Chris@16 49 #undef BOOST_GRAPH_SPECIALIZE_NUMERIC_VALUE
Chris@16 50 }
Chris@16 51
Chris@16 52 #endif