Skip to content

Commit

Permalink
Simplify mock_compile_time_properties.hpp by fakePropKind helper
Browse files Browse the repository at this point in the history
  • Loading branch information
aelovikov-intel committed Feb 27, 2024
1 parent 65c6e14 commit 1995fc5
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions sycl/test/extensions/properties/mock_compile_time_properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,25 @@ namespace sycl {
namespace ext {
namespace oneapi {
namespace experimental {
inline constexpr detail::PropKind fakePropKind(int N) {
return static_cast<detail::PropKind>(
static_cast<std::uint32_t>(detail::PropKind::PropKindSize) + N);
}

struct bar_key
: detail::compile_time_property_key<static_cast<detail::PropKind>(
static_cast<std::uint32_t>(detail::PropKind::PropKindSize) + 0)> {
struct bar_key : detail::compile_time_property_key<fakePropKind(0)> {
using value_t = property_value<bar_key>;
};

struct baz_key
: detail::compile_time_property_key<static_cast<detail::PropKind>(
static_cast<std::uint32_t>(detail::PropKind::PropKindSize) + 1)> {
struct baz_key : detail::compile_time_property_key<fakePropKind(1)> {
template <int K>
using value_t = property_value<baz_key, std::integral_constant<int, K>>;
};

struct boo_key
: detail::compile_time_property_key<static_cast<detail::PropKind>(
static_cast<std::uint32_t>(detail::PropKind::PropKindSize) + 2)> {
struct boo_key : detail::compile_time_property_key<fakePropKind(2)> {
template <typename... Ts> using value_t = property_value<boo_key, Ts...>;
};

struct foo
: detail::run_time_property_key<static_cast<detail::PropKind>(
static_cast<std::uint32_t>(detail::PropKind::PropKindSize) + 3)> {
struct foo : detail::run_time_property_key<fakePropKind(3)> {
constexpr foo(int v) : value(v) {}
int value;
};
Expand All @@ -48,9 +44,7 @@ inline bool operator==(const foo &lhs, const foo &rhs) {
}
inline bool operator!=(const foo &lhs, const foo &rhs) { return !(lhs == rhs); }

struct foz
: detail::run_time_property_key<static_cast<detail::PropKind>(
static_cast<std::uint32_t>(detail::PropKind::PropKindSize) + 4)> {
struct foz : detail::run_time_property_key<fakePropKind(4)> {
constexpr foz(float v1, bool v2) : value1(v1), value2(v2) {}
// Define copy constructor to make foz non-trivially copyable
constexpr foz(const foz &f) {
Expand All @@ -66,9 +60,7 @@ inline bool operator==(const foz &lhs, const foz &rhs) {
}
inline bool operator!=(const foz &lhs, const foz &rhs) { return !(lhs == rhs); }

struct fir
: detail::run_time_property_key<static_cast<detail::PropKind>(
static_cast<std::uint32_t>(detail::PropKind::PropKindSize) + 5)> {
struct fir : detail::run_time_property_key<fakePropKind(5)> {
// Intentionally not constexpr to test for properties that cannot be constexpr
fir(float v1, bool v2) : value1(v1), value2(v2) {}
// Define copy constructor to make foz non-trivially copyable
Expand Down

0 comments on commit 1995fc5

Please sign in to comment.