https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119899
Bug ID: 119899 Summary: Custom invoke has name collision with std::invoke, without using namespace std Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgcc Assignee: unassigned at gcc dot gnu.org Reporter: frederik.hofe at pm dot me Target Milestone: --- I get a name collision with std::invoke when using my custom invoke with a std::ref parameter, without pulling in the std:: namespace! There is a simple workaround by writing out the full namespace of my custom invoke. This happens with GCC and Clang. So I assume this is a libgcc issue. MSVC accepts this code. All tested on x86-64. This also needs C++17 or higher (When std::invoke was introduced) https://godbolt.org/z/W45W7j14c Or if godbolt forgets my code: #include <functional> namespace customNamespace { template<typename F, typename...Args> constexpr inline void invoke(F&& f, Args&&...args) {} template<typename F, typename...Args> constexpr inline void useMyCustomInvoke1(F&& f, Args&&...args) { invoke(std::forward<F>(f), std::forward<Args>(args)...); //namespace collision with std::invoke customNamespace::invoke(std::forward<F>(f), std::forward<Args>(args)...); //Workaround } } int main(int argc, char* argv[]) { auto lambda = [](int x){}; int i = 2; customNamespace::useMyCustomInvoke1(lambda, i); //no issue customNamespace::useMyCustomInvoke1(lambda, std::ref(i)); //triggers the issue! customNamespace::useMyCustomInvoke1(std::ref(lambda), i); //triggers the issue! }