kokkos-execution 0.0.1
Loading...
Searching...
No Matches
test_compile_time_optional.cpp
Go to the documentation of this file.
1#include "gtest/gtest.h"
2
4
15
16namespace Tests::Impl {
17
18struct TestType {
19 constexpr TestType(int first, int second) noexcept
20 : m_c(first + second) {
21 }
22
23 int m_c;
24};
25
28
31 return std::is_empty_v<disabled_t> && std::is_trivially_copyable_v<disabled_t>;
32}
33
35
37consteval bool test_size_of_enabled() {
38 return sizeof(enabled_t) == sizeof(typename enabled_t::value_type);
39}
40
41static_assert(test_size_of_enabled());
42
44consteval bool test_constructible() {
45 static_assert(
46 std::is_nothrow_constructible_v<enabled_t, int, int> && std::is_nothrow_constructible_v<disabled_t, int, int>);
47
48 return enabled_t(42, 666).value.m_c == 708;
49}
50
51static_assert(test_constructible());
52
54TEST(CompileTimeOptionalTest, value) {
55 ASSERT_EQ(enabled_t(42, 666).value.m_c, 708);
56}
57
58} // namespace Tests::Impl
consteval bool test_constructible()
consteval bool test_disabled_is_empty_and_trivially_copyable()
Kokkos::Execution::Impl::CompileTimeOptional< true, TestType > enabled_t
consteval bool test_size_of_enabled()
Kokkos::Execution::Impl::CompileTimeOptional< false, TestType > disabled_t
Compile-time optional value that holds a T when Enabled, is an empty type otherwise.
constexpr TestType(int first, int second) noexcept