C++03 bound functions are not available in C++17; remove

This makes me a little sad, it's time to move to C++11 or greater.
This commit is contained in:
John Hood
2018-07-21 23:41:48 -04:00
parent ace6324a77
commit 8ac80db419
5 changed files with 39 additions and 23 deletions
+15 -6
View File
@@ -40,8 +40,6 @@
using namespace Overlay; using namespace Overlay;
using std::max; using std::max;
using std::mem_fun_ref;
using std::bind2nd;
void ConditionalOverlayCell::apply( Framebuffer &fb, uint64_t confirmed_epoch, int row, bool flag ) const void ConditionalOverlayCell::apply( Framebuffer &fb, uint64_t confirmed_epoch, int row, bool flag ) const
{ {
@@ -380,7 +378,14 @@ void PredictionEngine::apply( Framebuffer &fb ) const
void PredictionEngine::kill_epoch( uint64_t epoch, const Framebuffer &fb ) void PredictionEngine::kill_epoch( uint64_t epoch, const Framebuffer &fb )
{ {
cursors.remove_if( bind2nd( mem_fun_ref( &ConditionalCursorMove::tentative ), epoch - 1 ) ); for( cursors_type::const_iterator it = cursors.begin(); it != cursors.end(); ) {
cursors_type::const_iterator it_next = it;
it_next++;
if ( it->tentative( epoch - 1 )) {
cursors.erase( it );
}
it = it_next;
}
cursors.push_back( ConditionalCursorMove( local_frame_sent + 1, cursors.push_back( ConditionalCursorMove( local_frame_sent + 1,
fb.ds.get_cursor_row(), fb.ds.get_cursor_row(),
@@ -623,9 +628,13 @@ void PredictionEngine::cull( const Framebuffer &fb )
ConditionalOverlayRow & PredictionEngine::get_or_make_row( int row_num, int num_cols ) ConditionalOverlayRow & PredictionEngine::get_or_make_row( int row_num, int num_cols )
{ {
overlays_type::iterator it = overlays_type::iterator it;
find_if( overlays.begin(), overlays.end(),
bind2nd( mem_fun_ref( &ConditionalOverlayRow::row_num_eq ), row_num ) ); for ( it = overlays.begin(); it != overlays.end(); it++ ) {
if ( it->row_num == row_num ) {
break;
}
}
if ( it != overlays.end() ) { if ( it != overlays.end() ) {
return *it; return *it;
-3
View File
@@ -133,9 +133,6 @@ namespace Overlay {
void apply( Framebuffer &fb, uint64_t confirmed_epoch, bool flag ) const; void apply( Framebuffer &fb, uint64_t confirmed_epoch, bool flag ) const;
/* For use with find_if */
bool row_num_eq( int v ) const { return row_num == v; }
ConditionalOverlayRow( int s_row_num ) : row_num( s_row_num ), overlay_cells() {} ConditionalOverlayRow( int s_row_num ) : row_num( s_row_num ), overlay_cells() {}
}; };
+15 -4
View File
@@ -360,12 +360,23 @@ void TransportSender<MyState>::process_acknowledgment_through( uint64_t ack_num
{ {
/* Ignore ack if we have culled the state it's acknowledging */ /* Ignore ack if we have culled the state it's acknowledging */
if ( sent_states.end() != typename sent_states_type::const_iterator i;
find_if( sent_states.begin(), sent_states.end(), for ( i = sent_states.begin(); i != sent_states.end(); i++ ) {
bind2nd( mem_fun_ref( &TimestampedState<MyState>::num_eq ), ack_num ) ) ) { if ( i->num == ack_num ) {
sent_states.remove_if( bind2nd( mem_fun_ref( &TimestampedState<MyState>::num_lt ), ack_num ) ); break;
}
} }
if ( i != sent_states.end() ) {
for ( i = sent_states.begin(); i != sent_states.end(); ) {
typename sent_states_type::const_iterator i_next = i;
i_next++;
if ( i->num < ack_num ) {
sent_states.erase( i );
}
i = i_next;
}
}
assert( !sent_states.empty() ); assert( !sent_states.empty() );
} }
-4
View File
@@ -45,10 +45,6 @@ namespace Network {
TimestampedState( uint64_t s_timestamp, uint64_t s_num, const State &s_state ) TimestampedState( uint64_t s_timestamp, uint64_t s_num, const State &s_state )
: timestamp( s_timestamp ), num( s_num ), state( s_state ) : timestamp( s_timestamp ), num( s_num ), state( s_state )
{} {}
/* For use with find_if, remove_if */
bool num_eq( uint64_t v ) const { return num == v; }
bool num_lt( uint64_t v ) const { return num < v; }
}; };
} }
+9 -6
View File
@@ -127,11 +127,6 @@ bool Complete::operator==( Complete const &x ) const
return (terminal == x.terminal) && (echo_ack == x.echo_ack); return (terminal == x.terminal) && (echo_ack == x.echo_ack);
} }
static bool old_ack(uint64_t newest_echo_ack, const pair<uint64_t, uint64_t> p)
{
return p.first < newest_echo_ack;
}
bool Complete::set_echo_ack( uint64_t now ) bool Complete::set_echo_ack( uint64_t now )
{ {
bool ret = false; bool ret = false;
@@ -145,7 +140,15 @@ bool Complete::set_echo_ack( uint64_t now )
} }
} }
input_history.remove_if( bind1st( ptr_fun( old_ack ), newest_echo_ack ) ); for ( input_history_type::const_iterator i = input_history.begin();
i != input_history.end(); ) {
input_history_type::const_iterator i_next = i;
i_next++;
if ( i->first < newest_echo_ack ) {
input_history.erase( i );
}
i = i_next;
}
if ( echo_ack != newest_echo_ack ) { if ( echo_ack != newest_echo_ack ) {
ret = true; ret = true;