2 * Copyright (C) 2024-2026 David C. Manuelda (StormBytePP)
4 * This file is part of StormByte.
6 * StormByte is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License version 3
8 * or later, as published by the Free Software Foundation.
10 * StormByte is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with StormByte. If not, see
17 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
24// Out-of-line implementation of StormByte::Clonable, included by clonable.hxx.
25// See clonable.hxx for documentation of each member.
28 template<class T, typename SmartPointer>
29 requires ValidSmartPointer<SmartPointer, T>
30 template<class Target, typename... Args>
31 typename Clonable<T, SmartPointer>::PointerType Clonable<T, SmartPointer>::MakePointer(Args&&... args) {
32 if constexpr (std::is_same_v<PointerType, std::shared_ptr<T>>) {
33 return std::make_shared<Target>(std::forward<Args>(args)...);
34 } else if constexpr (std::is_same_v<PointerType, std::unique_ptr<T>>) {
35 return std::make_unique<Target>(std::forward<Args>(args)...);
37 static_assert(false, "Unsupported smart pointer type");