Replace C++0x auto with Boost Typeof library

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg
2012-02-17 19:41:25 -05:00
parent bd3ffb85d5
commit 7d19fbe203
4 changed files with 24 additions and 20 deletions
+15 -14
View File
@@ -18,6 +18,7 @@
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/typeof/typeof.hpp>
#include <algorithm>
#include <wchar.h>
#include <list>
@@ -100,9 +101,9 @@ Validity ConditionalOverlayCell::get_validity( const Framebuffer &fb, int row,
|| ( (sent_frame <= early_ack) && (expiration_time <= now) ) ) {
if ( (current.contents == replacement.contents)
|| (current.is_blank() && replacement.is_blank()) ) {
auto it = find_if( original_contents.begin(), original_contents.end(),
BOOST_AUTO( it, find_if( original_contents.begin(), original_contents.end(),
(replacement.is_blank() && bind( &Cell::is_blank, _1 ))
|| replacement.contents == (&_1)->*&Cell::contents );
|| replacement.contents == (&_1)->*&Cell::contents ) );
if ( it == original_contents.end() ) {
return Correct;
} else {
@@ -340,8 +341,8 @@ void PredictionEngine::kill_epoch( uint64_t epoch, const Framebuffer &fb )
prediction_epoch ) );
cursor().active = true;
for ( auto i = overlays.begin(); i != overlays.end(); i++ ) {
for ( auto j = i->overlay_cells.begin(); j != i->overlay_cells.end(); j++ ) {
for ( BOOST_AUTO( i, overlays.begin() ); i != overlays.end(); i++ ) {
for ( BOOST_AUTO( j, i->overlay_cells.begin() ); j != i->overlay_cells.end(); j++ ) {
if ( j->tentative( epoch - 1 ) ) {
j->reset();
}
@@ -405,9 +406,9 @@ void PredictionEngine::cull( const Framebuffer &fb )
/* go through cell predictions */
auto i = overlays.begin();
BOOST_AUTO( i, overlays.begin() );
while ( i != overlays.end() ) {
auto inext = i;
BOOST_AUTO( inext, i );
inext++;
if ( (i->row_num < 0) || (i->row_num >= fb.ds.get_height()) ) {
overlays.erase( i );
@@ -415,7 +416,7 @@ void PredictionEngine::cull( const Framebuffer &fb )
continue;
}
for ( auto j = i->overlay_cells.begin(); j != i->overlay_cells.end(); j++ ) {
for ( BOOST_AUTO( j, i->overlay_cells.begin() ); j != i->overlay_cells.end(); j++ ) {
if ( j->start_clock( local_frame_acked, now, send_interval ) ) {
last_scheduled_timeout = max( last_scheduled_timeout, j->expiration_time );
}
@@ -505,7 +506,7 @@ void PredictionEngine::cull( const Framebuffer &fb )
}
/* go through cursor predictions */
for ( auto it = cursors.begin(); it != cursors.end(); it++ ) {
for ( BOOST_AUTO( it, cursors.begin() ); it != cursors.end(); it++ ) {
if ( it->start_clock( local_frame_acked, now, send_interval ) ) {
last_scheduled_timeout = max( last_scheduled_timeout, it->expiration_time );
}
@@ -536,8 +537,8 @@ void PredictionEngine::cull( const Framebuffer &fb )
ConditionalOverlayRow & PredictionEngine::get_or_make_row( int row_num, int num_cols )
{
auto it = find_if( overlays.begin(), overlays.end(),
(&_1)->*&ConditionalOverlayRow::row_num == row_num );
BOOST_AUTO( it, find_if( overlays.begin(), overlays.end(),
(&_1)->*&ConditionalOverlayRow::row_num == row_num ) );
if ( it != overlays.end() ) {
return *it;
@@ -573,7 +574,7 @@ void PredictionEngine::new_user_byte( char the_byte, const Framebuffer &fb )
list<Parser::Action *> actions( parser.input( the_byte ) );
for ( auto it = actions.begin(); it != actions.end(); it++ ) {
for ( BOOST_AUTO( it, actions.begin() ); it != actions.end(); it++ ) {
Parser::Action *act = *it;
/*
@@ -743,9 +744,9 @@ void PredictionEngine::newline_carriage_return( const Framebuffer &fb )
init_cursor( fb );
cursor().col = 0;
if ( cursor().row == fb.ds.get_height() - 1 ) {
for ( auto i = overlays.begin(); i != overlays.end(); i++ ) {
for ( BOOST_AUTO( i, overlays.begin() ); i != overlays.end(); i++ ) {
i->row_num--;
for ( auto j = i->overlay_cells.begin(); j != i->overlay_cells.end(); j++ ) {
for ( BOOST_AUTO( j, i->overlay_cells.begin() ); j != i->overlay_cells.end(); j++ ) {
if ( j->active ) {
j->expire( local_frame_sent + 1, now );
}
@@ -754,7 +755,7 @@ void PredictionEngine::newline_carriage_return( const Framebuffer &fb )
/* make blank prediction for last row */
ConditionalOverlayRow &the_row = get_or_make_row( cursor().row, fb.ds.get_width() );
for ( auto j = the_row.overlay_cells.begin(); j != the_row.overlay_cells.end(); j++ ) {
for ( BOOST_AUTO( j, the_row.overlay_cells.begin() ); j != the_row.overlay_cells.end(); j++ ) {
j->active = true;
j->tentative_until_epoch = prediction_epoch;
j->expire( local_frame_sent + 1, now );
+4 -3
View File
@@ -17,6 +17,7 @@
*/
#include <boost/lambda/lambda.hpp>
#include <boost/typeof/typeof.hpp>
#include <algorithm>
#include <list>
#include <stdio.h>
@@ -162,7 +163,7 @@ void TransportSender<MyState>::add_sent_state( uint64_t the_timestamp, uint64_t
{
sent_states.push_back( TimestampedState<MyState>( the_timestamp, num, state ) );
if ( sent_states.size() > 32 ) { /* limit on state queue */
auto last = sent_states.end();
BOOST_AUTO( last, sent_states.end() );
for ( int i = 0; i < 16; i++ ) { last--; }
sent_states.erase( last ); /* erase state from middle of queue */
}
@@ -259,7 +260,7 @@ void TransportSender<MyState>::send_in_fragments( string diff, uint64_t new_num
vector<Fragment> fragments = fragmenter.make_fragments( inst, connection->get_MTU() );
for ( auto i = fragments.begin(); i != fragments.end(); i++ ) {
for ( BOOST_AUTO( i, fragments.begin() ); i != fragments.end(); i++ ) {
connection->send( i->tostring() );
if ( verbose ) {
@@ -311,7 +312,7 @@ uint64_t TransportSender<MyState>::get_late_ack( uint64_t now )
{
uint64_t newest_echo_ack = 0;
for ( auto i = ack_history.begin(); i != ack_history.end(); i++ ) {
for ( BOOST_AUTO( i, ack_history.begin() ); i != ack_history.end(); i++ ) {
if ( i->second < now - ECHO_TIMEOUT ) {
newest_echo_ack = i->first;
}
+2 -1
View File
@@ -16,6 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <boost/typeof/typeof.hpp>
#include <assert.h>
#include <stdio.h>
@@ -42,7 +43,7 @@ std::string Display::new_frame( bool initialized, const Framebuffer &last, const
/* set window title */
frame.append( "\033]0;" );
const std::deque<wchar_t> &window_title( f.get_window_title() );
for ( auto i = window_title.begin();
for ( BOOST_AUTO( i, window_title.begin() );
i != window_title.end();
i++ ) {
snprintf( tmp, 64, "%lc", *i );
+2 -1
View File
@@ -16,6 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <boost/typeof/typeof.hpp>
#include <assert.h>
#include <stdio.h>
@@ -429,7 +430,7 @@ void Row::reset( int background_color )
void Framebuffer::prefix_window_title( const std::deque<wchar_t> &s )
{
for ( auto i = s.rbegin(); i != s.rend(); i++ ) {
for ( BOOST_AUTO( i, s.rbegin() ); i != s.rend(); i++ ) {
window_title.push_front( *i );
}
}