Annotation of researchv10dc/cmd/cfront/ooptcfront/demo/ltgt.c, revision 1.1.1.1

1.1       root        1: // just a simple check to verify that < and > operators are intact
                      2: 
                      3: #include <iostream.h>
                      4: 
                      5: 
                      6: template <class T>
                      7: class C
                      8: {
                      9: public:
                     10:   T x;
                     11: 
                     12:   C(T y) { x = y; }
                     13:   T f() { return x; }
                     14:   void m();
                     15:   int operator <(C&);
                     16: };
                     17: 
                     18: 
                     19: template <class T>
                     20: void C<T>::m()
                     21: { cout << x << "\n"; }
                     22: 
                     23: template <class T>
                     24: int C<T>::operator <(C<T>& c)
                     25: {
                     26:   return x < c.x;
                     27: }
                     28: 
                     29: 
                     30:   
                     31:  
                     32: #define check(p)  if (!(p))printf("\nerror(%d): test failed at line %d",++error, __LINE__) 
                     33: 
                     34: 
                     35: typedef char *pc ;
                     36: typedef int *pi ;
                     37: 
                     38: extern "C" void printf(...) ;
                     39: 
                     40: extern "C" void exit(int) ;
                     41: 
                     42: void end_test(int error) 
                     43: {
                     44:   printf ("\n*End Testing %s", __FILE__) ;
                     45:   if (error)
                     46:     printf (" *** %d errors ***\n", error) ;
                     47:   else printf (" no errors detected\n") ;
                     48:   
                     49:   exit(error) ;
                     50: }
                     51: 
                     52: main()
                     53: {
                     54:   printf ("\n*Begin Testing %s\n", __FILE__) ;
                     55:   
                     56:   C<float> x(3.5), y(5.0);
                     57:   int error = 0 ;
                     58: 
                     59:   check( x < y) ;
                     60: 
                     61:   end_test(error) ;
                     62: 
                     63: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.