Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
c1a8dfe5
Commit
c1a8dfe5
authored
Nov 17, 2015
by
vitaut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve detection of signbit
parent
d9e0f5c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
19 deletions
+35
-19
format.h
format.h
+35
-19
No files found.
format.h
View file @
c1a8dfe5
...
...
@@ -579,18 +579,45 @@ class FixedBuffer : public fmt::Buffer<Char> {
void
grow
(
std
::
size_t
size
);
};
#ifndef _MSC_VER
template
<
typename
T
=
void
>
struct
Null
{};
// Dummy implementations of signbit and _ecvt_s called if corresponding system
// functions are not available.
inline
Null
<>
signbit
(...)
{
return
Null
<>
();
}
inline
Null
<>
_ecvt_s
(...)
{
return
Null
<>
();
}
// Portable version of signbit.
inline
int
getsign
(
double
x
)
{
// When compiled in C++11 mode signbit is no longer a macro but a function
// defined in namespace std and the macro is undefined.
# ifdef signbit
return
signbit
(
x
);
# else
return
std
::
signbit
(
x
);
# endif
class
SignBit
{
private:
double
value_
;
int
handle
(
int
result
)
{
return
result
;
}
int
handle
(
fmt
::
internal
::
Null
<>
)
{
if
(
value_
<
0
)
return
1
;
if
(
value_
==
value_
)
return
0
;
int
dec
=
0
,
sign
=
0
;
char
buffer
[
2
];
// The buffer size must be >= 2 or _ecvt_s will fail.
_ecvt_s
(
buffer
,
sizeof
(
buffer
),
value_
,
0
,
&
dec
,
&
sign
);
return
sign
;
}
public:
SignBit
(
double
value
)
:
value_
(
value
)
{}
int
call
()
{
// When compiled in C++11 mode signbit is no longer a macro but a
// function defined in namespace std and the macro is undefined.
using
namespace
std
;
return
handle
(
signbit
(
value_
));
}
};
return
SignBit
(
x
).
call
();
}
#ifndef _MSC_VER
// Portable version of isinf.
# ifdef isinf
inline
int
isinfinity
(
double
x
)
{
return
isinf
(
x
);
}
...
...
@@ -609,14 +636,6 @@ inline int isnotanumber(double x) { return std::isnan(x); }
inline
int
isnotanumber
(
long
double
x
)
{
return
std
::
isnan
(
x
);
}
# endif
#else
inline
int
getsign
(
double
value
)
{
if
(
value
<
0
)
return
1
;
if
(
value
==
value
)
return
0
;
int
dec
=
0
,
sign
=
0
;
char
buffer
[
2
];
// The buffer size must be >= 2 or _ecvt_s will fail.
_ecvt_s
(
buffer
,
sizeof
(
buffer
),
value
,
0
,
&
dec
,
&
sign
);
return
sign
;
}
inline
int
isinfinity
(
double
x
)
{
return
!
_finite
(
x
);
}
inline
int
isinfinity
(
long
double
x
)
{
return
!
_finite
(
static_cast
<
double
>
(
x
));
...
...
@@ -895,9 +914,6 @@ struct Arg : Value {
template
<
typename
Char
>
struct
NamedArg
;
template
<
typename
T
=
void
>
struct
Null
{};
// A helper class template to enable or disable overloads taking wide
// characters and strings in MakeValue.
template
<
typename
T
,
typename
Char
>
...
...
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