OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [template/] [non-type1.C] - Blame information for rev 696

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// PR c++/4377
2
 
3
template < int I1, int I2 >
4
class unit
5
{
6
public:
7
  typedef unit my_type;
8
 
9
  unit() {}
10
  unit( const unit& ) {}
11
 
12
   template< int Q1, int Q2 >
13
   unit< I1 + Q1, I2 + Q2 > operator * ( const unit< Q1, Q2 >& rhs ) const {
14
     return unit< I1 + Q1, I2 + Q2 >();
15
   }
16
 
17
  template< int Q1, int Q2 >
18
  unit< I1 - Q1, I2 - Q2 > operator / ( const unit< Q1, Q2 >& rhs ) const {
19
    return unit< I1 - Q1, I2 - Q2 >();
20
  }
21
};
22
 
23
// specialization added to first test
24
//
25
template <>
26
class unit<0,0> {
27
public:
28
  typedef unit<0,0> my_type;
29
 
30
  unit() {}
31
 
32
   friend unit<0,0> operator*( const unit<0,0>& lhs, const unit<0,0>& rhs ) {
33
     return unit<0,0>();
34
   }
35
   friend unit<0,0> operator/( const unit<0,0>& lhs, const unit<0,0>& rhs ) {
36
     return unit<0,0>();
37
   }
38
 
39
};
40
 
41
 
42
int main()
43
{
44
  const unit<1,0> u1;
45
  const unit<2,0> u2;
46
 
47
  unit<-1,0> u3( u1 / u2 );
48
  unit< 3,0> u4( u1 * u2 );
49
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.