FlightGear next
pointer_traits.hxx
Go to the documentation of this file.
1// -*- coding: utf-8 -*-
2//
3// pointer_traits.hxx --- Pointer traits classes
4// Copyright (C) 2018 Florent Rougon
5//
6// This program is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 2 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License along
17// with this program; if not, write to the Free Software Foundation, Inc.,
18// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20#ifndef FG_ADDON_POINTER_TRAITS_HXX
21#define FG_ADDON_POINTER_TRAITS_HXX
22
23#include <memory>
24#include <utility>
25
26#include <simgear/structure/SGSharedPtr.hxx>
27
28namespace flightgear
29{
30
31namespace addons
32{
33
34template <typename T>
36
37template <typename T>
38struct shared_ptr_traits<SGSharedPtr<T>>
39{
40 using element_type = T;
41 using strong_ref = SGSharedPtr<T>;
42
43 template <typename ...Args>
44 static strong_ref makeStrongRef(Args&& ...args)
45 {
46 return strong_ref(new T(std::forward<Args>(args)...));
47 }
48};
49
50template <typename T>
51struct shared_ptr_traits<std::shared_ptr<T>>
52{
53 using element_type = T;
54 using strong_ref = std::shared_ptr<T>;
55
56 template <typename ...Args>
57 static strong_ref makeStrongRef(Args&& ...args)
58 {
59 return std::make_shared<T>(std::forward<Args>(args)...);
60 }
61};
62
63} // of namespace addons
64
65} // of namespace flightgear
66
67#endif // of FG_ADDON_POINTER_TRAITS_HXX
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
Definition Addon.cxx:53