TrinityCore
Loading...
Searching...
No Matches
Tuples.h
Go to the documentation of this file.
1
/*
2
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3
*
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the
6
* Free Software Foundation; either version 2 of the License, or (at your
7
* option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License along
15
* with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef Tuples_h__
19
#define Tuples_h__
20
21
#include <tuple>
22
23
namespace
Trinity
24
{
25
template
<
typename
T,
typename
Tuple>
26
struct
has_type
;
27
28
template
<
typename
T,
typename
... Us>
29
struct
has_type
<T,
std
::tuple<Us...>> : std::disjunction<std::is_same<T, Us>...>
30
{
31
};
32
33
template
<
typename
T,
typename
... Us>
34
constexpr
bool
has_type_v
=
has_type
<T, Us...>::value;
35
36
template
<
typename
>
37
struct
is_tuple
: std::false_type
38
{
39
};
40
41
template
<
typename
... Ts>
42
struct
is_tuple
<
std
::tuple<Ts...>> : std::true_type
43
{
44
};
45
46
template
<
typename
... Ts>
47
constexpr
bool
is_tuple_v
=
is_tuple
<Ts...>::value;
48
49
namespace
Impl
50
{
51
template
<
class
T,
class
Tuple,
size_t
... I>
52
T*
new_from_tuple
(Tuple&& args, std::index_sequence<I...>)
53
{
54
return
new
T(std::get<I>(std::forward<Tuple>(args))...);
55
}
56
}
57
58
template
<
class
T,
class
Tuple>
59
[[nodiscard]] T*
new_from_tuple
(Tuple&& args)
60
{
61
return
Impl::new_from_tuple<T>(std::forward<Tuple>(args), std::make_index_sequence<std::tuple_size_v<std::remove_reference_t<Tuple>>>{});
62
}
63
}
64
65
#endif
// Tuples_h__
Trinity::Impl::new_from_tuple
T * new_from_tuple(Tuple &&args, std::index_sequence< I... >)
Definition
Tuples.h:52
Trinity
Definition
AsioHacksFwd.h:53
Trinity::new_from_tuple
T * new_from_tuple(Tuple &&args)
Definition
Tuples.h:59
Trinity::has_type_v
constexpr bool has_type_v
Definition
Tuples.h:34
Trinity::is_tuple_v
constexpr bool is_tuple_v
Definition
Tuples.h:47
std
STL namespace.
Trinity::has_type
Definition
Tuples.h:26
Trinity::is_tuple
Definition
Tuples.h:38
common
Utilities
Tuples.h
Generated on Sun May 10 2026 02:30:13 for TrinityCore by
1.9.8