20 template<
typename Reference>
23 return std::forward<Reference>(r);
31 template<
typename Reference>
34 using ValueType = std::decay_t<Reference>;
35 if constexpr(isProxyReference<ValueType>)
36 return static_cast<typename ValueType::value_type
>(r);
53 template<
typename Ref>
85 static_assert(
sizeof(T) == 0,
"You cannot write through a Const accessor");
91 template<
typename ProxyReference, std::enable_if_t<llama::isProxyReference<ProxyReference>,
int> = 0>
109 #ifdef __cpp_lib_atomic_ref
117 return std::atomic_ref<T>{r};
124 template<
typename Mutex = std::mutex>
128 std::unique_ptr<Mutex>
m = std::make_unique<Mutex>();
130 template<
typename Ref,
typename Value>
142 const std::lock_guard<Mutex> lock(
m);
150 const std::lock_guard<Mutex> lock(
m);
157 const std::lock_guard<Mutex> lock(
m);
163 template<
typename PR>
178 template<std::
size_t I,
typename Accessor>
187 template<
typename... Accessors>
193 template<
typename FirstAccessor,
typename... MoreAccessors>
194 struct Stacked<FirstAccessor, MoreAccessors...>
204 :
First{std::move(first)}
205 ,
Rest{std::move(rest)...}
209 template<
typename Reference>
212 return static_cast<const Rest&
>(*this)(
static_cast<const First&
>(*this)(std::forward<Reference>(r)));
#define LLAMA_FORCE_INLINE
Forces the compiler to inline a function annotated with this macro.
#define LLAMA_FN_HOST_ACC_INLINE
CRTP mixin for proxy reference types to support all compound assignment and increment/decrement opera...
Accessor wrapping a reference into a std::atomic_ref. Can only wrap l-value references.
auto operator()(T &r) const -> std::atomic_ref< T >
Allows only read access and returns values instead of references to memory.
auto operator()(Reference &&r) const
constexpr Reference(Ref ref)
Reference(const Reference &)=default
auto operator=(T) -> Reference &
typename Ref::value_type value_type
constexpr auto operator=(const Reference &other) -> Reference &
Allows only read access by qualifying the references to memory with const.
auto operator()(ProxyReference r) const
auto operator()(T &r) const -> const T &
Default accessor. Passes through the given reference.
auto operator()(Reference &&r) const -> Reference
constexpr auto operator=(const Reference &other) -> Reference &
auto operator=(T t) -> Reference &
Locks a mutex during each access to the data structure.
std::unique_ptr< Mutex > m
auto operator()(PR r) const -> Reference< PR, typename PR::value_type >
auto operator()(T &r) const -> Reference< T &, std::remove_cv_t< T >>
Qualifies references to memory with __restrict. Only works on l-value references.
auto operator()(T &r) const -> T &__restrict
Stacked(FirstAccessor first, MoreAccessors... rest)
auto operator()(Reference &&r) const -> decltype(auto)