timemory 3.3.0
Modular C++ Toolkit for Performance Analysis and Logging. Profiling API and Tools for C, C++, CUDA, Fortran, and Python. The C++ template API is essentially a framework to creating tools: it is designed to provide a unifying interface for recording various performance measurements alongside data logging and interfaces to other tools.
tim::operation::generic_operator< Tp, Op, Tag > Struct Template Reference

This operation class is similar to pointer_operator but can handle non-pointer types. More...

#include "timemory/operations/types/generic.hpp"

+ Collaboration diagram for tim::operation::generic_operator< Tp, Op, Tag >:

Public Types

using type = std::remove_pointer_t< Tp >
 

Public Member Functions

 TIMEMORY_DELETED_OBJECT (generic_operator) private
 
template<typename Up , typename... Args, typename Rp = type, enable_if_t< trait::is_available< Rp >::value, int > = 0, enable_if_t< std::is_pointer< Up >::value, int > = 0>
 generic_operator (Up obj, Args &&... args)
 
template<typename Up , typename... Args, typename Rp = type, enable_if_t< trait::is_available< Rp >::value, int > = 0, enable_if_t< std::is_pointer< Up >::value, int > = 0>
 generic_operator (Up obj, Up rhs, Args &&... args)
 
template<typename Up , typename... Args, typename Rp = Tp, enable_if_t< trait::is_available< Rp >::value, int > = 0, enable_if_t<!std::is_pointer< Up >::value, int > = 0>
 generic_operator (Up &obj, Args &&... args)
 
template<typename Up , typename... Args, typename Rp = Tp, enable_if_t< trait::is_available< Rp >::value, int > = 0, enable_if_t<!std::is_pointer< Up >::value, int > = 0>
 generic_operator (Up &obj, Up &rhs, Args &&... args)
 
template<typename Up , typename... Args, typename Rp = Tp, enable_if_t<!trait::is_available< Rp >::value, int > = 0>
 generic_operator (Up &, Args &&...)
 

Static Public Member Functions

template<typename Up >
static bool is_invalid (Up &obj)
 

Detailed Description

template<typename Tp, typename Op, typename Tag>
struct tim::operation::generic_operator< Tp, Op, Tag >

This operation class is similar to pointer_operator but can handle non-pointer types.

Definition at line 54 of file generic.hpp.

Member Typedef Documentation

◆ type

template<typename Tp , typename Op , typename Tag >
using tim::operation::generic_operator< Tp, Op, Tag >::type = std::remove_pointer_t<Tp>

Definition at line 56 of file generic.hpp.

Constructor & Destructor Documentation

◆ generic_operator() [1/5]

template<typename Tp , typename Op , typename Tag >
template<typename Up , typename... Args, typename Rp = type, enable_if_t< trait::is_available< Rp >::value, int > = 0, enable_if_t< std::is_pointer< Up >::value, int > = 0>
tim::operation::generic_operator< Tp, Op, Tag >::generic_operator ( Up  obj,
Args &&...  args 
)
inlineexplicit

Definition at line 109 of file generic.hpp.

110 {
111 // rely on compiler to optimize this away if supports_runtime_checks if false
112 if(!check<Up>())
113 return;
114
115 // check the component is valid before applying
116 if(obj && !is_invalid(*obj))
117 sfinae(obj, 0, 0, 0, std::forward<Args>(args)...);
118 }
static bool is_invalid(Up &obj)
Definition: generic.hpp:89

References tim::operation::generic_operator< Tp, Op, Tag >::is_invalid().

◆ generic_operator() [2/5]

template<typename Tp , typename Op , typename Tag >
template<typename Up , typename... Args, typename Rp = type, enable_if_t< trait::is_available< Rp >::value, int > = 0, enable_if_t< std::is_pointer< Up >::value, int > = 0>
tim::operation::generic_operator< Tp, Op, Tag >::generic_operator ( Up  obj,
Up  rhs,
Args &&...  args 
)
inlineexplicit

Definition at line 123 of file generic.hpp.

124 {
125 // rely on compiler to optimize this away if supports_runtime_checks if false
126 if(!check<Up>())
127 return;
128
129 // check the components are valid before applying
130 if(obj && rhs && !is_invalid(*obj) && !is_invalid(*rhs))
131 sfinae(obj, rhs, 0, 0, 0, std::forward<Args>(args)...);
132 }

