-
Notifications
You must be signed in to change notification settings - Fork 54
Description
I ran into problems getting the following to work in Clang 12.0.0, using the latest master of visit_struct:
template <typename T>
struct TemplatedStruct
{
struct Visitable
{
BEGIN_VISITABLES(Visitable);
VISITABLE(int, a);
VISITABLE(int, b);
VISITABLE(int, c);
END_VISITABLES;
};
};
int main(int argc, char** argv)
{
TemplatedStruct<int> test;
return 0;
}For this minimal example, Clang outputs the following:
main.cpp:12:3: error: functions that differ only in their return type cannot be overloaded
VISITABLE(int, c);
^~~~~~~~~~~~~~~~~
visit_struct/include/visit_struct/visit_struct_intrusive.hpp:382:3: note: expanded from macro 'VISITABLE'
Visit_Struct_Get_Visitables__(::visit_struct::detail::Rank<VISIT_STRUCT_GET_REGISTERED_MEMBERS::size + 1>);
^
main.cpp:11:3: note: previous declaration is here
VISITABLE(int, b);
^~~~~~~~~~~~~~~~~
visit_struct/include/visit_struct/visit_struct_intrusive.hpp:382:3: note: expanded from macro 'VISITABLE'
Visit_Struct_Get_Visitables__(::visit_struct::detail::Rank<VISIT_STRUCT_GET_REGISTERED_MEMBERS::size + 1>);
^
1 error generated.
Both GCC and MSVC compile this example just fine, only Clang has problems with it. The problem happens only with visitable structs inside template classes. Without the template, it works just fine. Curiously, it also works fine with exactly 2 visitables in the struct - it starts failing for 3.