Project
Loading...
Searching...
No Matches
CheckTypes.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11#ifndef O2_FRAMEWORK_CHECKTYPES_H_
12#define O2_FRAMEWORK_CHECKTYPES_H_
13
14#include <algorithm>
15#include <type_traits>
16#include "CompilerBuiltins.h"
17
18namespace o2::framework
19{
20
21template <typename T>
22concept TypeComplete = requires(T) {
23 {
24 sizeof(T)
25 };
26};
27
28template <typename T>
30
34template <typename T, typename TDefined, typename TUndefined>
35void call_if_defined_full(TDefined&& onDefined, TUndefined&& onUndefined)
36{
37 if constexpr (is_type_complete_v<T>) {
38 onDefined(static_cast<T*>(nullptr));
39 } else {
40 onUndefined();
41 }
42}
43
44template <typename T, typename TDefined>
45void call_if_defined(TDefined&& onDefined)
46{
47 call_if_defined_full<T>(onDefined, []() -> void {});
48}
49
50} // namespace o2::framework
51
52#endif // O2_FRAMEWORK_CHECKTYPES_H_
Defining PrimaryVertex explicitly as messageable.
void call_if_defined_full(TDefined &&onDefined, TUndefined &&onUndefined)
Definition CheckTypes.h:35
constexpr bool is_type_complete_v
Definition CheckTypes.h:29
void call_if_defined(TDefined &&onDefined)
Definition CheckTypes.h:45