Skip to content

Commit

Permalink
Merge pull request #313 from qicosmos/fix_check_cpp20
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos authored Oct 8, 2024
2 parents 697b38b + 3a6cd39 commit 095f27c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion iguana/ylt/reflection/member_names.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ inline constexpr size_t index_of(std::string_view name) {
return arr.size();
}

#if __has_include(<concetps>)
#if __cplusplus >= 202002L
template <typename T, FixedString name>
inline constexpr size_t index_of() {
return index_of<T>(name.str());
Expand Down
4 changes: 2 additions & 2 deletions iguana/ylt/reflection/member_value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ inline constexpr auto& get(T& t) {
return std::get<index>(ref_tp);
}

#if __has_include(<concetps>)
#if __cplusplus >= 202002L
template <FixedString name, typename T>
inline constexpr auto& get(T& t) {
constexpr size_t index = index_of<T, name>();
Expand Down Expand Up @@ -257,7 +257,7 @@ inline constexpr void for_each(T&& t, Visit&& func) {

#if (defined(__GNUC__) && __GNUC__ > 10) || \
((defined(__clang__) || defined(_MSC_VER)) && __has_include(<concepts>))
#if __has_include(<concetps>)
#if __cplusplus >= 202002L
template <ylt::reflection::FixedString s>
inline constexpr auto operator""_ylts() {
return s;
Expand Down
20 changes: 10 additions & 10 deletions test/test_reflection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ TEST_CASE("test member names") {
constexpr size_t tp_size = std::tuple_size_v<decltype(tp)>;
CHECK(tp_size == 5);

#if __has_include(<concetps>)
#if __cplusplus >= 202002L
constexpr auto arr = get_member_names<person>();
for (auto name : arr) {
std::cout << name << ", ";
Expand Down Expand Up @@ -144,13 +144,13 @@ void test_pt() {
static_assert(y == 4);
CHECK(y == 4);

#if __has_include(<concetps>)
#if __cplusplus >= 202002L
constexpr auto x = get<"x"_ylts>(pt);
static_assert(x == 2);
#endif
}

#if __has_include(<concetps>)
#if __cplusplus >= 202002L
TEST_CASE("test member value") {
simple p{.color = 2, .id = 10, .str = "hello reflection", .age = 6};
auto ref_tp = object_to_tuple(p);
Expand Down Expand Up @@ -180,7 +180,7 @@ TEST_CASE("test member value") {
auto& age1 = get<int>(p, "age");
CHECK(age1 == 6);

#if __has_include(<concetps>)
#if __cplusplus >= 202002L
auto& age2 = get<"age"_ylts>(p);
CHECK(age2 == 6);

Expand Down Expand Up @@ -240,7 +240,7 @@ TEST_CASE("test member value") {
constexpr std::string_view name2 = name_of<simple>(2);
CHECK(name2 == "str");

#if __has_include(<concetps>)
#if __cplusplus >= 202002L
constexpr size_t idx = index_of<simple, "str"_ylts>();
CHECK(idx == 2);

Expand Down Expand Up @@ -428,18 +428,18 @@ TEST_CASE("test macros") {
auto var = get(t, 3);
CHECK(*std::get<3>(var) == 6);

#if __has_include(<concetps>)
#if __cplusplus >= 202002L
auto& age2 = get<"age"_ylts>(t);
CHECK(age2 == 6);

auto& var1 = get<"str"_ylts>(t);
CHECK(var1 == "hello reflection");

constexpr size_t idx = index_of<simple2, "str"_ylts>();
CHECK(idx == 2);
constexpr size_t i1 = index_of<simple2, "str"_ylts>();
CHECK(i1 == 2);

constexpr size_t idx2 = index_of<simple2, "no_such"_ylts>();
CHECK(idx2 == 4);
constexpr size_t i2 = index_of<simple2, "no_such"_ylts>();
CHECK(i2 == 4);
#endif

constexpr std::string_view name1 = name_of<simple2, 2>();
Expand Down

0 comments on commit 095f27c

Please sign in to comment.