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