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
28
namespace
flightgear
29
{
30
31
namespace
addons
32
{
33
34
template
<
typename
T>
35
struct
shared_ptr_traits
;
36
37
template
<
typename
T>
38
struct
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
50
template
<
typename
T>
51
struct
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
flightgear::addons
Definition
Addon.cxx:56
flightgear
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
Definition
Addon.cxx:53
flightgear::addons::shared_ptr_traits< SGSharedPtr< T > >::element_type
T element_type
Definition
pointer_traits.hxx:40
flightgear::addons::shared_ptr_traits< SGSharedPtr< T > >::makeStrongRef
static strong_ref makeStrongRef(Args &&...args)
Definition
pointer_traits.hxx:44
flightgear::addons::shared_ptr_traits< SGSharedPtr< T > >::strong_ref
SGSharedPtr< T > strong_ref
Definition
pointer_traits.hxx:41
flightgear::addons::shared_ptr_traits< std::shared_ptr< T > >::makeStrongRef
static strong_ref makeStrongRef(Args &&...args)
Definition
pointer_traits.hxx:57
flightgear::addons::shared_ptr_traits< std::shared_ptr< T > >::strong_ref
std::shared_ptr< T > strong_ref
Definition
pointer_traits.hxx:54
flightgear::addons::shared_ptr_traits< std::shared_ptr< T > >::element_type
T element_type
Definition
pointer_traits.hxx:53
flightgear::addons::shared_ptr_traits
Definition
pointer_traits.hxx:35
src
Add-ons
pointer_traits.hxx
Generated on Tue Jun 3 2025 12:58:36 for FlightGear by
1.13.2