overload-resolution相关内容
Microsoft编译器(Visual Studio 2017 15.2)拒绝以下代码: #include 结构B { template = 0> void f(){} }; 结构D:B { 使用B :: f; template
..
考虑以下这段代码: template void foo() { } template void foo() { foo(); } int main() { foo()
..
请考虑以下示例代码: 示例: void print(int n){ cout vec){ cout
..
大多数 IO流操纵器是具有以下签名的常规函数: std :: ios_base& func(std :: ios_base& str); 但是某些操纵器(包括最常用的操纵器- std :: endl 和 std :: flush )是模板格式如下: template std :: basic_ostream
..
我试图理解为什么有人会写一个带有 const rvalue引用的函数。 在下面的代码示例中有什么用途是常量右值参考函数(返回“ 3”)。 为什么重载解析优先于const LValue引用函数上方的const Rvalue(返回“ 2”)。 #include #include #include std :: v
..
我写了一些代码 S s; ... s = {}; ,期望它结束与 S s = {}; 相同。但事实并非如此。以下示例重现了该问题: #include 结构S { S():a(5){} S(int t):a(t){} S& operator =(int t){a = t;返回* this; } S& operator =(S const& t
..
我试图理解为什么 std :: function 不能区分重载函数。 #include void add(int,int){} A类{}; void add(A,A){} int main(){ std :: function func =添加; } 在上面显示的代码中, fun
..
我们最近从公司的VS2013迁移到VS2017。升级后,我们的代码库将不再构建。我们将收到以下错误: 以下方法或属性之间的调用不明确:'IRepository .Get(object, params Expression> [])'和'IRepository .Get(object,params string [])' 这里是呼叫本身
..
此完整的C#程序说明了此问题: 公共抽象类Executor { public abstract void Execute(T item); } 类StringExecutor:执行程序 { public void Execute(对象项) { //为什么此方法会回调自身,而不是将 //绑定到更具体的“字符串” ”超载。 this.Exe
..
我最近在ENTT库中遇到了一个有趣的类.此类用于计算字符串哈希,如下所示: std::uint32_t hashVal = hashed_string::to_value("ABC"); hashed_string hs{"ABC"}; std::uint32_t hashVal2 = hs.value(); 在查看此类的实现时,我注意到没有一个构造函数或hashed_string:
..
$ 7.3.3/14(C ++ 03) struct A { int x(); }; struct B : A { }; struct C : A { using A::x; int x(int); }; struct D : B, C { using C::x; int x(double); }; int f(D* d) { return d->x(); //
..
以下内容无法使用clang35 -std=c++11进行编译: #include #include #include class A { public: A(int, bool) { std::cout
..
考虑方法mean的以下重载定义: def mean[T](data: Iterable[T])(implicit number: Fractional[T]): T = { import number._ val sum = data.foldLeft(zero)(plus) div(sum, fromInt(data.size)) } def mean[T](data: It
..
我用一个额外的模板参数创建了一个简单的舍入模板函数,该参数定义了返回前需要将舍入值转换为类型的类型. template T round(U val) { T result; if (val >= 0) result = (T)(floor(val + (U)(.5))); else re
..
#include struct uct { uct() { std::cerr
..
在尝试编译以下代码时,这些代码会将map s的密钥复制到vector: map mss; vector vs; transform(mss.begin(), mss.end(), back_inserter(vs), get); VS2013无法区分要使用哪个get,但是这种更简单的用法可以正常工作: vs.push_back
..
如此处所述 C ++ 11样式SFINAE和模板实例化上的函数可见性类成员函数使无用函数蒙上阴影。通常使用完全限定的名称是可行的,但是我很难与其他内联声明的类的朋友函数一起使用。考虑下面的示例: 命名空间N { 结构C { 朋友int f (const C& c){ 返回1; } 朋友int g(const C& c){ return 2; } }; 结构D { voi
..
在C#中,我对如何解析非虚拟方法的理解是,它取决于变量的类型(而不是实例的类型). 看看下面的代码. class Program { static void Main(string[] args) { Sedan vehicle = new Sedan(); vehicle.Drive(); vehicle.Acceler
..
我想做的是,允许使用setter函数传递指针,引用或常量引用: class A{ std::string * p; std::string st; public: A():p(0) {} A& setS(const std::string& s){ std::cout
..
我有此类在Scala中: object Util { class Tapper[A](tapMe: A) { def tap(f: A => Unit): A = { f(tapMe) tapMe } def tap(fs: (A => Unit)*): A = { fs.foreach(_(tapMe)) tap
..