/
Ant010ff
/
ffpp
Обзор
Документация
Войти
/
Ant010ff
/
ffpp
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
include/factory.hpp
63 строки
2 KB
Ant010ff
Version 2.11.3.
08 авг 2026, 16:44
08 авг 2026, 16:44
fd187d3
Код
Авторство
О чём код?
/* This header is part of a Functional Flow Processing Primitives (FFPP) library, version 2.11.3. Official repository: https://gitlab.com/ant010ff/ffpp Licensed under the MIT License <http://opensource.org/licenses/MIT>. SPDX-License-Identifier: MIT Copyright (c) 2021 - 2026 Anton Nasonov <ant010fff @ gmail . com>. */ #ifndef FFPP_FACTORY_HPP #define FFPP_FACTORY_HPP namespace FFPP::Concepts { template<typename Type> concept Constructible = requires { typename Type::PolicyT; } && ResourcePolicy<typename Type::ResourcePolicyT> ; }//FFPP::Concepts namespace FFPP { template<typename TConstructible> class Factory { public: using PolicyT = typename TConstructible::PolicyT; using ResourcePolicyT = PolicyT::ResourcePolicyT; template<typename Type> using SharedT = ResourcePolicyT::template SharedT<Type>; Factory( #if FFPP_TRACK_ORIGIN std::source_location const& slOrigin = std::source_location::current() #endif ) #if FFPP_TRACK_ORIGIN : c_slOrigin_(slOrigin) #endif { } template<typename... TArguments> requires Concepts::Constructible<TConstructible> FFPP_ATTR_INLINE SharedT<TConstructible> MakeShared(TArguments&&... args) { auto spInstance = ResourcePolicyT::template AllocateShared<TConstructible>(std::forward<TArguments>(args)...); #if FFPP_TRACK_ORIGIN if constexpr(requires { spInstance->template SetOrigin<true>(c_slOrigin_); }) { spInstance->template SetOrigin<true>(c_slOrigin_); } #endif return spInstance; } private: std::source_location const c_slOrigin_; };//Factory }//FFPP #endif//FFPP_FACTORY_HPP