| 1 |
/* { dg-options "-O2 -fgraphite-identity" } */ |
| 2 |
|
| 3 |
struct Point |
| 4 |
{ |
| 5 |
int line, col; |
| 6 |
|
| 7 |
Point( int l = -1, int c = 0 ) throw() : line( l ), col( c ) {} |
| 8 |
bool operator==( const Point & p ) const throw() |
| 9 |
{ return ( line == p.line && col == p.col ); } |
| 10 |
bool operator<( const Point & p ) const throw() |
| 11 |
{ return ( line < p.line || ( line == p.line && col < p.col ) ); } |
| 12 |
}; |
| 13 |
|
| 14 |
class Buffer |
| 15 |
{ |
| 16 |
public: |
| 17 |
int characters( const int line ) const throw(); |
| 18 |
int pgetc( Point & p ) const throw(); |
| 19 |
Point eof() const throw() { return Point( 0, 0 ); } |
| 20 |
bool pisvalid( const Point & p ) const throw() |
| 21 |
{ return ( ( p.col >= 0 && p.col < characters( p.line ) ) || p == eof() ); |
| 22 |
} |
| 23 |
bool save( Point p1 = Point(), Point p2 = Point() ) const; |
| 24 |
}; |
| 25 |
|
| 26 |
bool Buffer::save( Point p1, Point p2 ) const |
| 27 |
{ |
| 28 |
if( !this->pisvalid( p1 ) ) p1 = eof(); |
| 29 |
if( !this->pisvalid( p2 ) ) p2 = eof(); |
| 30 |
for( Point p = p1; p < p2; ) { pgetc( p ); } |
| 31 |
return true; |
| 32 |
} |
| 33 |
|
| 34 |
|