1// { dg-do compile }
2
3namespace std __attribute__ ((__visibility__ ("default")))
4{
5  typedef __SIZE_TYPE__ size_t;
6  template<typename _Alloc>     class allocator;
7  template<class _CharT>     struct char_traits;
8  template<typename _CharT, typename _Traits = char_traits<_CharT>,
9      typename _Alloc = allocator<_CharT> >
10	  class basic_string;
11  typedef basic_string<char> string;
12  template<class _T1, class _T2>     struct pair     { };
13  template<typename _Tp>     class allocator    { };
14  template<typename _Arg1, typename _Arg2, typename _Result>
15      struct binary_function     {
16	  typedef _Arg1 first_argument_type;
17	  typedef _Arg2 second_argument_type;
18	  typedef _Result result_type;
19      };
20  template<typename _CharT, typename _Traits, typename _Alloc>
21  class basic_string {
22  public:
23      basic_string(const _CharT* __s, const _Alloc& __a = _Alloc());
24  };
25  class type_info   {
26  public:
27      const char* name() const;
28  };
29  extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__))
30  void * memcpy (void *__restrict __dest, __const void *__restrict __src, size_t __len) throw ()
31  {
32      return __builtin___memcpy_chk (__dest, __src, __len, __builtin_object_size (__dest, 0));
33  }
34  template <typename _Key, typename _Tp >
35  class map {
36      typedef _Key key_type;
37      typedef _Tp mapped_type;
38  public:
39      mapped_type&       operator[](const key_type& __k);
40  };
41}
42class CodeAlloc { };
43using namespace std;
44typedef void *Stack;
45class basicForEachType;
46typedef const basicForEachType * aType;
47extern map<const string,basicForEachType *> map_type;
48class AnyTypeWithOutCheck { };
49typedef AnyTypeWithOutCheck AnyType;
50template<typename T> AnyTypeWithOutCheck inline SetAny(const T & x)
51{
52  AnyTypeWithOutCheck any;
53  memcpy(&any,&x,sizeof(x));
54}
55template<typename T> const T& GetAny(const AnyTypeWithOutCheck & x);
56class E_F0;
57class C_F0;
58class Polymorphic;
59typedef E_F0 * Expression;
60class basicAC_F0;
61extern Polymorphic * TheOperators, * TheRightOperators;
62class basicForEachType : public CodeAlloc {
63public:
64    virtual C_F0 CastTo(const C_F0 & e) const ;
65};
66class E_F0 :public CodeAlloc    {
67public:
68    virtual AnyType operator()(Stack) const =0;
69};
70class E_F0mps : public E_F0 {
71};
72class ArrayOfaType : public CodeAlloc{
73protected:
74    aType * t;
75};
76class OneOperator : public ArrayOfaType {
77public:
78    OneOperator(aType rr,aType a,aType b);
79    virtual E_F0 * code(const basicAC_F0 &) const =0;
80};
81class Polymorphic: public E_F0mps {
82public:
83    void Add(const char * op,OneOperator * p0 ,OneOperator * p1=0) const;
84};
85class C_F0 {
86public:
87    operator E_F0 * () const;
88};
89class basicAC_F0 {
90public:
91    const C_F0 & operator [] (int i) const;
92};
93struct OneBinaryOperatorMI { };
94struct evalE_F2 { };
95template<typename C,class MI=OneBinaryOperatorMI,class MIx=evalE_F2 >
96class OneBinaryOperator : public OneOperator
97{
98  typedef typename C::result_type R;
99  typedef typename C::first_argument_type A;
100  typedef typename C::second_argument_type B;
101  aType t0,t1;
102  class Op : public E_F0 {
103      Expression a,b;
104  public:
105      AnyType operator()(Stack s) const {
106	  return SetAny<R>(static_cast<R>(C::f( GetAny<A>((*a)(s)),
107						GetAny<B>((*b)(s)))));
108      }
109      Op(Expression aa,Expression bb) : a(aa),b(bb) { }
110  };
111public:
112  E_F0 * code(const basicAC_F0 & args) const   {
113      return new Op(t0->CastTo(args[0]),t1->CastTo(args[1]));
114  }
115  OneBinaryOperator()
116      : OneOperator(map_type[typeid(R).name()],
117		    map_type[typeid(A).name()],
118		    map_type[typeid(B).name()]), t0(t[0]), t1(t[1]) { }
119};
120struct NothingType { };
121class ShapeOfArray{ };
122template<class R> class KN_: public ShapeOfArray { };
123template <class T> struct affectation: binary_function<T, T, T> { };
124template<class K,class L,class OP> struct set_A_BI
125: public binary_function<KN_<K>,pair<KN_<K>, KN_<L> > *,KN_<K> >
126{
127  static KN_<K> f(const KN_<K> & a, pair<KN_<K>, KN_<L> > * const & b);
128};
129template<class K,class L,class OP> struct set_AI_B
130: public binary_function<pair<KN_<K>, KN_<L> > * ,KN_<K>, NothingType >
131{
132  static NothingType f( pair<KN_<K>, KN_<L> > * const & b,const KN_<K> & a);
133};
134template<class K,class Z> void ArrayOperator()
135{
136  TheOperators->Add("=", new OneBinaryOperator<set_A_BI< K,Z,affectation<K> > >,
137		    new OneBinaryOperator<set_AI_B< K,Z,affectation<K> > >);
138}
139void initArrayOperatorlong() {
140    ArrayOperator<long,long>();
141}
142