|
|
Cases when overload resolution applies
I have two questions:
1) Shall overload resolution be applied to a set of candidate
functions which consist of a single function? (Presumably, yes)
void f() {}
int main()
{
f(); // f is only candidate for the call
}
2) May a selection process described in N3225 - 13.4 ("Address of
overloaded function") be considered as overload resolution?
(Presumably, no)
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
0
|
|
|
|
Reply
|
Nikolay
|
12/11/2010 4:30:15 PM |
|
Am 11.12.2010 23:30, schrieb Nikolay Ivchenkov:
>
> I have two questions:
>
> 1) Shall overload resolution be applied to a set of candidate
> functions which consist of a single function? (Presumably, yes)
>
> void f() {}
>
> int main()
> {
> f(); // f is only candidate for the call
> }
The standard is pretty fuzzy in this regard. In several occasions it uses the
term "overload resolution is applied" where it obviously means to include
non-overloaded functions. Even though, f is not overloaded here, "overload
resolution is applied". I don't like this pretty hairy discrimination, though. I
would prefer to consider f as "trivially overloaded" or some such term to help
unifying overloaded and non-overloaded functions in contexts where this would
simplify the wording.
But I agree with your assumption.
> 2) May a selection process described in N3225 - 13.4 ("Address of
> overloaded function") be considered as overload resolution?
> (Presumably, no)
I don't think so. This seems to be indicated in the way 13.3.1.1 notes in p. 2
the difference between 13.4 and real overload resolution:
[ Note: the resolution of the address of an overload
set in other contexts is described in 13.4. �end note ]
Real overload resolution involving function addresses is applied in case like these:
void f(int);
char f(double);
static_assert(sizeof(decltype((&f)(1.2))) == 1, "Error");
HTH & Greetings from Bremen,
Daniel Kr�gler
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
0
|
|
|
|
Reply
|
windows
|
12/13/2010 11:04:40 AM
|
|
OK. Let's consider
// non-overloaded
void f();
namespace N
{
struct X {};
void f(X) {}
}
// overloded
void g(int);
void g(long) {}
int main()
{
// both f are candidate functions
f(N::X());
// candidate functions aren't considered here
void (*p)(long) = &g;
}
Which functions in this example are odr-used (according to 3.2/2)?
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
0
|
|
|
|
Reply
|
Nikolay
|
12/14/2010 1:56:31 PM
|
|
|
2 Replies
116 Views
(page loaded in 0.052 seconds)
|
|
|
|
|
|
|
|
|