kokkos-execution 0.0.1
Loading...
Searching...
No Matches
compile_time_optional.hpp
Go to the documentation of this file.
1#ifndef KOKKOS_EXECUTION_IMPL_COMPILE_TIME_OPTIONAL_HPP
2#define KOKKOS_EXECUTION_IMPL_COMPILE_TIME_OPTIONAL_HPP
3
4#include <concepts>
5#include <type_traits>
6#include <utility>
7
9
16template <bool Enabled, typename T>
18
19template <typename T>
20struct CompileTimeOptional<false, T> {
21 using value_type = T;
22
23 constexpr CompileTimeOptional() noexcept = default;
24
26 template <typename... Args>
27 requires(!(sizeof...(Args) == 1 && (std::same_as<std::remove_cvref_t<Args>, CompileTimeOptional> && ...)))
28 constexpr explicit CompileTimeOptional(Args&&...) noexcept {
29 }
30};
31
32template <typename T>
33struct CompileTimeOptional<true, T> {
34 using value_type = T;
35
36 template <typename... Args>
37 requires(
38 std::constructible_from<T, Args...>
39 && !(sizeof...(Args) == 1 && (std::same_as<std::remove_cvref_t<Args>, CompileTimeOptional> && ...)))
40 constexpr explicit CompileTimeOptional(Args&&... args) noexcept(std::is_nothrow_constructible_v<T, Args&&...>)
41 : value(std::forward<Args>(args)...) {
42 }
43
45};
46
47} // namespace Kokkos::Execution::Impl
48
49#endif // KOKKOS_EXECUTION_IMPL_COMPILE_TIME_OPTIONAL_HPP
constexpr CompileTimeOptional(Args &&... args) noexcept(std::is_nothrow_constructible_v< T, Args &&... >)
Compile-time optional value that holds a T when Enabled, is an empty type otherwise.