Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[reflection]Fix check cpp20 #786

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/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 include/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
8 changes: 4 additions & 4 deletions src/reflection/tests/test_reflection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ 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
Expand Down Expand Up @@ -118,7 +118,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 @@ -178,7 +178,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 @@ -359,7 +359,7 @@ 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);

Expand Down
3 changes: 2 additions & 1 deletion src/struct_pb/examples/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ struct person {
std::string name;
int age;
};
#if __cplusplus >= 202002L

#if __GNUC__ < 11 || __cplusplus < 202002L
YLT_REFL(person, id, name, age);
#endif

Expand Down
Loading