Replace C++0x lambda with Boost Lambda Library
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#include <boost/lambda/bind.hpp>
|
||||
#include <algorithm>
|
||||
#include <wchar.h>
|
||||
#include <list>
|
||||
@@ -24,6 +26,7 @@
|
||||
|
||||
#include "terminaloverlay.h"
|
||||
|
||||
using namespace boost::lambda;
|
||||
using namespace Overlay;
|
||||
using std::max;
|
||||
|
||||
@@ -98,8 +101,8 @@ Validity ConditionalOverlayCell::get_validity( const Framebuffer &fb, int row,
|
||||
if ( (current.contents == replacement.contents)
|
||||
|| (current.is_blank() && replacement.is_blank()) ) {
|
||||
auto it = find_if( original_contents.begin(), original_contents.end(),
|
||||
[&]( const Cell &x ) { return ( (replacement.is_blank() && x.is_blank())
|
||||
|| (replacement.contents == x.contents) ); } );
|
||||
(replacement.is_blank() && bind( &Cell::is_blank, _1 ))
|
||||
|| replacement.contents == (&_1)->*&Cell::contents );
|
||||
if ( it == original_contents.end() ) {
|
||||
return Correct;
|
||||
} else {
|
||||
@@ -311,7 +314,7 @@ void TitleEngine::set_prefix( const wstring s )
|
||||
|
||||
void ConditionalOverlayRow::apply( Framebuffer &fb, uint64_t confirmed_epoch, bool flag ) const
|
||||
{
|
||||
for_each( overlay_cells.begin(), overlay_cells.end(), [&]( const ConditionalOverlayCell &x ) { x.apply( fb, confirmed_epoch, row_num, flag ); } );
|
||||
for_each( overlay_cells.begin(), overlay_cells.end(), bind( &ConditionalOverlayCell::apply, _1, var(fb), confirmed_epoch, row_num, flag ) );
|
||||
}
|
||||
|
||||
void PredictionEngine::apply( Framebuffer &fb ) const
|
||||
@@ -321,15 +324,15 @@ void PredictionEngine::apply( Framebuffer &fb ) const
|
||||
|| (display_preference == Always) );
|
||||
|
||||
if ( show ) {
|
||||
for_each( cursors.begin(), cursors.end(), [&]( const ConditionalCursorMove &x ) { x.apply( fb, confirmed_epoch ); } );
|
||||
for_each( cursors.begin(), cursors.end(), bind( &ConditionalCursorMove::apply, _1, var(fb), confirmed_epoch ) );
|
||||
|
||||
for_each( overlays.begin(), overlays.end(), [&]( const ConditionalOverlayRow &x ){ x.apply( fb, confirmed_epoch, flagging ); } );
|
||||
for_each( overlays.begin(), overlays.end(), bind( &ConditionalOverlayRow::apply, _1, var(fb), confirmed_epoch, flagging ) );
|
||||
}
|
||||
}
|
||||
|
||||
void PredictionEngine::kill_epoch( uint64_t epoch, const Framebuffer &fb )
|
||||
{
|
||||
cursors.remove_if( [&]( ConditionalCursorMove &x ) { return x.tentative( epoch - 1 ); } );
|
||||
cursors.remove_if( bind( &ConditionalCursorMove::tentative, _1, epoch - 1 ) );
|
||||
|
||||
cursors.push_back( ConditionalCursorMove( local_frame_sent + 1,
|
||||
fb.ds.get_cursor_row(),
|
||||
@@ -526,16 +529,15 @@ void PredictionEngine::cull( const Framebuffer &fb )
|
||||
}
|
||||
}
|
||||
|
||||
cursors.remove_if( [&]( const ConditionalCursorMove &x ) {
|
||||
return (x.get_validity( fb,
|
||||
cursors.remove_if( bind( &ConditionalCursorMove::get_validity, _1, var(fb),
|
||||
local_frame_sent, local_frame_acked, local_frame_late_acked,
|
||||
now ) != Pending); } );
|
||||
now ) != Pending );
|
||||
}
|
||||
|
||||
ConditionalOverlayRow & PredictionEngine::get_or_make_row( int row_num, int num_cols )
|
||||
{
|
||||
auto it = find_if( overlays.begin(), overlays.end(),
|
||||
[&]( const ConditionalOverlayRow &x ) { return x.row_num == row_num; } );
|
||||
(&_1)->*&ConditionalOverlayRow::row_num == row_num );
|
||||
|
||||
if ( it != overlays.end() ) {
|
||||
return *it;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
#include <stdio.h>
|
||||
@@ -23,6 +24,7 @@
|
||||
#include "transportsender.h"
|
||||
#include "transportfragment.h"
|
||||
|
||||
using namespace boost::lambda;
|
||||
using namespace Network;
|
||||
using namespace std;
|
||||
|
||||
@@ -280,8 +282,8 @@ void TransportSender<MyState>::process_acknowledgment_through( uint64_t ack_num
|
||||
/* Ignore ack if we have culled the state it's acknowledging */
|
||||
|
||||
if ( sent_states.end() != find_if( sent_states.begin(), sent_states.end(),
|
||||
[&]( const TimestampedState<MyState> &x ) { return x.num == ack_num; } ) ) {
|
||||
sent_states.remove_if( [&]( const TimestampedState<MyState> &x ) { return x.num < ack_num; } );
|
||||
(&_1)->*&TimestampedState<MyState>::num == ack_num ) ) {
|
||||
sent_states.remove_if( (&_1)->*&TimestampedState<MyState>::num < ack_num );
|
||||
}
|
||||
|
||||
assert( !sent_states.empty() );
|
||||
@@ -315,7 +317,7 @@ uint64_t TransportSender<MyState>::get_late_ack( uint64_t now )
|
||||
}
|
||||
}
|
||||
|
||||
ack_history.remove_if( [&]( const pair<uint64_t, uint64_t> &x ) { return x.first < newest_echo_ack; } );
|
||||
ack_history.remove_if( (&_1)->*&pair<uint64_t, uint64_t>::first < newest_echo_ack );
|
||||
|
||||
return newest_echo_ack;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user