FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.robertl / eb43.C
blobc4cf02804c74e3c3b32f130b881e345140a61634
1 // All the pointer_to_binary_function cases used to fail because g++
2 // couldn't handle converting an overloaded function to a class type.
3 // The first one should still fail because it requires an implicit conversion
4 // to pointer_to_binary_function, which has an `explicit' constructor.
6 #include <vector>
7 #include <algorithm>
8 #include <functional>
10 using namespace std;
12 template <class T> class Expr 
14 public :
15   Expr(){};
16   Expr(const T&){};
19 template <class T >
20 inline bool compare(const Expr<T> a, const Expr<T> b){ return true; }
22 int main()
24   vector<int>   a(3);
25   sort( a.begin(), a.end(),
26         static_cast<bool (*)(const Expr<int>,const Expr<int>)>(compare) );
27   sort( a.begin(), a.end(), compare<int> );
28   sort<vector<int>::iterator,
29        pointer_to_binary_function<const Expr<int>, const Expr<int>, bool> >
30     ( a.begin(), a.end(), compare ); // ERROR - constructor is explicit
31   sort( a.begin(), a.end(),
32         ptr_fun<const Expr<int>, const Expr<int>, bool> (compare) );
33   sort( a.begin(), a.end(),
34         ptr_fun(compare<int>) );
35   sort( a.begin(), a.end(),
36         pointer_to_binary_function<const Expr<int>, const Expr<int>, bool>(compare) );
37   sort( a.begin(), a.end(),
38         pointer_to_binary_function<const Expr<int>, const Expr<int>, bool>(compare<int>) );
39   sort( a.begin(), a.end(),
40         pointer_to_binary_function<const Expr<int>, const Expr<int>, bool>(compare<>) );