Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
Root
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
为了安全,强烈建议开启2FA双因子认证:User Settings -> Account -> Enable two-factor authentication!!!
Show more breadcrumbs
cxwx
Root
Commits
f13ca2eb
Commit
f13ca2eb
authored
5 years ago
by
Danilo Piparo
Browse files
Options
Downloads
Patches
Plain Diff
[Core][ROOT-10086] Add make_unique backport for arrays
parent
22c32d30
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/foundation/inc/ROOT/RMakeUnique.hxx
+34
-3
34 additions, 3 deletions
core/foundation/inc/ROOT/RMakeUnique.hxx
with
34 additions
and
3 deletions
core/foundation/inc/ROOT/RMakeUnique.hxx
+
34
−
3
View file @
f13ca2eb
/// \file ROOT/RMakeUnique.h
/// \file ROOT/RMakeUnique.h
xx
/// \ingroup Base StdExt
/// \author Danilo Piparo
/// \date 2017-09-22
/*************************************************************************
* Copyright (C) 1995-201
7
, Rene Brun and Fons Rademakers. *
* Copyright (C) 1995-201
9
, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
...
...
@@ -18,16 +18,47 @@
#if __cplusplus < 201402L && !defined(_MSC_VER)
#include
<type_traits>
#include
<utility>
namespace
ROOT
{
namespace
Detail
{
// Inspired from abseil
template
<
typename
T
>
struct
RMakeUniqueResult
{
using
scalar
=
std
::
unique_ptr
<
T
>
;
};
template
<
typename
T
>
struct
RMakeUniqueResult
<
T
[]
>
{
using
array
=
std
::
unique_ptr
<
T
[]
>
;
};
template
<
typename
T
,
size_t
N
>
struct
RMakeUniqueResult
<
T
[
N
]
>
{
using
invalid
=
void
;
};
}
// namespace Detail
}
// namespace ROOT
namespace
std
{
// template <typename T, typename... Args, typename std::enable_if<!std::is_array<T>::value, int>::type = 0>
template
<
typename
T
,
typename
...
Args
>
std
::
unique_ptr
<
T
>
make_unique
(
Args
&&
...
args
)
typename
ROOT
::
Detail
::
RMakeUniqueResult
<
T
>::
scalar
make_unique
(
Args
&&
...
args
)
{
return
std
::
unique_ptr
<
T
>
(
new
T
(
std
::
forward
<
Args
>
(
args
)...));
}
template
<
typename
T
>
typename
ROOT
::
Detail
::
RMakeUniqueResult
<
T
>::
array
make_unique
(
std
::
size_t
size
)
{
return
std
::
unique_ptr
<
T
>
(
new
typename
std
::
remove_extent
<
T
>::
type
[
size
]());
}
template
<
typename
T
,
typename
...
Args
>
typename
ROOT
::
Detail
::
RMakeUniqueResult
<
T
>::
invalid
make_unique
(
Args
&&
...)
=
delete
;
}
// namespace std
#endif
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment