diff --git a/Framework/Foundation/include/Framework/CheckTypes.h b/Framework/Foundation/include/Framework/CheckTypes.h index f0c74c54f9790..95e99a67ac0cf 100644 --- a/Framework/Foundation/include/Framework/CheckTypes.h +++ b/Framework/Foundation/include/Framework/CheckTypes.h @@ -18,13 +18,15 @@ namespace o2::framework { -/// Helper to understand if a given type is complete (declared fully) or not (forward declared). -/// See also: https://devblogs.microsoft.com/oldnewthing/20190710-00/?p=102678 -template -constexpr bool is_type_complete_v = false; +template +concept TypeComplete = requires(T) { + { + sizeof(T) + }; +}; template -constexpr bool is_type_complete_v> = true; +constexpr bool is_type_complete_v = TypeComplete; /// Helper which will invoke @a onDefined if the type T is actually available /// or @a onUndefined if the type T is a forward declaration. @@ -39,31 +41,12 @@ void call_if_defined_full(TDefined&& onDefined, TUndefined&& onUndefined) } } -/// Helper which will invoke @a onDefined if the type T is actually available -/// or @a onUndefined if the type T is a forward declaration. -/// Can be used to check for existence or not of a given type. -template -T call_if_defined_full_forward(TDefined&& onDefined, TUndefined&& onUndefined) -{ - if constexpr (is_type_complete_v) { - return std::move(onDefined(static_cast(nullptr))); - } else { - return onUndefined(); - } -} - template void call_if_defined(TDefined&& onDefined) { call_if_defined_full(onDefined, []() -> void {}); } -template -T call_if_defined_forward(TDefined&& onDefined) -{ - return std::move(call_if_defined_full_forward(onDefined, []() -> T&& { O2_BUILTIN_UNREACHABLE(); })); -} - } // namespace o2::framework #endif // O2_FRAMEWORK_CHECKTYPES_H_