Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
20
generator/factory_utils.hpp
Normal file
20
generator/factory_utils.hpp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
namespace generator
|
||||
{
|
||||
template <typename T, typename... Args>
|
||||
std::enable_if_t<std::is_constructible<T, Args...>::value, std::shared_ptr<T>> create(Args &&... args)
|
||||
{
|
||||
return std::make_shared<T>(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// impossible to construct
|
||||
template <typename T, typename... Args>
|
||||
std::enable_if_t<!std::is_constructible<T, Args...>::value, std::shared_ptr<T>> create(Args &&...)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace generator
|
||||
Loading…
Add table
Add a link
Reference in a new issue