Why is the following code well-formed:
void foo(int i, int j = 56);
void foo(int i = 42, int j);
int main(){ }
Demo
But the following
void foo(int i = 42, int j);
void foo(int i, int j = 56);
int main(){ }
Demo
badly formed. I tried to find in N4296::8.3.6 [dcl.fct.default], and I found the following example:
class C
{
void f(int i = 3);
void g(int i, int j = 99);
};
void C::f(int i = 3) { }
void C::g(int i = 88, int j) {
}
But clang doesn't seem like that.
struct A
{
void foo(int i = 42, int j);
};
void A::foo(int i, int j = 56){ };
int main(){ }
Demo
So, is this an implementation issue? Formally, this whole example should be acceptable if they are?
user2953119
source
share