小编imi*_*mix的帖子

GCC 将 `set` 成员函数与 `std::set` 混淆

以下 C++ 代码给出了 GCC 错误(例如 13.1,请参阅godbolt.org),其中编译器似乎将set成员函数模板与混淆std::set

#include <set>
using namespace std;
template <typename T> struct C {
    template <int S> void set(T const &) { }
};
template <typename T> struct D : C<T> {
    void f(T const & v) { this->template set<0>(v); }
};
Run Code Online (Sandbox Code Playgroud)

它显然与该行有关,但我不明白当它由 显式限定时,using namespace std;编译器如何尝试set在全局或命名空间中查找。谁能启发我吗?stdthis->

c++ gcc compiler-bug

8
推荐指数
1
解决办法
171
查看次数

标签 统计

c++ ×1

compiler-bug ×1

gcc ×1