Closed seanbaxter closed 1 year ago
Ahh. My compiler was finding ranges::get::get via a using namespace directive in ranges ns. I guess that's not supposed to be used by argument dependent lookup. What obscurantist stuff!
namespace ns {
struct obj_t { };
namespace _get_ {
void get(obj_t);
}
using namespace _get_;
}
int main() {
ns::obj_t obj;
get(obj);
}
The get overloads were a major cause of poor compile times at one point. This tortured implementation avoided the problems. It could probably be simplified now.
I'm running up against infinite recursion when building some ranges code with circle.
Consider this
get
function. https://github.com/ericniebler/range-v3/blob/master/include/range/v3/utility/get.hpp#L37It's an ADL candidate of the trailing-return-type of
adl_get
, when passed a type in theranges
namespace: https://github.com/ericniebler/range-v3/blob/master/include/range/v3/detail/adl_get.hpp#L34But that
get
function at the top is a macro, and that expands the body of the function into a trailing-return-type. After macro expansion it looks like this:So you have get's trailing return type which calls adl_get, and adl_get's trailing return type does an ADL call back into get. Infinite recursion.
Why is this legal, and what is supposed to prevent the recursion?
Here's the sequence of instantiations: