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

error: implicit instantiation of undefined template 'std::tuple_size<rfl::Tuple<rfl::Field<...>>>' after #160 #178

Closed
Kicer86 opened this issue Aug 25, 2024 · 1 comment

Comments

@Kicer86
Copy link

Kicer86 commented Aug 25, 2024

Hi

I have a code like this:

const auto objView = rfl::to_view(obj);

const auto process = []<class... F>(F... _field) {
    ...
};

std::apply(process, objView.fields());

but after #160 it stopped working with:

/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/utility.h:75:44: error: implicit instantiation of undefined template 'std::tuple_size<rfl::Tuple<rfl::Field<internal::StringLiteral<8>{{"abc_vec"}}, const std::vector<ABC> *>, rfl::Field<internal::StringLiteral<10>{{"abc_deque"}}, const std::deque<ABC> *>>>'
   75 |     inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
      |                                            ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/tuple:2935:24: note: in instantiation of variable template specialization 'std::tuple_size_v<rfl::Tuple<rfl::Field<internal::StringLiteral<8>{{"abc_vec"}}, const std::vector<ABC> *>, rfl::Field<internal::StringLiteral<10>{{"abc_deque"}}, const std::deque<ABC> *>>>' requested here
 2935 |         = make_index_sequence<tuple_size_v<remove_reference_t<_Tuple>>>;
      |                               ^
/home/michal/projects/sources/broom/src/core/json_serializer.hpp:100:22: note: in instantiation of function template specialization 'std::apply<const (lambda at /home/michal/projects/sources/broom/src/core/json_serializer.hpp:96:38) &, rfl::Tuple<rfl::Field<internal::StringLiteral<8>{{"abc_vec"}}, const std::vector<ABC> *>, rfl::Field<internal::StringLiteral<10>{{"abc_deque"}}, const std::deque<ABC> *>>>' requested here
  100 |                 std::apply(process, objView.fields());
      |                      ^
/home/michal/projects/sources/broom/src/core/json_serializer.hpp:179:36: note: in instantiation of function template specialization 'JSon::impl::serialize<DEF>' requested here
  179 |         const auto jsonObj = impl::serialize(obj);
      |                                    ^
/home/michal/projects/sources/broom/src/core/unit_tests/json_serializer_tests.cpp:89:38: note: in instantiation of function template specialization 'JSon::serialize<DEF>' requested here
   89 |     const QJsonDocument json = JSon::serialize(def);
      |                                      ^
/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/utility.h:49:12: note: template is declared here
   49 |     struct tuple_size;
      |            ^

Should I implement it differently now?

@liuzicheng1987
Copy link
Contributor

For performance reasons, we replaced std::tuple with our own implementation, rfl::Tuple.

You can just replace std::apply with rfl::apply.

@Kicer86 Kicer86 closed this as completed Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants