fix doc example typo
[boost.git] / boost / graph / numeric_values.hpp
blobad01837270a5b828d28cf4d8c0cb5cdbd4713444
1 // (C) Copyright 2007-2009 Andrew Sutton
2 //
3 // Use, modification and distribution are subject to the
4 // Boost Software License, Version 1.0 (See accompanying file
5 // LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef BOOST_GRAPH_NUMERIC_VALUES_HPP
8 #define BOOST_GRAPH_NUMERIC_VALUES_HPP
10 #include <limits>
12 namespace boost
15 #define BOOST_GRAPH_SPECIALIZE_NUMERIC_FLOAT(type) \
16 template <> struct numeric_values<type> { \
17 typedef type value_type; \
18 static type zero() { return 0.0; } \
19 static type infinity() { return std::numeric_limits<type>::infinity(); } \
22 /**
23 * This generic type reports various numeric values for some type. In the
24 * general case, numeric values simply treat their maximum value as infinity
25 * and the default-constructed value as 0.
27 * Specializations of this template can redefine the notions of zero and
28 * infinity for various types. For example, the class is specialized for
29 * floating point types to use the built in notion of infinity.
31 template <typename T>
32 struct numeric_values
34 typedef T value_type;
36 static T zero()
37 { return T(); }
39 static T infinity()
40 { return (std::numeric_limits<T>::max)(); }
43 // Specializations for floating point types refer to 0.0 and their infinity
44 // value defined by numeric_limits.
45 BOOST_GRAPH_SPECIALIZE_NUMERIC_FLOAT(float)
46 BOOST_GRAPH_SPECIALIZE_NUMERIC_FLOAT(double)
47 BOOST_GRAPH_SPECIALIZE_NUMERIC_FLOAT(long double)
49 #undef BOOST_GRAPH_SPECIALIZE_NUMERIC_VALUE
52 #endif