Closed ticelo closed 4 years ago
It was some code that wouldn't compile without the fix, just like this:
#include <iostream>
#include "third_party/refl-cpp/refl.hpp"
struct Label {
char const* text() const { return "(nothing here)"; }
};
REFL_TYPE(Label)
REFL_FUNC(text, property())
REFL_END
int main() {
Label l;
for_each(refl::reflect(l).members, [&](auto member) {
std::cout << get_display_name(member) << std::endl;
});
}
> clang++ -std=gnu++17 fix1_demo.cpp
In file included from fix1_demo.cpp:2:
./third_party/refl-cpp/refl.hpp:2143:38: error: incompatible operand types ('const char *const' and 'const refl::util::const_string<4>')
return friendly_name ? *friendly_name : t.name;
^ ~~~~~~~~~~~~~~ ~~~~~~
fix1_demo.cpp:21:22: note: in instantiation of function template specialization 'refl::descriptor::get_display_name<refl::descriptor::function_descriptor<Label, 0> >' requested here
std::cout <<get_display_name(member)<<std::endl;
^
1 error generated.
> clang++ --version
clang version 9.0.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
> git -C third_party/refl-cpp status
HEAD detached at d8bc094
nothing to commit, working tree clean
Have a nice day!
That wouldn't really fix anything, would it? The return type of
get_display_name
is specified asconst char*
. Also,const_string
is explicitly convertible toconst char*
. Are you running into an issue with the code as-is, or is this just an attempt at making the definition clearer?