kokkos-execution 0.0.1
Loading...
Searching...
No Matches
optional_ref.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_IMPL_OPTIONAL_REF_HPP
2#define KOKKOS_EXECUTION_IMPL_OPTIONAL_REF_HPP
3
4#include "Kokkos_Assert.hpp"
5
7
13template <typename T>
15 T* m_ptr = nullptr;
16
17 OptionalRef() = default;
18
19 explicit constexpr OptionalRef(T& value) noexcept
20 : m_ptr(std::addressof(value)) {
21 }
22
23 explicit constexpr OptionalRef(T&&) = delete;
24
25 [[nodiscard]]
26 constexpr bool has_value() const noexcept {
27 return m_ptr != nullptr;
28 }
29
30 [[nodiscard]]
31 constexpr T& get() const noexcept {
32 KOKKOS_EXPECTS(has_value());
33 return *m_ptr;
34 }
35};
36
37} // namespace Kokkos::Execution::Impl
38
39#endif // KOKKOS_EXECUTION_IMPL_OPTIONAL_REF_HPP
constexpr OptionalRef(T &value) noexcept
constexpr T & get() const noexcept
constexpr OptionalRef(T &&)=delete
constexpr bool has_value() const noexcept