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
6ee9e5f4
Unverified
Commit
6ee9e5f4
authored
Jun 20, 2020
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
⚗
remove const from value type
parent
4fd0d02b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
45 deletions
+37
-45
ordered_map.hpp
include/nlohmann/ordered_map.hpp
+16
-22
json.hpp
single_include/nlohmann/json.hpp
+21
-23
No files found.
include/nlohmann/ordered_map.hpp
View file @
6ee9e5f4
...
@@ -10,14 +10,15 @@ namespace nlohmann
...
@@ -10,14 +10,15 @@ namespace nlohmann
/// ordered_map: a minimal map-like container that preserves insertion order
/// ordered_map: a minimal map-like container that preserves insertion order
/// for use within nlohmann::basic_json<ordered_map>
/// for use within nlohmann::basic_json<ordered_map>
template
<
class
Key
,
class
T
,
class
IgnoredLess
=
std
::
less
<
Key
>
,
template
<
class
Key
,
class
T
,
class
IgnoredLess
=
std
::
less
<
Key
>
,
class
Allocator
=
std
::
allocator
<
std
::
pair
<
const
Key
,
T
>>
,
class
Allocator
=
std
::
allocator
<
std
::
pair
<
Key
,
T
>>
,
class
Container
=
std
::
vector
<
std
::
pair
<
const
Key
,
T
>
,
Allocator
>>
class
Container
=
std
::
vector
<
std
::
pair
<
Key
,
T
>
,
Allocator
>>
struct
ordered_map
:
Container
struct
ordered_map
:
Container
{
{
using
key_type
=
Key
;
using
key_type
=
Key
;
using
mapped_type
=
T
;
using
mapped_type
=
T
;
using
value_type
=
std
::
pair
<
const
Key
,
T
>
;
using
value_type
=
typename
Container
::
value_type
;
using
size_type
=
typename
Container
::
size_type
;
using
Container
::
Container
;
using
Container
::
Container
;
std
::
pair
<
typename
Container
::
iterator
,
bool
>
emplace
(
key_type
&&
key
,
T
&&
t
)
std
::
pair
<
typename
Container
::
iterator
,
bool
>
emplace
(
key_type
&&
key
,
T
&&
t
)
...
@@ -29,33 +30,26 @@ struct ordered_map : Container
...
@@ -29,33 +30,26 @@ struct ordered_map : Container
return
{
it
,
false
};
return
{
it
,
false
};
}
}
}
}
Container
::
emplace_back
(
key
,
t
);
this
->
emplace_back
(
key
,
t
);
return
{
--
this
->
end
(),
true
};
return
{
--
this
->
end
(),
true
};
}
}
std
::
size_t
erase
(
const
key_type
&
key
)
T
&
operator
[](
Key
&
&
key
)
{
{
std
::
size_t
result
=
0
;
return
emplace
(
std
::
move
(
key
),
T
{}).
first
->
second
;
for
(
auto
it
=
this
->
begin
();
it
!=
this
->
end
();)
}
size_type
erase
(
const
Key
&
key
)
{
for
(
auto
it
=
this
->
begin
();
it
!=
this
->
end
();
++
it
)
{
{
if
(
it
->
first
==
key
)
if
(
it
->
first
==
key
)
{
{
++
result
;
Container
::
erase
(
it
);
it
=
Container
::
erase
(
it
);
return
1
;
}
else
{
++
it
;
}
}
}
}
return
0
;
return
result
;
}
T
&
operator
[](
key_type
&&
key
)
{
return
emplace
(
std
::
move
(
key
),
T
{}).
first
->
second
;
}
}
};
};
...
...
single_include/nlohmann/json.hpp
View file @
6ee9e5f4
...
@@ -2777,6 +2777,10 @@ template<class Key, class T, class IgnoredLess, class Allocator, class Container
...
@@ -2777,6 +2777,10 @@ template<class Key, class T, class IgnoredLess, class Allocator, class Container
struct
ordered_map
;
struct
ordered_map
;
/*!
/*!
@brief ordered JSON class
This type preserves the insertion order of object keys.
@since version 3.9.0
@since version 3.9.0
*/
*/
using
ordered_json
=
basic_json
<
nlohmann
::
ordered_map
>
;
using
ordered_json
=
basic_json
<
nlohmann
::
ordered_map
>
;
...
@@ -15875,17 +15879,18 @@ namespace nlohmann
...
@@ -15875,17 +15879,18 @@ namespace nlohmann
/// ordered_map: a minimal map-like container that preserves insertion order
/// ordered_map: a minimal map-like container that preserves insertion order
/// for use within nlohmann::basic_json<ordered_map>
/// for use within nlohmann::basic_json<ordered_map>
template
<
class
Key
,
class
T
,
class
IgnoredLess
=
std
::
less
<
Key
>
,
template
<
class
Key
,
class
T
,
class
IgnoredLess
=
std
::
less
<
Key
>
,
class
Allocator
=
std
::
allocator
<
std
::
pair
<
const
Key
,
T
>>
,
class
Allocator
=
std
::
allocator
<
std
::
pair
<
Key
,
T
>>
,
class
Container
=
std
::
vector
<
std
::
pair
<
const
Key
,
T
>
,
Allocator
>>
class
Container
=
std
::
vector
<
std
::
pair
<
Key
,
T
>
,
Allocator
>>
struct
ordered_map
:
Container
struct
ordered_map
:
Container
{
{
using
key_type
=
Key
;
using
key_type
=
Key
;
using
mapped_type
=
T
;
using
mapped_type
=
T
;
using
value_type
=
std
::
pair
<
const
Key
,
T
>
;
using
value_type
=
typename
Container
::
value_type
;
using
size_type
=
typename
Container
::
size_type
;
using
Container
::
Container
;
using
Container
::
Container
;
std
::
pair
<
typename
Container
::
iterator
,
bool
>
emplace
(
Key
&&
key
,
T
&&
t
)
std
::
pair
<
typename
Container
::
iterator
,
bool
>
emplace
(
key_type
&&
key
,
T
&&
t
)
{
{
for
(
auto
it
=
this
->
begin
();
it
!=
this
->
end
();
++
it
)
for
(
auto
it
=
this
->
begin
();
it
!=
this
->
end
();
++
it
)
{
{
...
@@ -15894,33 +15899,26 @@ struct ordered_map : Container
...
@@ -15894,33 +15899,26 @@ struct ordered_map : Container
return
{
it
,
false
};
return
{
it
,
false
};
}
}
}
}
Container
::
emplace_back
(
key
,
t
);
this
->
emplace_back
(
key
,
t
);
return
{
--
this
->
end
(),
true
};
return
{
--
this
->
end
(),
true
};
}
}
std
::
size_t
erase
(
const
Key
&
key
)
T
&
operator
[](
Key
&
&
key
)
{
{
std
::
size_t
result
=
0
;
return
emplace
(
std
::
move
(
key
),
T
{}).
first
->
second
;
for
(
auto
it
=
this
->
begin
();
it
!=
this
->
end
();
)
}
size_type
erase
(
const
Key
&
key
)
{
for
(
auto
it
=
this
->
begin
();
it
!=
this
->
end
();
++
it
)
{
{
if
(
it
->
first
==
key
)
if
(
it
->
first
==
key
)
{
{
++
result
;
Container
::
erase
(
it
);
it
=
Container
::
erase
(
it
);
return
1
;
}
else
{
++
it
;
}
}
}
}
return
0
;
return
result
;
}
T
&
operator
[](
Key
&&
key
)
{
return
emplace
(
std
::
move
(
key
),
T
{}).
first
->
second
;
}
}
};
};
...
...
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