扣除在类模板中声明的朋友函数的模板参数
考虑以下示例: #include template struct S { friend int Func(T) // decl-1 { return V; } }; struct U { friend int Func(U); // decl-2 }; templa…
如何将指针到基座转换为void比指针衍生到void转换更好
[over.ics.rank]/4 : [..] (4.3)如果B类直接或间接从A类派生,则B***的转换比B*转换为void*更好,并且A*转换为void*比B的转换更好* void*。 因此…
超载函数模板仅在C+&#x2B中仅在返回类型上有所不同。
众所周知,仅在返回类型上有所不同的普通函数不能在C ++中超载。 但是,此限制不适合过载函数模板,例如: int f(auto) { return 1; } auto f(auto) {…
foo(int,int)被挑选在foo(int ...)上
在此代码中,为什么编译器无法引用从静态上下文中具有varargs参数的方法。 private static void doSomething(int... nums) { System.out.println("1")…
C++当我调整其序列时,功能分辨率匹配不同的函数
我有一个测试程序,可以查看编译器(G ++)匹配模板函数的方式: #include templatevoid f(T){printf("T\n");} templatevoid f(T*){printf("T*\n");} …
为什么此功能调用不拒绝不合适的过载?
考虑以下代码: #include #include #include //using namespace std; using namespace std::ranges; int main() { std::vector a = {}; sort(a); retu…
为什么在过载分辨率期间认为静态成员函数具有隐式对象参数?
在此链接中:隐式对象参数 在这句话中: 如果任何候选函数是没有显式对象参数(自C ++ 23)而不是构造函数的成员函数(静态或非静态),则将其视为具…
ADL与当前名称空间中的功能发生冲突
我的命名空间中有一个功能。它的名称是销毁。 std 命名空间还包含 and nofollow noreferrer' 。当我在命名空间中调用我的功能时,调用是模棱两可的,…
sfinae在递归功能中没有工作
让我们创建咖喱函数。 template class CurryT { public: CurryT(const TFunc &func, const TArg &arg) : func(func), arg(arg ) {} template decltype…
[over.match.funcs.general]/9和继承的复制/移动构造函数上的问题
per : 从类型C([class.inhctor.init])继承的构造函数) 具有“引用CV1 P”类型的第一个参数(包括这样的A 从模板实例化的构造函数)不包括在一组 …
关于“完美匹配”的混乱和“与次要调整”的MatchB&quot在完美的转发CTOR与其他构造函数的背景下
我正在阅读第25章的第25章 c ++模板 - 完整指南 - 第二版。,在哪里,在哪里给定代码,像这样不太这样 #include template struct Tuple; template str…
传递概念约束的函数重载
以下代码无法编译(Godbolt 链接): #include template decltype(auto) g(Fn&& fn) { return fn(); } template requires(std::integral) int f() { r…