#include <utility>
namespace nanobind {
template <typename T, typename U>
auto forward_like(U&& t) { return t; }
template <typename T>
auto func(T&& t) { return forward_like<T>(t); }
}
int main() {
auto p = std::pair(0, 0);
nanobind::func(p);
return 0;
}
x86-64 clang 17.0.1
x86-64 clang 17.0.1
-std=c++23 -stdlib=libc++ -Wall -Wextra
123
<Compilation failed>
# For more information see the output window
x86-64 clang 17.0.1 - cached
<source>:8:31: error: call to 'forward_like' is ambiguous
8 | auto func(T&& t) { return forward_like<T>(t); }
| ^~~~~~~~~~~~~~~
In particular, this will potentially occur when casting std object to a Python object using the nanobind STL caster.
The simplest solution is to rename forward_like (in this PR). We can also avoid ADL in other ways.
When nanobind user code enables C++23, I found that
nanobind::detail::forward_like
has a naming conflict withstd::forward_like
in STL due to ADL.The situation is like this:
In particular, this will potentially occur when casting std object to a Python object using the nanobind STL caster.
The simplest solution is to rename
forward_like
(in this PR). We can also avoid ADL in other ways.