Skip to content

Commit 784e7db

Browse files
Dawn Perchikzygoloid
authored andcommitted
CWG2273 Inheriting constructors vs implicit default constructor
Also fixes CWG2277.
1 parent dbe0b33 commit 784e7db

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

source/declarations.tex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3022,7 +3022,8 @@
30223022

30233023
\pnum
30243024
\indextext{overloading!using-declaration and}%
3025-
For the purpose of overload resolution, the functions that are
3025+
For the purpose of forming a set of candidates during overload resolution,
3026+
the functions that are
30263027
introduced by a \grammarterm{using-declaration} into a derived class
30273028
are treated as though they were members of the derived class. In
30283029
particular, the implicit \tcode{this} parameter shall be treated as if
@@ -3037,6 +3038,10 @@
30373038
of an object of class type, all subobjects other than the base class
30383039
from which the constructor originated
30393040
are implicitly initialized~(\ref{class.inhctor.init}).
3041+
\begin{note}
3042+
A member of a derived class is sometimes preferred to a member of a base class
3043+
if they would otherwise be ambiguous~(\ref{over.match.best}).
3044+
\end{note}
30403045

30413046
\pnum
30423047
\indextext{access control!using-declaration and}%

source/overloading.tex

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,6 +1676,29 @@
16761676
according to the partial ordering rules described in~\ref{temp.func.order},
16771677
or, if not that,
16781678

1679+
\item
1680+
\tcode{F1} is a constructor for a class \tcode{D},
1681+
\tcode{F2} is a constructor for a base class \tcode{B} of \tcode{D}, and
1682+
for all arguments
1683+
the corresponding parameters of \tcode{F1} and \tcode{F2} have the same type.
1684+
\begin{example}
1685+
\begin{codeblock}
1686+
struct A {
1687+
A(int = 0);
1688+
};
1689+
1690+
struct B: A {
1691+
using A::A;
1692+
B();
1693+
};
1694+
1695+
int main() {
1696+
B b; // OK, \tcode{B::B()}
1697+
}
1698+
\end{codeblock}
1699+
\end{example}
1700+
or, if not that,
1701+
16791702
\item
16801703
\tcode{F1} is generated from a
16811704
\grammarterm{deduction-guide}~(\ref{over.match.class.deduct})

0 commit comments

Comments
 (0)