Questions tagged [overload-resolution]

Overload resolution is a language mechanism to select among several viable function overloads. Its rules are intricate and often surprising, even for experienced users.

Overload resolution is a language mechanism to select among several viable function overloads.

Possible functions overloads are first determined from a candidate list resolution that itself includes inter ala. name lookups, template or generic determination and instantiation, promotions and conversions.

733 questions
0
votes
1 answer

Why am I getting "no matching function for call to '…'" with template function?

With the below code: materia.h: #ifndef MATERIA_H #define MATERIA_H class material { public: template static material* MakeMaterial(typename type::configtype, long); template void CreateNaturalForm(typename…
0
votes
1 answer

Overloading resolution of C++ virtual functions - references vs pointers

I'm puzzled by A behavior in C++ overloading resolution. I have 2 classes, A and B, with A<:B. A has a virtual function f and B is supposed to override that function. However, virtual functions don't seem to work as virtual when I invoke them using…
Agostino
  • 2,723
  • 9
  • 48
  • 65
0
votes
1 answer

Deduce function type of overloaded function based on argument types

Suppose there is an overloaded function: void overloaded(int) {} void overloaded(void) {} Because I don't want to (or can) write down the full function signature (like void(int) or void(void)) I need to get this signature using only the function…
Daniel Jour
  • 15,896
  • 2
  • 36
  • 63
0
votes
4 answers

Forcing late method resolution in case of class inheritance in c++

Consider the following class structure:- class foo { public: int fun () { cout << "in foo" << endl; } }; class bar_class1:public foo { public: int fun () { cout << "in bar_class1" << endl; …
Sagar Jha
  • 1,068
  • 4
  • 14
  • 24
0
votes
2 answers

Partial template specialization by overloading

I created a simple round template function with an extra template argument that defines the type the rounded value needs to be casted to before returning. template T round(U val) { T result; if (val >= 0) …
0
votes
2 answers

C++: "specializing" a member function template to work for derived classes from a certain base class

I have a base class MessageBase, from which I derive various other message classes, e.g., MessageDerived. I have another class that does some processing on various types of data, including a catchall method template: struct Process { void f(int…
Ari
  • 3,460
  • 3
  • 24
  • 31
0
votes
2 answers

Understanding method overloading rules

I have a string class: #include class CString { public: CString() {} explicit CString(uint64_t ui64, int width = -1, int base = 10, char fillChar = ' ') {} CString(const char * str) {} CString arg(const CString&…
Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
0
votes
1 answer

Why is Java picking this overload over the other

Could anyone explain to me why Java is picking the second overload instead of the first? public static void foo (int a, double b, double...c) {} public static void foo (double...a) {} public static void bar () { // this is the second …
One Two Three
  • 22,327
  • 24
  • 73
  • 114
0
votes
1 answer

Overload resolution of function templates in VS2013 RC

Compiling following code in VS2012 without any problem. struct Foo { typedef int DummyType; }; template int Bar(T* foo, typename T::DummyType* dummy_ = 0) { return 0; } template int Bar(T* foo, ...) { return 1;…
Orup
  • 559
  • 1
  • 5
  • 14
0
votes
1 answer

Function template specialization not called for derived type

I have a function template that I have specialized for a specific type. I'm having trouble getting the specialized version to be called in certain circumstances. To illustrate struct Base {}; struct Derived : public Base {}; template
0
votes
1 answer

Overload of QtGui.QLabel.setNum in PyQt4

In PyQt4, the slot QtGui.QLabel.setNum is overloaded. We have setNum( int ) and setNum( float ), linking to their c++ counterparts setNum( int) and setNum( double). I would like to connect a signal to the "float" version. label = QLabel() slider…
Quant
  • 1,593
  • 14
  • 21
0
votes
1 answer

VB.net Option Strict, listview.items.add(itm.clone) Overload

In VB.net (2012) I have the following code: For Each itm As ListViewItem In Me.lvCustomers If CDbl(itm.Tag) <> customer.Id Then Me.lvMerges.Items.Add(itm.Clone) Next With Option Strict On I get the following error: Error 2 Overload…
Jeff
  • 1,609
  • 3
  • 20
  • 25
0
votes
1 answer

How to perform overload resolution with generics programatically

I have a number of MethodBase instances referencing different open generic methods (expected), e.g. representing the following methods: T Foo(T nevermind, T other); T Foo(string nevermind, T other); And I have a single MethodBase instance…
NOtherDev
  • 9,542
  • 2
  • 36
  • 47
0
votes
1 answer

Trouble With Overload Resolution

Id like to say that there's a ton of C++ Overloading questions already on SO, but after an hour of looking at them and other posts on forums and newsgroups, I'm still stumped. Background I've created a namespace, call it A, where a bunch of classes…
daniel gratzer
  • 52,833
  • 11
  • 94
  • 134
0
votes
1 answer

Trouble with C++ templates (big surprise!). Why won't this work?

I am testing out a way to mimic C# properties and created the following property class: struct BY_REF { template struct TT_s { typedef T &TT_t; }; }; struct BY_VAL { template struct TT_s { …
Matt
  • 21,026
  • 18
  • 63
  • 115
1 2 3
48
49