brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · a933f62 Raw
40 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify -std=c++1z %s2// expected-no-diagnostics3 4template<typename T> int &f0(T*, int);5float &f0(void*, int);6 7void test_f0(int* ip, void *vp) {8  // One argument is better...9  int &ir = f0(ip, 0);10  11  // Prefer non-templates to templates12  float &fr = f0(vp, 0);13}14 15namespace deduction_guide_example {16  template<typename T> struct A {17    A(T, int*);18    A(A<T>&, int*);19    enum { value };20  };21 22  template<typename T> struct remove_ref_impl;23  template<typename T> struct remove_ref_impl<T&> { using type = T; };24  template<typename T> using remove_ref = typename remove_ref_impl<T>::type;25 26  // FIXME: The standard's example is wrong; we add a remove_ref<...> here to27  // fix it.28  template<typename T, int N = remove_ref<T>::value> A(T&&, int*) -> A<T**>;29  A a{1, 0};30  extern A<int> a;31  A b{a, 0}; // uses the implicit ctor that is more specialized32 33  A<int> *pa = &a;34  A<int> *pb = &b;35}36 37// Partial ordering of function template specializations will be tested 38// elsewhere39// FIXME: Initialization by user-defined conversion is tested elsewhere40