ttg 1.0.0
Template Task Graph (TTG): flowgraph-based programming model for high-performance distributed-memory algorithms
Loading...
Searching...
No Matches
ttvalue.h
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-3-Clause
2#ifndef TTG_PARSEC_TTVALUE_H
3#define TTG_PARSEC_TTVALUE_H
4
5#include <type_traits>
6
8
9namespace ttg_parsec {
10
17 template<typename DerivedT>
18 struct TTValue : private ttg_parsec::detail::ttg_data_copy_container_setter<ttg_parsec::detail::ttg_data_copy_t>
20
21 using derived_type = std::decay_t<DerivedT>;
22
23 /* Constructor called with a pointer to the derived class object */
28
29 /* default copy ctor */
34
35 /* default move ctor */
38 , ttg_data_copy_t(std::move(v))
39 { }
40
41 /* virtual mark destructor */
42 virtual ~TTValue() = default;
43
44 /* default copy operator */
47 ttg_data_copy_t::operator=(v);
48 return *this;
49 }
50
51 /* default move operator */
54 ttg_data_copy_t::operator=(std::move(v));
55 return *this;
56 }
57
58 virtual void* get_ptr() override final {
59 return static_cast<DerivedT*>(this);
60 }
61
63 return *static_cast<DerivedT*>(this);
64 }
65
66 const derived_type& get_derived() const {
67 return *static_cast<DerivedT*>(this);
68 }
69 };
70
71 namespace detail {
72
73 template<typename T, typename Enabler = void>
74 struct is_ttvalue_base : std::false_type {};
75
76 template<typename T>
77 struct is_ttvalue_base<T, std::is_base_of<TTValue<std::decay_t<T>>, std::decay_t<T>>>
78 : std::true_type
79 { };
80
81 template<typename T>
82 static constexpr const bool is_ttvalue_base_v = is_ttvalue_base<T>::value;
83
84 template<typename ValueT>
86 using reference_type = ValueT;
87 using value_type = std::decay_t<ValueT>;
88 using lvalue_reference_type = std::add_lvalue_reference_t<std::remove_reference_t<ValueT>>;
90 };
91 } // namespace detail
92
93 template<typename ValueT>
94 inline auto persistent(ValueT&& value) {
95 if constexpr (std::is_base_of_v<TTValue<std::decay_t<ValueT>>, std::decay_t<ValueT>>) {
97 } else {
98 return std::forward<ValueT>(value);
99 }
100 }
101
102} // namespace ttg_parsec
103
104#endif // TTG_PARSEC_TTVALUE_H
STL namespace.
ttg_data_copy_t *& ttg_data_copy_container()
this contains PaRSEC-based TTG functionality
Definition fwd.h:19
auto persistent(ValueT &&value)
Definition ttvalue.h:94
TTValue(TTValue &&v)
Definition ttvalue.h:36
std::decay_t< DerivedT > derived_type
Definition ttvalue.h:21
const derived_type & get_derived() const
Definition ttvalue.h:66
TTValue & operator=(TTValue &&v)
Definition ttvalue.h:52
TTValue & operator=(const TTValue &v)
Definition ttvalue.h:45
derived_type & get_derived()
Definition ttvalue.h:62
virtual ~TTValue()=default
TTValue(const TTValue &v)
Definition ttvalue.h:30
virtual void * get_ptr() override final
Definition ttvalue.h:58
std::add_lvalue_reference_t< std::remove_reference_t< ValueT > > lvalue_reference_type
Definition ttvalue.h:88
lvalue_reference_type value_ref
Definition ttvalue.h:89
std::decay_t< ValueT > value_type
Definition ttvalue.h:87