Visual Computing Library
Loading...
Searching...
No Matches
type_wrapper.h
1/*****************************************************************************
2 * VCLib *
3 * Visual Computing Library *
4 * *
5 * Copyright(C) 2021-2025 *
6 * Visual Computing Lab *
7 * ISTI - Italian National Research Council *
8 * *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the Mozilla Public License Version 2.0 as published *
13 * by the Mozilla Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * Mozilla Public License Version 2.0 *
20 * (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21 ****************************************************************************/
22
23#ifndef VCL_TYPES_TYPE_WRAPPER_H
24#define VCL_TYPES_TYPE_WRAPPER_H
25
26#include "variadic_templates.h"
27
28namespace vcl {
29
30// TODO: write documentation for all the functions and classes in this file
31
39template<typename... Args>
41{
42 static constexpr uint size() { return sizeof...(Args); }
43};
44
50// note: specialization from variadic_templates.h
51template<typename... Args>
52struct FirstType<TypeWrapper<Args...>>
53{
54 using type = std::tuple_element<0, std::tuple<Args...>>::type;
55};
56
57// note: specialization from variadic_templates.h
58template<typename... Args>
59uint indexInTypePack(std::type_index ti, TypeWrapper<Args...>)
60{
61 return indexInTypePack<Args...>(ti);
62}
63
64// note: specialization from variadic_templates.h
65template<typename T, typename... Us>
67{
68 static constexpr uint value = indexInTypePack<T, Us...>();
69};
70
71// note: specialization from variadic_templates.h
72template<uint I, typename... T>
73struct TypeAt<I, TypeWrapper<T...>>
74{
75 using type = TypeAt<I, T...>::type;
76};
77
78// note: specialization from variadic_templates.h
79template<typename... Args>
80struct NumberOfTypes<TypeWrapper<Args...>> : public NumberOfTypes<Args...>
81{
82};
83
84// note: specialization from variadic_templates.h
85template<typename... T>
86struct ForEachType<TypeWrapper<T...>> : public ForEachType<T...>
87{
88};
89
90} // namespace vcl
91
92#endif // VCL_TYPES_TYPE_WRAPPER_H
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
constexpr uint indexInTypePack()
Function that returns the index of a Type T in a pack of types (variadic templates)....
Definition variadic_templates.h:75
Get the first type of a pack of types (variadic templates) or a TypeWrapper.
Definition variadic_templates.h:49
Allows to apply a function to each type in a variadic template pack.
Definition variadic_templates.h:166
Definition variadic_templates.h:128
Definition variadic_templates.h:143
Definition variadic_templates.h:134
A simple structure that wraps a list of variadic templates, without instantiating anything....
Definition type_wrapper.h:41