Move range to the util namespace
This commit is contained in:
parent
6e73c22d91
commit
306f852fc7
@ -30,7 +30,7 @@ using namespace std;
|
||||
const ipv4::ip ipv4::ip::LOOPBACK (127, 0, 0, 1);
|
||||
const ipv4::ip ipv4::ip::ANY ( 0, 0, 0, 0);
|
||||
|
||||
const range<ipv4::port> ipv4::WELL_KNOWN_PORT ( 0, 1023),
|
||||
const util::range<ipv4::port> ipv4::WELL_KNOWN_PORT ( 0, 1023),
|
||||
ipv4::REGISTERED_PORT ( 1024, 49151),
|
||||
ipv4::PRIVATE_PORT (49152, 65535);
|
||||
|
||||
|
2
ip.hpp
2
ip.hpp
@ -52,7 +52,7 @@ namespace ipv4 {
|
||||
typedef uint16_t port;
|
||||
typedef uint32_t mask;
|
||||
|
||||
extern const range<port> WELL_KNOWN_PORT,
|
||||
extern const util::range<port> WELL_KNOWN_PORT,
|
||||
REGISTERED_PORT,
|
||||
PRIVATE_PORT;
|
||||
}
|
||||
|
@ -25,9 +25,9 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace util;
|
||||
using namespace maths;
|
||||
|
||||
|
||||
matrix::matrix (size_t _rows, size_t _columns):
|
||||
m_rows (_rows),
|
||||
m_columns (_columns),
|
||||
|
15
range.cpp
15
range.cpp
@ -8,6 +8,7 @@
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace util;
|
||||
|
||||
|
||||
/*
|
||||
@ -81,18 +82,20 @@ range<T>::rand (void) const {
|
||||
}
|
||||
|
||||
|
||||
template <>
|
||||
bool
|
||||
range<float>::operator ==(const range<float> &rhs) const
|
||||
namespace util {
|
||||
template <>
|
||||
bool
|
||||
range<float>::operator ==(const range<float> &rhs) const
|
||||
{ return almost_equal (min, rhs.min) &&
|
||||
almost_equal (max, rhs.max); }
|
||||
|
||||
|
||||
template <>
|
||||
bool
|
||||
range<double>::operator ==(const range<double> &rhs) const
|
||||
template <>
|
||||
bool
|
||||
range<double>::operator ==(const range<double> &rhs) const
|
||||
{ return almost_equal (min, rhs.min) &&
|
||||
almost_equal (max, rhs.max); }
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
|
17
range.hpp
17
range.hpp
@ -23,13 +23,13 @@
|
||||
|
||||
#include "json.hpp"
|
||||
|
||||
|
||||
/**
|
||||
namespace util {
|
||||
/**
|
||||
* Represents a continuous range of values. Contains convenience functions
|
||||
* and debugging checks.
|
||||
*/
|
||||
template <typename T>
|
||||
struct range {
|
||||
template <typename T>
|
||||
struct range {
|
||||
T min;
|
||||
T max;
|
||||
|
||||
@ -63,14 +63,15 @@ struct range {
|
||||
static const range <T> UNIT;
|
||||
|
||||
void sanity (void) const;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
std::ostream&
|
||||
operator <<(std::ostream &os, const range<T> &rhs) {
|
||||
template <typename T>
|
||||
std::ostream&
|
||||
operator <<(std::ostream &os, const range<T> &rhs) {
|
||||
os << '[' << rhs.min << ", " << rhs.max << ']';
|
||||
return os;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user