Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:17:11

0001 /******************************************************************************
0002  * This file is part of libome                                                *
0003  * Copyright (C) 2025 Arnd Behring, Kay Schoenwald                            *
0004  * SPDX-License-Identifier: GPL-3.0-or-later                                  *
0005  ******************************************************************************/
0006 
0007 /**
0008  * \file
0009  * \brief Type traits for template metaprogramming
0010  */
0011 
0012 #ifndef LIBOME_TRAITS_H
0013 #define LIBOME_TRAITS_H
0014 
0015 #include <type_traits>
0016 
0017 namespace apfel
0018 {
0019   namespace ome
0020   {
0021     /**
0022      * \brief Boolean trait to check if a type has a get_view() method
0023      * \details Base case: false
0024      */
0025     template<typename T, typename = void>
0026     struct has_view : std::false_type {};
0027 
0028     /**
0029      * \brief Boolean trait to check if a type has a get_view() method
0030      * \details True case
0031      */
0032     template<typename T>
0033 struct has_view<T, std::void_t<decltype(std::declval<T>().get_view())>> : std::true_type {};
0034 
0035     /**
0036      * \brief Type trait to extract the return type of the get_view() method
0037      * \details Base case: void (no view type found)
0038      */
0039     template<typename T, typename = void>
0040     struct get_view_type
0041     {
0042       /// Type alias for the view type (void if no view type was found)
0043       using type = void;
0044     };
0045 
0046     /**
0047      * \brief Type trait to extract the return type of the get_view() method
0048      * \details Extract actual view type
0049      */
0050     template<typename T>
0051     struct get_view_type<T, std::void_t<decltype(std::declval<T>().get_view())>>
0052     {
0053       /// Type alias for the view type (void if no view type was found)
0054       using type = decltype(std::declval<T>().get_view());
0055     };
0056 
0057     /**
0058      * \brief Boolean trait to check if a type has the type alias has_eval_plus_int and
0059      *        whether it is "true" (of type std::true_type)
0060      * \details Base case: false
0061      */
0062     template<typename T, typename = void>
0063     struct has_eval_plus_int : std::false_type {};
0064 
0065     /**
0066      * \brief Boolean trait to check if a type has the type alias has_eval_plus_int and
0067      *        whether it is "true" (of type std::true_type)
0068      * \details True case
0069      */
0070     template<typename T>
0071     struct has_eval_plus_int<T, std::void_t<typename T::has_eval_plus_int>>
0072       : std::is_same<typename T::has_eval_plus_int, std::true_type> {};
0073 
0074   }
0075 }
0076 
0077 #endif