1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/******************************************************************************
* This file is part of libome *
* Copyright (C) 2025 Arnd Behring, Kay Schoenwald *
* SPDX-License-Identifier: GPL-3.0-or-later *
******************************************************************************/
/**
* \file
* \brief Type traits for template metaprogramming
*/
#ifndef LIBOME_TRAITS_H
#define LIBOME_TRAITS_H
#include <type_traits>
namespace ome
{
/**
* \brief Boolean trait to check if a type has a get_view() method
* \details Base case: false
*/
template<typename T, typename = void>
struct has_view : std::false_type {};
/**
* \brief Boolean trait to check if a type has a get_view() method
* \details True case
*/
template<typename T>
struct has_view<T, std::void_t<decltype(std::declval<T>().get_view())>> : std::true_type {};
/**
* \brief Type trait to extract the return type of the get_view() method
* \details Base case: void (no view type found)
*/
template<typename T, typename = void>
struct get_view_type
{
/// Type alias for the view type (void if no view type was found)
using type = void;
};
/**
* \brief Type trait to extract the return type of the get_view() method
* \details Extract actual view type
*/
template<typename T>
struct get_view_type<T, std::void_t<decltype(std::declval<T>().get_view())>>
{
/// Type alias for the view type (void if no view type was found)
using type = decltype(std::declval<T>().get_view());
};
/**
* \brief Boolean trait to check if a type has the type alias has_eval_plus_int and
* whether it is "true" (of type std::true_type)
* \details Base case: false
*/
template<typename T, typename = void>
struct has_eval_plus_int : std::false_type {};
/**
* \brief Boolean trait to check if a type has the type alias has_eval_plus_int and
* whether it is "true" (of type std::true_type)
* \details True case
*/
template<typename T>
struct has_eval_plus_int<T, std::void_t<typename T::has_eval_plus_int>>
: std::is_same<typename T::has_eval_plus_int, std::true_type> {};
}
#endif