Zivid C++ API 2.11.1+de9b5dae-1
TypeTraits.h
Go to the documentation of this file.
1/*******************************************************************************
2 * This file is part of the Zivid API
3 *
4 * Copyright 2015-2024 (C) Zivid AS
5 * All rights reserved.
6 *
7 * Zivid Software License, v1.0
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * 3. Neither the name of Zivid AS nor the names of its contributors may be used
20 * to endorse or promote products derived from this software without specific
21 * prior written permission.
22 *
23 * 4. This software, with or without modification, must not be used with any
24 * other 3D camera than from Zivid AS.
25 *
26 * 5. Any software provided in binary form under this license must not be
27 * reverse engineered, decompiled, modified and/or disassembled.
28 *
29 * THIS SOFTWARE IS PROVIDED BY ZIVID AS "AS IS" AND ANY EXPRESS OR IMPLIED
30 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
31 * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
32 * DISCLAIMED. IN NO EVENT SHALL ZIVID AS OR CONTRIBUTORS BE LIABLE FOR ANY
33 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 * Contact: Zivid Customer Success Team <customersuccess@zivid.com>
41 * Info: http://www.zivid.com
42 ******************************************************************************/
43
44#pragma once
45
46#include <type_traits>
47#include <utility>
48
49namespace Zivid
50{
51#ifndef NO_DOC
53 namespace Detail
54 {
55 namespace TypeTraits
56 {
57 // This file is intended to be used in public headers only. Internally use
58 // Traits.h exclusively (the traits in this file are available via Traits.h)
59
60 template<typename T, typename...>
61 struct IsInList : std::false_type
62 {};
63
64 template<typename T, typename First, typename... Rest>
65 struct IsInList<T, First, Rest...>
66 : std::integral_constant<bool, std::is_same<T, First>::value || IsInList<T, Rest...>::value>
67 {};
68
69 template<typename T, typename Tuple>
70 struct IsInTuple;
71
72 template<typename T, typename... Ts>
73 struct IsInTuple<T, std::tuple<Ts...>> : IsInList<T, Ts...>
74 {};
75
76 template<typename Tuple, typename... Args>
77 struct AllArgsAreInTuple : std::true_type
78 {};
79
80 template<typename Tuple, typename Arg, typename... Args>
81 struct AllArgsAreInTuple<Tuple, Arg, Args...>
82 : std::integral_constant<bool, IsInTuple<Arg, Tuple>::value && AllArgsAreInTuple<Tuple, Args...>::value>
83 {};
84
85 template<typename... Args>
86 struct AllArgsDecayedAreUnique : std::true_type
87 {};
88
89 template<typename Head, typename... Tail>
90 struct AllArgsDecayedAreUnique<Head, Tail...>
91 : std::integral_constant<
92 bool,
93 !IsInList<typename std::decay<Head>::type, typename std::decay<Tail>::type...>::value
94 && AllArgsDecayedAreUnique<Tail...>::value>
95 {};
96
97 template<typename... Ts>
98 struct Concatenate;
99
100 template<typename... T1s, typename... T2s, typename... Rest>
101 struct Concatenate<std::tuple<T1s...>, std::tuple<T2s...>, Rest...>
102 : Concatenate<std::tuple<T1s..., T2s...>, Rest...>
103 {};
104
105 template<typename... T1s>
106 struct Concatenate<std::tuple<T1s...>>
107 {
108 using Type = std::tuple<T1s...>;
109 };
110
111 template<typename T>
112 struct TypeIdentity
113 {
114 using Type = T;
115 };
116
117 template<typename...>
118 struct Conjunction : std::true_type
119 {};
120
121 template<typename T>
122 struct Conjunction<T> : T
123 {};
124
125 template<typename T, typename... Ts>
126 struct Conjunction<T, Ts...> : std::conditional<T::value, Conjunction<Ts...>, std::false_type>::type
127 {};
128 } // namespace TypeTraits
129 } // namespace Detail
130#endif
131} // namespace Zivid
The main Zivid namespace. All Zivid code is found here.
Definition Application.h:54