kokkos-execution
0.0.1
Toggle main menu visibility
Loading...
Searching...
No Matches
test_compile_time_optional.cpp
Go to the documentation of this file.
1
#include "gtest/gtest.h"
2
3
#include "
kokkos-execution/impl/compile_time_optional.hpp
"
4
15
16
namespace
Tests::Impl
{
17
18
struct
TestType
{
19
constexpr
TestType
(
int
first,
int
second) noexcept
20
:
m_c
(first + second) {
21
}
22
23
int
m_c
;
24
};
25
26
using
disabled_t
=
Kokkos::Execution::Impl::CompileTimeOptional<false, TestType>
;
27
using
enabled_t
=
Kokkos::Execution::Impl::CompileTimeOptional<true, TestType>
;
28
30
consteval
bool
test_disabled_is_empty_and_trivially_copyable
() {
31
return
std::is_empty_v<disabled_t> && std::is_trivially_copyable_v<disabled_t>;
32
}
33
34
static_assert
(
test_disabled_is_empty_and_trivially_copyable
());
35
37
consteval
bool
test_size_of_enabled
() {
38
return
sizeof
(
enabled_t
) ==
sizeof
(
typename
enabled_t::value_type);
39
}
40
41
static_assert
(
test_size_of_enabled
());
42
44
consteval
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
51
static_assert
(
test_constructible
());
52
54
TEST(CompileTimeOptionalTest, value) {
55
ASSERT_EQ(
enabled_t
(42, 666).value.m_c, 708);
56
}
57
58
}
// namespace Tests::Impl
compile_time_optional.hpp
Tests::Impl
Definition
test_compile_time_optional.cpp:16
Tests::Impl::test_constructible
consteval bool test_constructible()
Definition
test_compile_time_optional.cpp:44
Tests::Impl::test_disabled_is_empty_and_trivially_copyable
consteval bool test_disabled_is_empty_and_trivially_copyable()
Definition
test_compile_time_optional.cpp:30
Tests::Impl::enabled_t
Kokkos::Execution::Impl::CompileTimeOptional< true, TestType > enabled_t
Definition
test_compile_time_optional.cpp:27
Tests::Impl::test_size_of_enabled
consteval bool test_size_of_enabled()
Definition
test_compile_time_optional.cpp:37
Tests::Impl::disabled_t
Kokkos::Execution::Impl::CompileTimeOptional< false, TestType > disabled_t
Definition
test_compile_time_optional.cpp:26
Kokkos::Execution::Impl::CompileTimeOptional
Compile-time optional value that holds a T when Enabled, is an empty type otherwise.
Definition
compile_time_optional.hpp:17
Tests::Impl::TestType::TestType
constexpr TestType(int first, int second) noexcept
Definition
test_compile_time_optional.cpp:19
Tests::Impl::TestType::m_c
int m_c
Definition
test_compile_time_optional.cpp:23
tests
impl
test_compile_time_optional.cpp
Generated on
for kokkos-execution by
1.18.0