References tim::operation::generic_operator< Tp, Op, Tag >::is_invalid().

◆ generic_operator() [3/5]

template<typename Tp , typename Op , typename Tag >
template<typename Up , typename... Args, typename Rp = Tp, enable_if_t< trait::is_available< Rp >::value, int > = 0, enable_if_t<!std::is_pointer< Up >::value, int > = 0>
tim::operation::generic_operator< Tp, Op, Tag >::generic_operator ( Up &  obj,
Args &&...  args 
)
inlineexplicit

Definition at line 199 of file generic.hpp.

200 {
201 // rely on compiler to optimize this away if supports_runtime_checks if false
202 if(!check<Up>())
203 return;
204
205 // check the component is valid before applying
206 if(!is_invalid(obj))
207 sfinae(obj, 0, 0, 0, std::forward<Args>(args)...);
208 }

References tim::operation::generic_operator< Tp, Op, Tag >::is_invalid().

◆ generic_operator() [4/5]

template<typename Tp , typename Op , typename Tag >
template<typename Up , typename... Args, typename Rp = Tp, enable_if_t< trait::is_available< Rp >::value, int > = 0, enable_if_t<!std::is_pointer< Up >::value, int > = 0>
tim::operation::generic_operator< Tp, Op, Tag >::generic_operator ( Up &  obj,
Up &  rhs,
Args &&...  args 
)
inlineexplicit

Definition at line 213 of file generic.hpp.

214 {
215 // rely on compiler to optimize this away if supports_runtime_checks if false
216 if(!check<Up>())
217 return;
218
219 // check the components are valid before applying
220 if(!is_invalid(obj) && !is_invalid(rhs))
221 sfinae(obj, rhs, 0, 0, 0, std::forward<Args>(args)...);
222 }

References tim::operation::generic_operator< Tp, Op, Tag >::is_invalid().

◆ generic_operator() [5/5]

template<typename Tp , typename Op , typename Tag >
template<typename Up , typename... Args, typename Rp = Tp, enable_if_t<!trait::is_available< Rp >::value, int > = 0>
tim::operation::generic_operator< Tp, Op, Tag >::generic_operator ( Up &  ,
Args &&  ... 
)
inline

Definition at line 307 of file generic.hpp.

308 {}

Member Function Documentation

◆ is_invalid()

template<typename Tp , typename Op , typename Tag >
template<typename Up >
static bool tim::operation::generic_operator< Tp, Op, Tag >::is_invalid ( Up &  obj)
inlinestatic

Definition at line 89 of file generic.hpp.

90 {
91 // use a type-list for checking multiple types
92 using passthrough_t =
93 type_list<operation::set_is_invalid<Tp>, operation::get_is_invalid<Tp, false>,
94 operation::get_is_invalid<Tp, true>>;
95 if(is_one_of<Op, passthrough_t>::value)
96 return false;
97 return operation::get_is_invalid<Tp, false>{}(obj);
98 }

Referenced by tim::operation::generic_operator< Tp, Op, Tag >::generic_operator().

◆ TIMEMORY_DELETED_OBJECT()

template<typename Tp , typename Op , typename Tag >
tim::operation::generic_operator< Tp, Op, Tag >::TIMEMORY_DELETED_OBJECT ( generic_operator< Tp, Op, Tag >  )
inline

Definition at line 58 of file generic.hpp.

60 :
61 template <typename Up>
62 static bool check()
63 {
64 using U = std::decay_t<std::remove_pointer_t<Up>>;
65 static_assert(std::is_same<U, type>::value, "Error! Up != type");
66
67 // this is commented out because generic_operator does work with non-component
68 // types
69 // static_assert(
70 // concepts::is_component<U>::value,
71 // "Error! Applying generic_operator on a type that is not a component");
72
73 constexpr bool supports_runtime_checks = trait::runtime_enabled<Tp>::value &&
76
77 // if runtime checks are enabled and type or tag is not enabled, return false
78 if(supports_runtime_checks &&
80 return false;
81
82 // if supports_runtime_checks if false, compiler should optimize away this entire
83 // function call because it will be known at compile time that this function will
84 // always returns true
85 return true;
86 }
static bool get(enable_if_t< is_available< U >::value &&get_value< U >(), int >=0)
GET specialization if component is available.
static constexpr bool value

The documentation for this struct was generated from the following files: