Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
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
fmt
Commits
cdfcee27
Commit
cdfcee27
authored
Feb 10, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use allocator_traits if available
parent
66b25ef0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
include/fmt/format.h
include/fmt/format.h
+10
-1
test/mock-allocator.h
test/mock-allocator.h
+3
-1
No files found.
include/fmt/format.h
View file @
cdfcee27
...
@@ -222,7 +222,16 @@ inline dummy_int isinf(...) { return dummy_int(); }
...
@@ -222,7 +222,16 @@ inline dummy_int isinf(...) { return dummy_int(); }
inline
dummy_int
_finite
(...)
{
return
dummy_int
();
}
inline
dummy_int
_finite
(...)
{
return
dummy_int
();
}
inline
dummy_int
isnan
(...)
{
return
dummy_int
();
}
inline
dummy_int
isnan
(...)
{
return
dummy_int
();
}
inline
dummy_int
_isnan
(...)
{
return
dummy_int
();
}
inline
dummy_int
_isnan
(...)
{
return
dummy_int
();
}
template
<
typename
Allocator
>
typename
Allocator
::
value_type
*
allocate
(
Allocator
&
alloc
,
std
::
size_t
n
)
{
#if __cplusplus >= 201103L || FMT_MSC_VER >= 1700
return
std
::
allocator_traits
<
Allocator
>::
allocate
(
alloc
,
n
);
#else
return
this
->
allocate
(
n
);
#endif
}
}
}
// namespace internal
}
// namespace fmt
}
// namespace fmt
namespace
std
{
namespace
std
{
...
@@ -442,7 +451,7 @@ void basic_memory_buffer<T, SIZE, Allocator>::grow(std::size_t size) {
...
@@ -442,7 +451,7 @@ void basic_memory_buffer<T, SIZE, Allocator>::grow(std::size_t size) {
if
(
size
>
new_capacity
)
if
(
size
>
new_capacity
)
new_capacity
=
size
;
new_capacity
=
size
;
T
*
old_data
=
this
->
data
();
T
*
old_data
=
this
->
data
();
T
*
new_data
=
this
->
allocate
(
new_capacity
);
T
*
new_data
=
internal
::
allocate
<
Allocator
>
(
*
this
,
new_capacity
);
// The following code doesn't throw, so the raw pointer above doesn't leak.
// The following code doesn't throw, so the raw pointer above doesn't leak.
std
::
uninitialized_copy
(
old_data
,
old_data
+
this
->
size
(),
std
::
uninitialized_copy
(
old_data
,
old_data
+
this
->
size
(),
internal
::
make_ptr
(
new_data
,
new_capacity
));
internal
::
make_ptr
(
new_data
,
new_capacity
));
...
...
test/mock-allocator.h
View file @
cdfcee27
...
@@ -78,7 +78,9 @@ class AllocatorRef {
...
@@ -78,7 +78,9 @@ class AllocatorRef {
Allocator
*
get
()
const
{
return
alloc_
;
}
Allocator
*
get
()
const
{
return
alloc_
;
}
value_type
*
allocate
(
std
::
size_t
n
)
{
return
alloc_
->
allocate
(
n
);
}
value_type
*
allocate
(
std
::
size_t
n
)
{
return
fmt
::
internal
::
allocate
(
*
alloc_
,
n
);
}
void
deallocate
(
value_type
*
p
,
std
::
size_t
n
)
{
alloc_
->
deallocate
(
p
,
n
);
}
void
deallocate
(
value_type
*
p
,
std
::
size_t
n
)
{
alloc_
->
deallocate
(
p
,
n
);
}
};
};
...
...
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