Add pure annotation to simple maths and ntoh funcs
This commit is contained in:
parent
d6b943500c
commit
31796b34f6
@ -44,13 +44,13 @@ template double rootsquare ( int, int);
|
||||
|
||||
template <>
|
||||
bool
|
||||
almost_equal (float a, float b)
|
||||
almost_equal (const float &a, const float &b)
|
||||
{ return ieee_single::almost_equal (a, b); }
|
||||
|
||||
|
||||
template <>
|
||||
bool
|
||||
almost_equal (double a, double b)
|
||||
almost_equal (const double &a, const double &b)
|
||||
{ return ieee_double::almost_equal (a, b); }
|
||||
|
||||
|
||||
|
15
maths.hpp
15
maths.hpp
@ -20,15 +20,17 @@
|
||||
#ifndef __MATHS_HPP
|
||||
#define __MATHS_HPP
|
||||
|
||||
#include "annotations.hpp"
|
||||
|
||||
|
||||
template <typename T>
|
||||
T
|
||||
pow2 (T value);
|
||||
pow2 (T value) pure;
|
||||
|
||||
|
||||
template <typename T>
|
||||
double
|
||||
rootsquare (T a, T b);
|
||||
rootsquare (T a, T b) pure;
|
||||
|
||||
|
||||
/**
|
||||
@ -40,13 +42,13 @@ rootsquare (T a, T b);
|
||||
|
||||
template <typename T>
|
||||
bool
|
||||
almost_equal (T a, T b)
|
||||
almost_equal (const T &a, const T &b)
|
||||
{ return a == b; }
|
||||
|
||||
|
||||
template <typename Ta, typename Tb>
|
||||
bool
|
||||
almost_equal (Ta a, Tb b) {
|
||||
almost_equal (const Ta &a, const Tb &b) {
|
||||
return almost_equal <decltype(a + b)> (static_cast<decltype(a + b)>(a),
|
||||
static_cast<decltype(a + b)>(b));
|
||||
}
|
||||
@ -54,12 +56,12 @@ almost_equal (Ta a, Tb b) {
|
||||
|
||||
template <>
|
||||
bool
|
||||
almost_equal (float a, float b);
|
||||
almost_equal (const float &a, const float &b);
|
||||
|
||||
|
||||
template <>
|
||||
bool
|
||||
almost_equal (double a, double b);
|
||||
almost_equal (const double &a, const double &b);
|
||||
|
||||
|
||||
/// Variadic minimum
|
||||
@ -88,5 +90,4 @@ max (const T &a , const T &b , const Args &...args )
|
||||
{ return max ( b > a ? b : a, args...); }
|
||||
|
||||
|
||||
|
||||
#endif // __MATHS_HPP
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef __TYPES_HPP
|
||||
#define __TYPES_HPP
|
||||
|
||||
#include "annotations.hpp"
|
||||
#include "enable_if.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
@ -124,12 +125,12 @@ size_t elems(T (&)[N])
|
||||
|
||||
/// Convert a scalar from host byte order to network byte order
|
||||
template <typename T>
|
||||
T hton (T);
|
||||
T hton (T) pure;
|
||||
|
||||
|
||||
/// Convert a scalar from network byte order to host byte order
|
||||
template <typename T>
|
||||
T ntoh (T);
|
||||
T ntoh (T) pure;
|
||||
|
||||
|
||||
template <typename T, typename ...Args>
|
||||
|
Loading…
Reference in New Issue
Block a user