You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I am using EASTL's fixed_vector in a test.
When I try to CAPTURE() the fixed_vector, I get a compile error due to ambiguity of begin(), when trying to evaluate Catch::is_range::value:
../../3rdparty/catch2/single_include/catch2/catch.hpp|1979 col 41| error: call of overloaded ‘begin(eastl::fixed_vector<pu::Box<glm::vec<2, float, (glm::qualifier)0> >, 4, false>)’ is ambiguous
!std::is_same<decltype(begin(std::declval<T>())), not_this_one>::value &&
~~~~~^~~~~~~~~~~~~~~~~~~
(full error below)
Expected behavior
I would expect the appropriate begin() to be chosen.
In this case, it would be: eastl::begin
Theorizing
I imagine this has to do with some subtlety of ADL, but I am not sure.
Perhaps eastl::begin is a candidate because the type is from that namespace, and std::begin is an equally-good candidate because this is being evaluated within std::is_same ?
Or maybe it is due to this catch2 code.
Note that other cases outside of Catch2 work fine, such as:
for (auto i : myvec) {
//...
}
Though I know the rules for range-based for are a bit specialized, so maybe not the best example...
Reproduction steps
Nothing special with my setup; once you have EASTL and Catch2 set up, this will produce the error:
Yeah, this is not really possible to fix, unless you make EASTL live in std and use it as the standard library in your code.
To exposit a bit, the problem is caused by mix of ADL, unconstrained templates and common idioms in generic code. As an example, the idiom to swap two instances of a generic T is this:
using std::swap;
swap(a, b);
This works by bringing in std::swap, which has a reasonable templated fallback implementation that works with any copyable/moveable type, and then it allows for ADL to find a specialized swap implementation for the concrete type of a and b. However, if the swap implementation found by ADL is not a better match (for example, if it is also a template), then you end up with ambiguous call, like in this example.
You are running into the same problem, but with begin and end.
There should be a workaround though, if you explicitly specialize Catch::is_range for EASTL containers, you should avoid the compilation error because there will be no need for the generic range check.
Describe the bug
I am using EASTL's fixed_vector in a test.
When I try to CAPTURE() the fixed_vector, I get a compile error due to ambiguity of
begin()
, when trying to evaluateCatch::is_range::value
:(full error below)
Expected behavior
I would expect the appropriate
begin()
to be chosen.In this case, it would be: eastl::begin
Theorizing
I imagine this has to do with some subtlety of ADL, but I am not sure.
Perhaps
eastl::begin
is a candidate because the type is from that namespace, andstd::begin
is an equally-good candidate because this is being evaluated withinstd::is_same
?Or maybe it is due to this catch2 code.
Note that other cases outside of Catch2 work fine, such as:
Though I know the rules for range-based for are a bit specialized, so maybe not the best example...
Reproduction steps
Nothing special with my setup; once you have EASTL and Catch2 set up, this will produce the error:
Platform information:
Additional context
Full error output:
The text was updated successfully, but these errors were encountered: