CORSIKA  @c8_version@
The framework to simulate particle cascades for astroparticle physics
DecayProcess.hpp
1 /*
2  * (c) Copyright 2021 CORSIKA Project, corsika-project@lists.kit.edu
3  *
4  * This software is distributed under the terms of the GNU General Public
5  * Licence version 3 (GPL Version 3). See file LICENSE for a full version of
6  * the license.
7  */
8 
9 #pragma once
10 
13 
14 namespace corsika {
15 
20  template <class TProcess, typename TReturn, typename... TArgs>
21  struct has_method_doDecay : public detail::has_method_signature<TReturn, TArgs...> {
22 
24  typedef std::decay_t<TProcess> process_type;
25 
27  using detail::has_method_signature<TReturn, TArgs...>::testSignature;
28 
30  template <class T>
31  static std::false_type test(...);
32 
34  template <class T>
35  static decltype(testSignature(&T::template doDecay<TArgs...>)) test(std::nullptr_t);
36 
38  template <class T>
39  static decltype(testSignature(&T::doDecay)) test(std::nullptr_t);
40 
41  public:
46  using type = decltype(test<process_type>(nullptr));
47  static const bool value = type::value;
49  };
50 
53  template <class TProcess, typename TReturn, typename... TArgs>
54  bool constexpr has_method_doDecay_v =
55  has_method_doDecay<TProcess, TReturn, TArgs...>::value;
56 
61  template <class TProcess, typename TReturn, typename... TArgs>
62  struct has_method_getLifetime : public detail::has_method_signature<TReturn, TArgs...> {
63 
65  using detail::has_method_signature<TReturn, TArgs...>::testSignature;
66 
68  template <class T>
69  static std::false_type test(...);
70 
72  template <class T>
73  static decltype(testSignature(&T::template getLifetime<TArgs...>)) test(
74  std::nullptr_t);
75 
77  template <class T>
78  static decltype(testSignature(&T::getLifetime)) test(std::nullptr_t);
79 
80  public:
85  using type = decltype(test<std::decay_t<TProcess>>(nullptr));
86  static const bool value = type::value;
88  };
89 
91  template <class TProcess, typename TReturn, typename... TArgs>
92  bool constexpr has_method_getLifetime_v =
93  has_method_getLifetime<TProcess, TReturn, TArgs...>::value;
94 
95 } // namespace corsika
static decltype(testSignature(&T::template getLifetime< TArgs... >)) test(std::nullptr_t)
signature of templated method
static decltype(testSignature(&T::getLifetime)) test(std::nullptr_t)
signature of non-templated method
std::decay_t< TProcess > process_type
type of process to be studied
traits test for DecayProcess::getLifetime method
traits test for DecayProcess::doDecay method
`, since they are used everywhere as integral part of the framework.
Helper traits class (partial) for static compile time checking.
bool constexpr has_method_getLifetime_v
value traits type
static decltype(testSignature(&T::template doDecay< TArgs... >)) test(std::nullptr_t)
signature of templated method
static decltype(testSignature(&T::doDecay)) test(std::nullptr_t)
signature of non-templated method