1 // Copyright (C) 2000 Free Software Foundation, Inc.
2 // Contributed by Nathan Sidwell 18 Jan 2001 <nathan@codesourcery.com>
3 
4 // Bug 1617. We didn't resolve partial ordering properly. The std is rather
5 // vague about it anyway, DR 214 talks about this.
6 
7 extern "C" int puts (char const *);
8 
Foo(T *)9 template <typename T> int Foo (T *) {puts (__PRETTY_FUNCTION__); return 1;}
Foo(T &)10 template <typename T> int Foo (T &) {puts (__PRETTY_FUNCTION__); return 2;}
Foo(T const &)11 template <typename T> int Foo (T const &) {puts (__PRETTY_FUNCTION__); return 3;}
12 
Bar(T const * const &)13 template <typename T> int Bar (T const *const &) {puts (__PRETTY_FUNCTION__); return 4;}
Bar(T * const &)14 template <typename T> int Bar (T *const &) {puts (__PRETTY_FUNCTION__); return 5;}
Bar(T *)15 template <typename T> int Bar (T *) {puts (__PRETTY_FUNCTION__); return 6;}
16 
Quux(T * const &)17 template <typename T> int Quux (T *const &) {puts (__PRETTY_FUNCTION__); return 7;}
Quux(T const &)18 template <typename T> int Quux (T const &) {puts (__PRETTY_FUNCTION__); return 8;}
19 
20 
Baz(int const * ptr,int * ptr2)21 int Baz (int const *ptr, int *ptr2)
22 {
23   if (Foo (ptr) != 1)
24     return 1;
25   if (Foo (ptr2) != 1)
26     return 2;
27   if (Foo (*ptr) != 3)
28     return 3;
29   if (Foo (*ptr2) != 2)
30     return 4;
31 
32   if (Bar (ptr) != 4)
33     return 5;
34 
35   if (Quux (ptr) != 7)
36     return 5;
37   if (Quux (ptr2) != 7)
38     return 6;
39 
40   return 0;
41 }
42 
main()43 int main ()
44 {
45   return Baz (0, 0);
46 }
47