File: p2.cpp

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (33 lines) | stat: -rw-r--r-- 1,040 bytes parent folder | download | duplicates (33)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// RUN: %clang_cc1 -std=c++11 -verify %s

namespace std_example {
  struct A { A(int); };
  struct B : A { using A::A; };

  struct C1 : B { using B::B; };
  struct C2 : B { using B::B; };

  struct D1 : C1, C2 {
    using C1::C1; // expected-note {{inherited from base class 'C1' here}}
    using C2::C2; // expected-note {{inherited from base class 'C2' here}}
  };

  struct V1 : virtual B { using B::B; };
  struct V2 : virtual B { using B::B; };

  struct D2 : V1, V2 {
    using V1::V1;
    using V2::V2;
  };

  D1 d1(0); // expected-error {{constructor of 'A' inherited from multiple base class subobjects}}
  D2 d2(0); // OK: initializes virtual B base class, which initializes the A base class
            // then initializes the V1 and V2 base classes as if by a defaulted default constructor

  struct M { M(); M(int); };
  struct N : M { using M::M; };
  struct O : M {};
  struct P : N, O { using N::N; using O::O; };
  P p(0); // OK: use M(0) to initialize N's base class,
          // use M() to initialize O's base class
}