Add make_shared emulation for std::tr1::shared_ptr; use make_shared

This commit is contained in:
John Hood
2014-06-15 00:59:55 -04:00
parent b41bad918d
commit 589d21bbf2
4 changed files with 49 additions and 9 deletions
+9 -3
View File
@@ -48,6 +48,7 @@
namespace Terminal {
using shared::shared_ptr;
using shared::make_shared;
typedef uint16_t color_type;
class Renditions {
@@ -156,7 +157,7 @@ namespace Terminal {
// in scrolling.
uint64_t gen;
Row( size_t s_width, color_type background_color );
Row( const size_t s_width, const color_type background_color );
Row(); /* default constructor required by C++11 STL */
void insert_cell( int col, color_type background_color );
@@ -315,7 +316,12 @@ namespace Terminal {
unsigned int bell_count;
bool title_initialized; /* true if the window title has been set via an OSC */
row_pointer newrow( void ) { return row_pointer( new Row( ds.get_width(), ds.get_background_rendition())); }
row_pointer newrow( void )
{
const size_t w = ds.get_width();
const color_type c = ds.get_background_rendition();
return make_shared<Row>( w, c );
}
public:
Framebuffer( int s_width, int s_height );
@@ -349,7 +355,7 @@ namespace Terminal {
row_pointer &mutable_row = rows.at( row );
// If the row is shared, copy it.
if (!mutable_row.unique()) {
mutable_row = row_pointer( new Row( *mutable_row ));
mutable_row = make_shared<Row>( *mutable_row );
}
return mutable_row.get();
}