Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
fe410de2
Commit
fe410de2
authored
Aug 08, 2013
by
Davis King
Browse files
Added is_finite()
parent
99109823
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
dlib/algs.h
dlib/algs.h
+21
-0
No files found.
dlib/algs.h
View file @
fe410de2
...
...
@@ -67,6 +67,7 @@ namespace std
#include <algorithm> // for std::swap
#include <new> // for std::bad_alloc
#include <cstdlib>
#include <limits> // for std::numeric_limits for is_finite()
#include "assert.h"
#include "error.h"
#include "noncopyable.h"
...
...
@@ -450,6 +451,26 @@ namespace dlib
template
<
>
struct
is_float_type
<
double
>
{
const
static
bool
value
=
true
;
};
template
<
>
struct
is_float_type
<
long
double
>
{
const
static
bool
value
=
true
;
};
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
bool
is_finite
(
const
T
&
value
)
/*!
ensures
- returns true if value is a finite value (e.g. not infinity or NaN) and false
otherwise.
!*/
{
if
(
is_float_type
<
T
>::
value
)
return
-
std
::
numeric_limits
<
T
>::
infinity
()
<
value
&&
value
<
std
::
numeric_limits
<
T
>::
infinity
();
else
return
true
;
}
// ----------------------------------------------------------------------------------------
/*!A is_convertible
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment