mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-24 10:30:38 +00:00
core: add make_shared(T&&) overload
Allows for code like this: auto p = make_shared(object());
This commit is contained in:
committed by
Avi Kivity
parent
83963b23d3
commit
d674cd7deb
@@ -69,6 +69,9 @@ lw_shared_ptr<T> make_lw_shared(T& a);
|
||||
template <typename T, typename... A>
|
||||
shared_ptr<T> make_shared(A&&... a);
|
||||
|
||||
template <typename T>
|
||||
shared_ptr<T> make_shared(T&& a);
|
||||
|
||||
template <typename T, typename U>
|
||||
shared_ptr<T> static_pointer_cast(const shared_ptr<U>& p);
|
||||
|
||||
@@ -375,6 +378,9 @@ public:
|
||||
template <typename U, typename... A>
|
||||
friend shared_ptr<U> make_shared(A&&... a);
|
||||
|
||||
template <typename U>
|
||||
friend shared_ptr<U> make_shared(U&& a);
|
||||
|
||||
template <typename V, typename U>
|
||||
friend shared_ptr<V> static_pointer_cast(const shared_ptr<U>& p);
|
||||
|
||||
@@ -424,6 +430,14 @@ make_shared(A&&... a) {
|
||||
return helper::make(std::forward<A>(a)...);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline
|
||||
shared_ptr<T>
|
||||
make_shared(T&& a) {
|
||||
using helper = shared_ptr_make_helper<T, std::is_base_of<enable_shared_from_this<T>, T>::value>;
|
||||
return helper::make(std::forward<T>(a));
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
inline
|
||||
shared_ptr<T>
|
||||
|
||||
Reference in New Issue
Block a user