Skip to content

Commit b188b0d

Browse files
jensmaurerzygoloid
authored andcommitted
CWG2356 Base class copy and move constructors should not be inherited
1 parent 0aa43e6 commit b188b0d

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

source/overloading.tex

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,36 @@
630630

631631
\pnum
632632
A defaulted move special function\iref{class.copy} that is
633-
defined as deleted is excluded from the set of candidate functions in all
634-
contexts.
633+
defined as deleted is excluded from the set of candidate functions
634+
in all contexts.
635+
A constructor inherited from class type \tcode{C}\iref{class.inhctor.init}
636+
that has a first parameter of type ``reference to \cvqual{cv1} \tcode{P}''
637+
(including such a constructor instantiated from a template)
638+
is excluded from the set of candidate functions
639+
when constructing an object of type \cvqual{cv2} \tcode{D}
640+
if the argument list has exactly one argument and
641+
\tcode{C} is reference-related to \tcode{P} and
642+
\tcode{P} is reference-related to \tcode{D}.
643+
\begin{example}
644+
\begin{codeblock}
645+
struct A {
646+
A();
647+
A(A &&); // \#1
648+
template<typename T> A(T &&); // \#2
649+
};
650+
struct B : A {
651+
using A::A;
652+
B(const B &); // \#3
653+
B(B &&) = default; // \#4, implicitly deleted
654+
655+
struct X { X(X &&) = delete; } x;
656+
};
657+
extern B b1;
658+
B b2 = static_cast<B&&>(b1); // calls \#3: \#1, \#2, and \#4 are not viable
659+
struct C { operator B&&(); };
660+
B b3 = C(); // calls \#3
661+
\end{codeblock}
662+
\end{example}
635663

636664
\rSec3[over.match.call]{Function call syntax}%
637665
\indextext{overloading!resolution!function call syntax|(}

0 commit comments

Comments
 (0)