Commit d146c305 by Robert Lipe

Additional changes from Martin.

From-SVN: r20167
parent 8e54705d
// Compiles. Shouldn't. //Build don't link:
class A { class A {
private: private:
int i1_; int i1_;
public: public:
void f(int const i1 = 1); void f(int const i1 = 1); // ERROR -
}; };
void void
A::f(int const i1 = 1) // !!! SHOULD TRIGGER AN ERROR !!! A::f(int const i1 = 1)
{ { // ERROR - duplicate default argument
i1_ = i1; i1_ = i1;
} }
......
//Build don't link:
#include <vector.h> #include <vector.h>
#include <algo.h> #include <algo.h>
......
...@@ -8,41 +8,26 @@ Expr(){}; ...@@ -8,41 +8,26 @@ Expr(){};
Expr(const T&){}; Expr(const T&){};
}; };
#ifdef TEMPLATE
template <class T > template <class T >
inline bool compare(const Expr<T> a, const Expr<T> b){ return true; }; inline bool compare(const Expr<T> a, const Expr<T> b){ return true; };
#else
inline bool compare(const Expr<int> a, const Expr<int> b){ return true; };
#endif
void main() void main()
{ {
vector<int> a(3); vector<int> a(3);
#if TEMPLATE == 1
sort( a.begin(), a.end(), sort( a.begin(), a.end(),
static_cast<bool (*)(const Expr<int>,const Expr<int>)>(compare) ); static_cast<bool (*)(const Expr<int>,const Expr<int>)>(compare) );
#elif TEMPLATE == 2
sort( a.begin(), a.end(), compare<int> ); sort( a.begin(), a.end(), compare<int> );
#elif TEMPLATE == 3
sort<vector<int>::iterator, sort<vector<int>::iterator,
pointer_to_binary_function<const Expr<int>, const Expr<int>, bool> > pointer_to_binary_function<const Expr<int>, const Expr<int>, bool> >
( a.begin(), a.end(), compare ); ( a.begin(), a.end(), compare );
#elif TEMPLATE == 4
sort( a.begin(), a.end(), sort( a.begin(), a.end(),
ptr_fun<const Expr<int>, const Expr<int>, bool> (compare) ); ptr_fun<const Expr<int>, const Expr<int>, bool> (compare) );
#elif TEMPLATE == 5
sort( a.begin(), a.end(), sort( a.begin(), a.end(),
ptr_fun(compare<int>) ); ptr_fun(compare<int>) );
#elif TEMPLATE == 6
sort( a.begin(), a.end(), sort( a.begin(), a.end(),
pointer_to_binary_function<const Expr<int>, const Expr<int>, bool>(compare) ); pointer_to_binary_function<const Expr<int>, const Expr<int>, bool>(compare) );
#elif TEMPLATE == 7
sort( a.begin(), a.end(), sort( a.begin(), a.end(),
pointer_to_binary_function<const Expr<int>, const Expr<int>, bool>(compare<int>) ); pointer_to_binary_function<const Expr<int>, const Expr<int>, bool>(compare<int>) );
#elif TEMPLATE == 8
sort( a.begin(), a.end(), sort( a.begin(), a.end(),
pointer_to_binary_function<const Expr<int>, const Expr<int>, bool>(compare<>) ); pointer_to_binary_function<const Expr<int>, const Expr<int>, bool>(compare<>) );
#else
sort( a.begin(), a.end(), compare );
#endif
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment