gcc/testsuite/g++.dg/template/unify1.C
raw| 1 | // Test non-type template argument folding. |
| 2 | // Origin: [email protected] |
| 3 | |
| 4 | // { dg-do compile } |
| 5 | |
| 6 | template < int I1, int I2 > |
| 7 | class unit |
| 8 | { |
| 9 | public: |
| 10 | unit() {} |
| 11 | unit( const unit<I1,I2>& ) {} |
| 12 | |
| 13 | template< int Q1, int Q2 > |
| 14 | unit< I1 - Q1, I2 - Q2 > operator / ( const unit< Q1, Q2 >& rhs ) const { |
| 15 | return unit< I1 - Q1, I2 - Q2 >(); |
| 16 | } |
| 17 | |
| 18 | }; |
| 19 | |
| 20 | int main() |
| 21 | { |
| 22 | const unit<1,0> u1; |
| 23 | const unit<2,0> u2; |
| 24 | |
| 25 | unit<-1,0> u3( u1 / u2 ); |
| 26 | } |