forked from sPHENIX-Collaboration/acts
/
action_signature_check.hpp
84 lines (71 loc) · 2.63 KB
/
action_signature_check.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// This file is part of the Acts project.
//
// Copyright (C) 2016-2018 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#pragma once
#include <type_traits>
namespace Acts {
/// The following operators have to be inplemented in order to satisfy
/// as an actor in the propagation
///
/// clang-format off
///
/// @code
///
/// template <typename propagator_state_t, typename result_t>
/// void
/// operator()(propagator_state_t& state, result_t& result)
/// const
/// {
/// return false;
/// }
///
/// template <typename propagator_state_t>
/// void
/// operator()(propagator_state_t& state)
/// const
/// {
/// return false;
/// }
///
/// @endcode
///
/// clang-format off
namespace detail {
namespace {
template <typename T, typename propagator_state_t, typename stepper_t,
typename result_t,
typename = decltype(std::declval<T>().operator()(
std::declval<propagator_state_t&>(), std::declval<stepper_t&>(),
std::declval<result_t&>()))>
std::true_type test_action_with_result(int);
template <typename, typename, typename, typename>
std::false_type test_action_with_result(...);
template <typename T, typename propagator_state_t, typename stepper_t,
typename = decltype(std::declval<T>().operator()(
std::declval<propagator_state_t&>(), std::declval<stepper_t&>()))>
std::true_type test_action_without_result(int);
template <typename>
std::false_type test_action_without_result(...);
template <typename T, typename propagator_state_t, typename stepper_t,
bool has_result = false>
struct action_signature_check_impl
: decltype(
test_action_without_result<T, propagator_state_t, stepper_t>(0)) {};
template <typename T, typename propagator_state_t, typename stepper_t>
struct action_signature_check_impl<T, propagator_state_t, stepper_t, true>
: decltype(test_action_with_result<T, propagator_state_t, stepper_t,
detail::result_type_t<T>>(0)) {};
template <typename T, typename propagator_state_t, typename stepper_t>
struct action_signature_check
: action_signature_check_impl<T, propagator_state_t, stepper_t,
detail::has_result_type_v<T>> {};
} // end of anonymous namespace
template <typename T, typename propagator_state_t, typename stepper_t>
constexpr bool action_signature_check_v =
action_signature_check<T, propagator_state_t, stepper_t>::value;
} // namespace detail
} // namespace Acts