Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.robertl/eb43.C

raw
1 // { dg-do assemble }
2 // { dg-skip-if "requires hosted libstdc++ for vector" { ! hostedlib } }
3 // All the pointer_to_binary_function cases used to fail because g++
4 // couldn't handle converting an overloaded function to a class type.
5 // The first one should still fail because it requires an implicit conversion
6 // to pointer_to_binary_function, which has an `explicit' constructor.
7
8 // { dg-prune-output "note" }
9 // { dg-options "-Wno-deprecated" }
10
11 #include <vector>
12 #include <algorithm>
13 #include <functional>
14
15 using namespace std;
16
17 template <class T> class Expr
18 {
19 public :
20 Expr(){}
21 Expr(const T&){}
22 };
23
24 template <class T >
25 inline bool compare(const Expr<T> a, const Expr<T> b){ return true; }
26
27 int main()
28 {
29 vector<int> a(3);
30 sort( a.begin(), a.end(),
31 static_cast<bool (*)(const Expr<int>,const Expr<int>)>(compare) );
32 sort( a.begin(), a.end(), compare<int> );
33 sort<vector<int>::iterator,
34 pointer_to_binary_function<const Expr<int>, const Expr<int>, bool> >
35 ( a.begin(), a.end(), compare ); // { dg-error "" } constructor is explicit
36 sort( a.begin(), a.end(),
37 ptr_fun<const Expr<int>, const Expr<int>, bool> (compare) );
38 sort( a.begin(), a.end(),
39 ptr_fun(compare<int>) );
40 sort( a.begin(), a.end(),
41 pointer_to_binary_function<const Expr<int>, const Expr<int>, bool>(compare) );
42 sort( a.begin(), a.end(),
43 pointer_to_binary_function<const Expr<int>, const Expr<int>, bool>(compare<int>) );
44 sort( a.begin(), a.end(),
45 pointer_to_binary_function<const Expr<int>, const Expr<int>, bool>(compare<>) );
46 }
47
48 // { dg-prune-output "enable_if" }