File: p4.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 (61 lines) | stat: -rw-r--r-- 1,860 bytes parent folder | download | duplicates (18)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s

namespace PR8598 {
  template<class T> struct identity { typedef T type; };

  template<class T, class C>
  void f(T C::*, typename identity<T>::type*){}
  
  struct X { void f() {}; };
  
  void g() { (f)(&X::f, 0); }
}

namespace PR12132 {
  template<typename S> void fun(const int* const S::* member) {}
  struct A { int* x; };
  void foo() {
    fun(&A::x);
  }
  struct B { char* x; };
  void bar() {
    fun(&B::x);
    // expected-error@-1 {{no matching function for call to 'fun'}}
    // expected-note@-9  {{candidate template ignored: could not match 'const int' against 'char'}}
  }
}

#if __cplusplus > 201402L
namespace noexcept_conversion {
  template<typename R> void foo(R());
  template<typename R> void bar(R()) = delete;
  template<typename R> void bar(R() noexcept) {}
  void f() throw() {
    foo(&f);
    bar(&f);
  }
  // There is no corresponding rule for references.
  // We consider this to be a defect, and allow deduction to succeed in this
  // case. FIXME: Check this should be accepted once the DR is resolved.
  template<typename R> void baz(R(&)());
  void g() {
    baz(f);
  }

  // But there is one for member pointers.
  template<typename R, typename C, typename ...A> void quux(R (C::*)(A...));
  struct Q { void f(int, char) noexcept { quux(&Q::f); } };

  void g1() noexcept;
  void g2();
  template <class T> int h(T *, T *); // expected-note {{deduced conflicting types for parameter 'T' ('void () noexcept' vs. 'void ()')}}
  int x = h(g1, g2); // expected-error {{no matching function}}

  // We consider it a defect that deduction does not support the following.
  // FIXME: Check that the defect is resolved as we expect.
  template<bool B> int i(void () noexcept(B));
  int i1 = i(g1);
  int i2 = i(g2);
}
#endif