Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yaml-cpp
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
yaml-cpp
Commits
b2f89386
Unverified
Commit
b2f89386
authored
Mar 11, 2020
by
Dekken
Committed by
GitHub
Mar 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split conversion call that uses std::signbit with unsupported parameters with enable_if (#824)
parent
1bfbd2be
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
15 deletions
+27
-15
include/yaml-cpp/node/convert.h
+27
-15
No files found.
include/yaml-cpp/node/convert.h
View file @
b2f89386
...
...
@@ -23,6 +23,7 @@
#include "yaml-cpp/node/type.h"
#include "yaml-cpp/null.h"
namespace
YAML
{
class
Binary
;
struct
_Null
;
...
...
@@ -90,27 +91,38 @@ struct convert<_Null> {
}
};
namespace
conversion
{
template
<
typename
T
>
typename
std
::
enable_if
<
std
::
is_floating_point
<
T
>::
value
,
void
>::
type
inner_encode
(
const
T
&
rhs
,
std
::
stringstream
&
stream
){
if
(
std
::
isnan
(
rhs
))
{
stream
<<
".nan"
;
}
else
if
(
std
::
isinf
(
rhs
))
{
if
(
std
::
signbit
(
rhs
))
{
stream
<<
"-.inf"
;
}
else
{
stream
<<
".inf"
;
}
}
else
{
stream
<<
rhs
;
}
}
template
<
typename
T
>
typename
std
::
enable_if
<!
std
::
is_floating_point
<
T
>::
value
,
void
>::
type
inner_encode
(
const
T
&
rhs
,
std
::
stringstream
&
stream
){
stream
<<
rhs
;
}
}
#define YAML_DEFINE_CONVERT_STREAMABLE(type, negative_op) \
template <> \
struct convert<type> { \
\
static Node encode(const type& rhs) { \
std::stringstream stream; \
stream.precision(std::numeric_limits<type>::max_digits10); \
if (std::is_floating_point<type>::value) { \
if (std::isnan(rhs)) { \
stream << ".nan"; \
} else if (std::isinf(rhs)) { \
if (std::signbit(rhs)) { \
stream << "-.inf"; \
} else { \
stream << ".inf"; \
} \
} else { \
stream << rhs; \
} \
} else { \
stream << rhs; \
} \
conversion::inner_encode(rhs, stream); \
return Node(stream.str()); \
} \
\
...
...
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