Toolbox
snapshot
The Reactive C++ Toolbox
Loading...
Searching...
No Matches
toolbox
util
Traits.hpp
Go to the documentation of this file.
1
// The Reactive C++ Toolbox.
2
// Copyright (C) 2013-2019 Swirly Cloud Limited
3
// Copyright (C) 2021 Reactive Markets Limited
4
//
5
// Licensed under the Apache License, Version 2.0 (the "License");
6
// you may not use this file except in compliance with the License.
7
// You may obtain a copy of the License at
8
//
9
// http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing, software
12
// distributed under the License is distributed on an "AS IS" BASIS,
13
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
// See the License for the specific language governing permissions and
15
// limitations under the License.
16
17
#ifndef TOOLBOX_UTIL_TRAITS_HPP
18
#define TOOLBOX_UTIL_TRAITS_HPP
19
20
#include <tuple>
21
22
namespace
toolbox
{
23
inline
namespace
util {
24
26
template
<
typename
TypeT>
27
struct
FunctionTraits
:
FunctionTraits
<decltype(&TypeT::operator())> {};
28
30
template
<
typename
ReturnT
,
typename
...
ArgsT
>
31
struct
FunctionTraits
<
ReturnT
(*)(
ArgsT
...)> {
32
33
using
FunctionType
=
ReturnT
(*)(
ArgsT
...);
34
using
ClassType
=
void
;
35
using
ReturnType
=
ReturnT
;
36
37
enum
{ Arity =
sizeof
...(ArgsT) };
38
39
template
<std::
size_t
i>
40
using
ArgType
= std::tuple_element_t<
i
, std::tuple<
ArgsT
...>>;
41
42
// Apply parameter pack to template.
43
template
<
template
<
typename
...>
typename
TemplT
>
44
using
Pack
=
TemplT
<
ArgsT
...>;
45
};
46
48
template
<
typename
ReturnT
,
typename
...
ArgsT
>
49
struct
FunctionTraits
<
ReturnT
(*)(
ArgsT
...)
noexcept
> :
FunctionTraits
<
ReturnT
(*)(
ArgsT
...)> {};
50
52
template
<
typename
ClassT
,
typename
ReturnT
,
typename
...
ArgsT
>
53
struct
FunctionTraits
<
ReturnT
(
ClassT
::*)(ArgsT...)> :
FunctionTraits
<ReturnT (*)(ArgsT...)> {
54
using
FunctionType
=
ReturnT
(
ClassT
::*)(
ArgsT
...);
55
using
ClassType
=
ClassT
;
56
};
57
59
template
<
typename
ClassT
,
typename
ReturnT
,
typename
...
ArgsT
>
60
struct
FunctionTraits
<
ReturnT
(
ClassT
::*)(ArgsT...)
const
> :
FunctionTraits
<ReturnT (*)(ArgsT...)> {
61
using
FunctionType
=
ReturnT
(
ClassT
::*)(
ArgsT
...)
const
;
62
using
ClassType
=
ClassT
;
63
};
64
66
template
<
typename
ClassT
,
typename
ReturnT
,
typename
...
ArgsT
>
67
struct
FunctionTraits
<
ReturnT
(
ClassT
::*)(ArgsT...)
const
noexcept
>
68
:
FunctionTraits
<ReturnT (*)(ArgsT...)> {
69
using
FunctionType
=
ReturnT
(
ClassT
::*)(
ArgsT
...)
const
noexcept
;
70
using
ClassType
=
ClassT
;
71
};
72
74
template
<
typename
ClassT
,
typename
ReturnT
,
typename
...
ArgsT
>
75
struct
FunctionTraits
<
ReturnT
(
ClassT
::*)(ArgsT...)
noexcept
>
76
:
FunctionTraits
<ReturnT (*)(ArgsT...)> {
77
using
FunctionType
=
ReturnT
(
ClassT
::*)(
ArgsT
...)
noexcept
;
78
using
ClassType
=
ClassT
;
79
};
80
81
}
// namespace util
82
}
// namespace toolbox
83
84
#endif
// TOOLBOX_UTIL_TRAITS_HPP
toolbox::util::bind
constexpr auto bind() noexcept
Definition
Slot.hpp:92
toolbox
Definition
Benchmark.cpp:26
toolbox::util::FunctionTraits< ReturnT(ClassT::*)(ArgsT...) const >::ClassType
ClassT ClassType
Definition
Traits.hpp:62
toolbox::util::FunctionTraits< ReturnT(ClassT::*)(ArgsT...) const >::FunctionType
ReturnT(ClassT::*)(ArgsT...) const FunctionType
Definition
Traits.hpp:61
toolbox::util::FunctionTraits< ReturnT(ClassT::*)(ArgsT...) const noexcept >::FunctionType
ReturnT(ClassT::*)(ArgsT...) const noexcept FunctionType
Definition
Traits.hpp:69
toolbox::util::FunctionTraits< ReturnT(ClassT::*)(ArgsT...) const noexcept >::ClassType
ClassT ClassType
Definition
Traits.hpp:70
toolbox::util::FunctionTraits< ReturnT(ClassT::*)(ArgsT...) noexcept >::FunctionType
ReturnT(ClassT::*)(ArgsT...) noexcept FunctionType
Definition
Traits.hpp:77
toolbox::util::FunctionTraits< ReturnT(ClassT::*)(ArgsT...) noexcept >::ClassType
ClassT ClassType
Definition
Traits.hpp:78
toolbox::util::FunctionTraits< ReturnT(ClassT::*)(ArgsT...)>::FunctionType
ReturnT(ClassT::*)(ArgsT...) FunctionType
Definition
Traits.hpp:54
toolbox::util::FunctionTraits< ReturnT(ClassT::*)(ArgsT...)>::ClassType
ClassT ClassType
Definition
Traits.hpp:55
toolbox::util::FunctionTraits< ReturnT(*)(ArgsT...)>::ClassType
void ClassType
Definition
Traits.hpp:34
toolbox::util::FunctionTraits< ReturnT(*)(ArgsT...)>::FunctionType
ReturnT(*)(ArgsT...) FunctionType
Definition
Traits.hpp:33
toolbox::util::FunctionTraits< ReturnT(*)(ArgsT...)>::ReturnType
ReturnT ReturnType
Definition
Traits.hpp:35
toolbox::util::FunctionTraits< ReturnT(*)(ArgsT...)>::Pack
TemplT< ArgsT... > Pack
Definition
Traits.hpp:44
toolbox::util::FunctionTraits< ReturnT(*)(ArgsT...)>::ArgType
std::tuple_element_t< i, std::tuple< ArgsT... > > ArgType
Definition
Traits.hpp:40
toolbox::FunctionTraits
Default case for functors and lambdas.
Definition
Traits.hpp:27
Generated by
1.9.8