Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
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
json
Commits
c5e73177
Unverified
Commit
c5e73177
authored
Dec 06, 2017
by
Niels Lohmann
Committed by
GitHub
Dec 06, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #856 from bogemic/std_allocator_conformance_cpp17
Std allocator conformance cpp17
parents
25d205c1
8890b935
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
34 deletions
+37
-34
src/json.hpp
src/json.hpp
+37
-34
No files found.
src/json.hpp
View file @
c5e73177
...
@@ -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
();
}
}
...
@@ -8112,37 +8115,37 @@ class basic_json
...
@@ -8112,37 +8115,37 @@ class basic_json
void
destroy
(
value_t
t
)
void
destroy
(
value_t
t
)
{
{
switch
(
t
)
switch
(
t
)
{
{
case
value_t
:
:
object
:
case
value_t
:
:
object
:
{
{
AllocatorType
<
object_t
>
alloc
;
AllocatorType
<
object_t
>
alloc
;
alloc
.
destroy
(
object
);
std
::
allocator_traits
<
decltype
(
alloc
)
>::
destroy
(
alloc
,
object
);
alloc
.
deallocate
(
object
,
1
);
std
::
allocator_traits
<
decltype
(
alloc
)
>::
deallocate
(
alloc
,
object
,
1
);
break
;
break
;
}
}
case
value_t
:
:
array
:
case
value_t
:
:
array
:
{
{
AllocatorType
<
array_t
>
alloc
;
AllocatorType
<
array_t
>
alloc
;
alloc
.
destroy
(
array
);
std
::
allocator_traits
<
decltype
(
alloc
)
>::
destroy
(
alloc
,
array
);
alloc
.
deallocate
(
array
,
1
);
std
::
allocator_traits
<
decltype
(
alloc
)
>::
deallocate
(
alloc
,
array
,
1
);
break
;
break
;
}
}
case
value_t
:
:
string
:
case
value_t
:
:
string
:
{
{
AllocatorType
<
string_t
>
alloc
;
AllocatorType
<
string_t
>
alloc
;
alloc
.
destroy
(
string
);
std
::
allocator_traits
<
decltype
(
alloc
)
>::
destroy
(
alloc
,
string
);
alloc
.
deallocate
(
string
,
1
);
std
::
allocator_traits
<
decltype
(
alloc
)
>::
deallocate
(
alloc
,
string
,
1
);
break
;
break
;
}
}
default:
default:
{
{
break
;
break
;
}
}
}
}
}
}
};
};
...
...
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