Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
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
Chen Yisong
json
Commits
4d7c2992
Unverified
Commit
4d7c2992
authored
Mar 12, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Plain Diff
🚑
fix for #486
Implemented std::less<value_t> to allow using value_t as std::map key in MSVC.
parents
ff0b18d1
f4126e4d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
0 deletions
+39
-0
json.hpp
src/json.hpp
+16
-0
json.hpp.re2c
src/json.hpp.re2c
+16
-0
unit-regression.cpp
test/src/unit-regression.cpp
+7
-0
No files found.
src/json.hpp
View file @
4d7c2992
...
@@ -13048,6 +13048,22 @@ struct hash<nlohmann::json>
...
@@ -13048,6 +13048,22 @@ struct hash<nlohmann::json>
return
h
(
j
.
dump
());
return
h
(
j
.
dump
());
}
}
};
};
/// specialization for std::less<value_t>
template
<>
struct
less
<::
nlohmann
::
detail
::
value_t
>
{
/*!
@brief compare two value_t enum values
@since version 3.0.0
*/
bool
operator
()(
nlohmann
::
detail
::
value_t
lhs
,
nlohmann
::
detail
::
value_t
rhs
)
const
noexcept
{
return
nlohmann
::
detail
::
operator
<
(
lhs
,
rhs
);
}
};
}
// namespace std
}
// namespace std
/*!
/*!
...
...
src/json.hpp.re2c
View file @
4d7c2992
...
@@ -12082,6 +12082,22 @@ struct hash<nlohmann::json>
...
@@ -12082,6 +12082,22 @@ struct hash<nlohmann::json>
return h(j.dump());
return h(j.dump());
}
}
};
};
/// specialization for std::less<value_t>
template <>
struct less<::nlohmann::detail::value_t>
{
/*!
@brief compare two value_t enum values
@since version 3.0.0
*/
bool operator()(nlohmann::detail::value_t lhs,
nlohmann::detail::value_t rhs) const noexcept
{
return nlohmann::detail::operator<(lhs, rhs);
}
};
} // namespace std
} // namespace std
/*!
/*!
...
...
test/src/unit-regression.cpp
View file @
4d7c2992
...
@@ -796,6 +796,13 @@ TEST_CASE("regression tests")
...
@@ -796,6 +796,13 @@ TEST_CASE("regression tests")
CHECK
(
s1
==
s2
);
CHECK
(
s1
==
s2
);
}
}
SECTION
(
"issue #486 - json::value_t can't be a map's key type in VC++ 2015"
)
{
// the code below must compile with MSVC
std
::
map
<
json
::
value_t
,
std
::
string
>
jsonTypes
;
jsonTypes
[
json
::
value_t
::
array
]
=
"array"
;
}
SECTION
(
"issue #494 - conversion from vector<bool> to json fails to build"
)
SECTION
(
"issue #494 - conversion from vector<bool> to json fails to build"
)
{
{
std
::
vector
<
bool
>
boolVector
=
{
false
,
true
,
false
,
false
};
std
::
vector
<
bool
>
boolVector
=
{
false
,
true
,
false
,
false
};
...
...
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