COMMS
Template library intended to help with implementation of communication protocols.
Loading...
Searching...
No Matches
detect.h
1//
2// Copyright 2017 - 2026 (C). Alex Robenko. All rights reserved.
3//
4// SPDX-License-Identifier: MPL-2.0
5//
6// This Source Code Form is subject to the terms of the Mozilla Public
7// License, v. 2.0. If a copy of the MPL was not distributed with this
8// file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
10#pragma once
11
12namespace comms
13{
14
15namespace details
16{
17
18template <class T, class R = void>
19struct EnableIfHasInterfaceOptions { using Type = R; };
20
21template <class T, class Enable = void>
22struct HasInterfaceOptions
23{
24 static const bool Value = false;
25};
26
27template <class T>
28struct HasInterfaceOptions<T, typename EnableIfHasInterfaceOptions<typename T::InterfaceOptions>::Type>
29{
30 static const bool Value = true;
31};
32
33template <class T>
34constexpr bool hasInterfaceOptions()
35{
36 return HasInterfaceOptions<T>::Value;
37}
38
39template <class T, class R = void>
40struct EnableIfHasImplOptions { using Type = R; };
41
42template <class T, class Enable = void>
43struct HasImplOptions
44{
45 static const bool Value = false;
46};
47
48template <class T>
49struct HasImplOptions<T, typename EnableIfHasImplOptions<typename T::ImplOptions>::Type>
50{
51 static const bool Value = true;
52};
53
54template <class T>
55constexpr bool hasImplOptions()
56{
57 return HasImplOptions<T>::Value;
58}
59
60template <class T, class R = void>
61struct EnableIfHasElementType { using Type = R; };
62
63template <class T, class Enable = void>
64struct HasElementType
65{
66 static const bool Value = false;
67};
68
69template <class T>
70struct HasElementType<T, typename EnableIfHasElementType<typename T::element_type>::Type>
71{
72 static const bool Value = true;
73};
74
75template <class T>
76constexpr bool hasElementType()
77{
78 return HasElementType<T>::Value;
79}
80
81} // namespace details
82
83} // namespace comms
Main namespace for all classes / functions of COMMS library.