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
daba1b6a
Commit
daba1b6a
authored
Dec 05, 2017
by
Mike Bogdanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed conformance with C++17, some members of allocator are depricated and…
fixed conformance with C++17, some members of allocator are depricated and should be used via allocator_traits
parent
0e3a0b73
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
3 deletions
+39
-3
json.hpp
src/json.hpp
+39
-3
No files found.
src/json.hpp
View file @
daba1b6a
...
@@ -7944,12 +7944,15 @@ class basic_json
...
@@ -7944,12 +7944,15 @@ class basic_json
static
T
*
create
(
Args
&&
...
args
)
static
T
*
create
(
Args
&&
...
args
)
{
{
AllocatorType
<
T
>
alloc
;
AllocatorType
<
T
>
alloc
;
using
AllocatorTraits
=
std
::
allocator_traits
<
AllocatorType
<
T
>>
;
auto
deleter
=
[
&
](
T
*
object
)
auto
deleter
=
[
&
](
T
*
object
)
{
{
alloc
.
deallocate
(
object
,
1
);
AllocatorTraits
::
deallocate
(
alloc
,
object
,
1
);
};
};
std
::
unique_ptr
<
T
,
decltype
(
deleter
)
>
object
(
alloc
.
allocate
(
1
),
deleter
);
std
::
unique_ptr
<
T
,
decltype
(
deleter
)
>
object
(
AllocatorTraits
::
allocate
(
alloc
,
1
),
deleter
);
alloc
.
construct
(
object
.
get
(),
std
::
forward
<
Args
>
(
args
)...);
AllocatorTraits
::
construct
(
alloc
,
object
.
get
(),
std
::
forward
<
Args
>
(
args
)...);
assert
(
object
!=
nullptr
);
assert
(
object
!=
nullptr
);
return
object
.
release
();
return
object
.
release
();
}
}
...
@@ -8937,6 +8940,39 @@ class basic_json
...
@@ -8937,6 +8940,39 @@ class basic_json
~
basic_json
()
~
basic_json
()
{
{
assert_invariant
();
assert_invariant
();
switch
(
m_type
)
{
case
value_t
:
:
object
:
{
AllocatorType
<
object_t
>
alloc
;
std
::
allocator_traits
<
decltype
(
alloc
)
>::
destroy
(
alloc
,
m_value
.
object
);
std
::
allocator_traits
<
decltype
(
alloc
)
>::
deallocate
(
alloc
,
m_value
.
object
,
1
);
break
;
}
case
value_t
:
:
array
:
{
AllocatorType
<
array_t
>
alloc
;
std
::
allocator_traits
<
decltype
(
alloc
)
>::
destroy
(
alloc
,
m_value
.
array
);
std
::
allocator_traits
<
decltype
(
alloc
)
>::
deallocate
(
alloc
,
m_value
.
array
,
1
);
break
;
}
case
value_t
:
:
string
:
{
AllocatorType
<
string_t
>
alloc
;
std
::
allocator_traits
<
decltype
(
alloc
)
>::
destroy
(
alloc
,
m_value
.
string
);
std
::
allocator_traits
<
decltype
(
alloc
)
>::
deallocate
(
alloc
,
m_value
.
string
,
1
);
break
;
}
default
:
{
// all other types need no specific destructor
break
;
}
}
m_value
.
destroy
(
m_type
);
m_value
.
destroy
(
m_type
);
}
}
...
...
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