veselink1/refl-cpp

constexpr if not a constant expression when using filter functions with const_string<N>

veselink1 opened this issue · 0 comments

constexpr auto contains(type_list<Ts...> list, const const_string<N>& name);
constexpr auto find_one(type_list<Ts...> list, const const_string<N>& name);

The overloads taking a const_string<N> do not work reliably. These functions currently wrap the passed in string in a lambda, which is later called in a constexpr context in filter(...). This does not work, as the captured variables by the lambda do not form a constant expression. The workaround is to pass in a lambda doing the comparison explicitly:

find_one(member_list<T>{}, [](auto member) { return member.name == "mymethod"; });

Some further investigation is required, but these will most likely end up being removed in the next release.