mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-30 05:30:51 +00:00
24 lines
456 B
C++
24 lines
456 B
C++
#pragma once
|
|
|
|
#include <memory>
|
|
|
|
namespace ext
|
|
{
|
|
|
|
/** Allows to make std::shared_ptr<T> from T with private constructor.
|
|
* Derive your T class from shared_ptr_helper<T> and define him as friend.
|
|
*/
|
|
template <typename T>
|
|
struct shared_ptr_helper
|
|
{
|
|
template <typename... TArgs>
|
|
static auto create(TArgs &&... args)
|
|
{
|
|
struct Local : T { using T::T; };
|
|
return std::make_shared<Local>(std::forward<TArgs>(args)...);
|
|
}
|
|
};
|
|
|
|
}
|
|
|