aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Alex Chernyakhovsky <alex@achernya.com>2023-07-30 17:20:33 -0400
committerGravatar Alex Chernyakhovsky <achernya@mit.edu>2023-07-30 19:02:51 -0400
commit38c84a9330a28ef1641014d189bfa5311405610e (patch)
tree18228a84e52e8a7d42f218660cfcd22112a4a545 /src
parent2224465cc9eec0acb5745348700c69c1d45d6c65 (diff)
Removed shared_ptr shim
Since C++17 is now the default mosh version, remove the shared_ptr shim in favor of std::shared_ptr.
Diffstat (limited to 'src')
-rw-r--r--src/examples/ntester.cc5
-rw-r--r--src/frontend/mosh-server.cc2
-rw-r--r--src/frontend/stmclient.h4
-rw-r--r--src/terminal/parseraction.h5
-rw-r--r--src/terminal/parserstate.cc77
-rw-r--r--src/terminal/parserstate.h4
-rw-r--r--src/terminal/parsertransition.h4
-rw-r--r--src/terminal/terminaldisplay.cc6
-rw-r--r--src/terminal/terminalframebuffer.cc4
-rw-r--r--src/terminal/terminalframebuffer.h15
-rw-r--r--src/tests/ocb-aes.cc4
-rw-r--r--src/util/Makefile.am2
-rw-r--r--src/util/shared.h90
13 files changed, 65 insertions, 157 deletions
diff --git a/src/examples/ntester.cc b/src/examples/ntester.cc
index 6e3c409..bd26409 100644
--- a/src/examples/ntester.cc
+++ b/src/examples/ntester.cc
@@ -33,12 +33,13 @@
#include <termios.h>
#include <unistd.h>
+#include <memory>
+
#include "src/statesync/user.h"
#include "src/util/fatal_assert.h"
#include "src/util/pty_compat.h"
#include "src/network/networktransport-impl.h"
#include "src/util/select.h"
-#include "src/util/shared.h"
using namespace Network;
@@ -50,7 +51,7 @@ int main( int argc, char *argv[] )
char *port;
UserStream me, remote;
- typedef shared::shared_ptr<Transport<UserStream, UserStream> > NetworkPointer;
+ using NetworkPointer = std::shared_ptr<Transport<UserStream, UserStream>>;
Transport<UserStream, UserStream> *raw_n;
try {
if ( argc > 1 ) {
diff --git a/src/frontend/mosh-server.cc b/src/frontend/mosh-server.cc
index 38d8fc2..4b13d9f 100644
--- a/src/frontend/mosh-server.cc
+++ b/src/frontend/mosh-server.cc
@@ -424,7 +424,7 @@ static int run_server( const char *desired_ip, const char *desired_port,
/* open network */
Network::UserStream blank;
- typedef shared::shared_ptr<ServerConnection> NetworkPointer;
+ using NetworkPointer = std::shared_ptr<ServerConnection>;
NetworkPointer network( new ServerConnection( terminal, blank, desired_ip, desired_port ) );
network->set_verbose( verbose );
diff --git a/src/frontend/stmclient.h b/src/frontend/stmclient.h
index 12a9512..3fccd1f 100644
--- a/src/frontend/stmclient.h
+++ b/src/frontend/stmclient.h
@@ -36,11 +36,11 @@
#include <sys/ioctl.h>
#include <termios.h>
#include <string>
+#include <memory>
#include "src/statesync/completeterminal.h"
#include "src/network/networktransport.h"
#include "src/statesync/user.h"
-#include "src/util/shared.h"
#include "src/frontend/terminaloverlay.h"
class STMClient {
@@ -62,7 +62,7 @@ private:
Terminal::Framebuffer local_framebuffer, new_state;
Overlay::OverlayManager overlays;
typedef Network::Transport< Network::UserStream, Terminal::Complete > NetworkType;
- typedef shared::shared_ptr< NetworkType > NetworkPointer;
+ using NetworkPointer = std::shared_ptr<NetworkType>;
NetworkPointer network;
Terminal::Display display;
diff --git a/src/terminal/parseraction.h b/src/terminal/parseraction.h
index 5a6c8ca..e102d40 100644
--- a/src/terminal/parseraction.h
+++ b/src/terminal/parseraction.h
@@ -33,11 +33,10 @@
#ifndef PARSERACTION_HPP
#define PARSERACTION_HPP
+#include <memory>
#include <string>
#include <vector>
-#include "src/util/shared.h"
-
namespace Terminal {
class Emulator;
}
@@ -59,7 +58,7 @@ namespace Parser {
virtual ~Action() {};
};
- typedef shared::shared_ptr<Action> ActionPointer;
+ using ActionPointer = std::shared_ptr<Action>;
typedef std::vector<ActionPointer> Actions;
class Ignore : public Action {
diff --git a/src/terminal/parserstate.cc b/src/terminal/parserstate.cc
index 3d60170..094c328 100644
--- a/src/terminal/parserstate.cc
+++ b/src/terminal/parserstate.cc
@@ -30,9 +30,10 @@
also delete it here.
*/
+#include <memory>
+
#include "parserstate.h"
#include "parserstatefamily.h"
-#include "src/util/shared.h"
using namespace Parser;
@@ -42,7 +43,7 @@ Transition State::anywhere_rule( wchar_t ch ) const
|| ((0x80 <= ch) && (ch <= 0x8F))
|| ((0x91 <= ch) && (ch <= 0x97))
|| (ch == 0x99) || (ch == 0x9A) ) {
- return Transition( shared::make_shared<Execute>(), &family->s_Ground );
+ return Transition( std::make_shared<Execute>(), &family->s_Ground );
} else if ( ch == 0x9C ) {
return Transition( &family->s_Ground );
} else if ( ch == 0x1B ) {
@@ -93,11 +94,11 @@ static bool GLGR ( wchar_t ch )
Transition Ground::input_state_rule( wchar_t ch ) const
{
if ( C0_prime( ch ) ) {
- return Transition( shared::make_shared< Execute >() );
+ return Transition( std::make_shared<Execute>() );
}
if ( GLGR( ch ) ) {
- return Transition( shared::make_shared< Print >() );
+ return Transition( std::make_shared<Print>() );
}
return Transition();
@@ -105,17 +106,17 @@ Transition Ground::input_state_rule( wchar_t ch ) const
ActionPointer Escape::enter( void ) const
{
- return shared::make_shared< Clear >();
+ return std::make_shared<Clear>();
}
Transition Escape::input_state_rule( wchar_t ch ) const
{
if ( C0_prime( ch ) ) {
- return Transition( shared::make_shared< Execute >() );
+ return Transition( std::make_shared<Execute>() );
}
if ( (0x20 <= ch) && (ch <= 0x2F) ) {
- return Transition( shared::make_shared< Collect >(), &family->s_Escape_Intermediate );
+ return Transition( std::make_shared<Collect>(), &family->s_Escape_Intermediate );
}
if ( ( (0x30 <= ch) && (ch <= 0x4F) )
@@ -124,7 +125,7 @@ Transition Escape::input_state_rule( wchar_t ch ) const
|| ( ch == 0x5A )
|| ( ch == 0x5C )
|| ( (0x60 <= ch) && (ch <= 0x7E) ) ) {
- return Transition( shared::make_shared< Esc_Dispatch >(), &family->s_Ground );
+ return Transition( std::make_shared<Esc_Dispatch>(), &family->s_Ground );
}
if ( ch == 0x5B ) {
@@ -149,15 +150,15 @@ Transition Escape::input_state_rule( wchar_t ch ) const
Transition Escape_Intermediate::input_state_rule( wchar_t ch ) const
{
if ( C0_prime( ch ) ) {
- return Transition( shared::make_shared< Execute >() );
+ return Transition( std::make_shared<Execute>() );
}
if ( (0x20 <= ch) && (ch <= 0x2F) ) {
- return Transition( shared::make_shared< Collect >() );
+ return Transition( std::make_shared<Collect>() );
}
if ( (0x30 <= ch) && (ch <= 0x7E) ) {
- return Transition( shared::make_shared< Esc_Dispatch >(), &family->s_Ground );
+ return Transition( std::make_shared<Esc_Dispatch>(), &family->s_Ground );
}
return Transition();
@@ -165,26 +166,26 @@ Transition Escape_Intermediate::input_state_rule( wchar_t ch ) const
ActionPointer CSI_Entry::enter( void ) const
{
- return shared::make_shared< Clear >();
+ return std::make_shared<Clear>();
}
Transition CSI_Entry::input_state_rule( wchar_t ch ) const
{
if ( C0_prime( ch ) ) {
- return Transition( shared::make_shared< Execute >() );
+ return Transition( std::make_shared<Execute>() );
}
if ( (0x40 <= ch) && (ch <= 0x7E) ) {
- return Transition( shared::make_shared< CSI_Dispatch >(), &family->s_Ground );
+ return Transition( std::make_shared<CSI_Dispatch>(), &family->s_Ground );
}
if ( ( (0x30 <= ch) && (ch <= 0x39) )
|| ( ch == 0x3B ) ) {
- return Transition( shared::make_shared< Param >(), &family->s_CSI_Param );
+ return Transition( std::make_shared<Param>(), &family->s_CSI_Param );
}
if ( (0x3C <= ch) && (ch <= 0x3F) ) {
- return Transition( shared::make_shared< Collect >(), &family->s_CSI_Param );
+ return Transition( std::make_shared<Collect>(), &family->s_CSI_Param );
}
if ( ch == 0x3A ) {
@@ -192,7 +193,7 @@ Transition CSI_Entry::input_state_rule( wchar_t ch ) const
}
if ( (0x20 <= ch) && (ch <= 0x2F) ) {
- return Transition( shared::make_shared< Collect >(), &family->s_CSI_Intermediate );
+ return Transition( std::make_shared<Collect>(), &family->s_CSI_Intermediate );
}
return Transition();
@@ -201,11 +202,11 @@ Transition CSI_Entry::input_state_rule( wchar_t ch ) const
Transition CSI_Param::input_state_rule( wchar_t ch ) const
{
if ( C0_prime( ch ) ) {
- return Transition( shared::make_shared< Execute >() );
+ return Transition( std::make_shared<Execute>() );
}
if ( ( (0x30 <= ch) && (ch <= 0x39) ) || ( ch == 0x3B ) ) {
- return Transition( shared::make_shared< Param >() );
+ return Transition( std::make_shared<Param>() );
}
if ( ( ch == 0x3A ) || ( (0x3C <= ch) && (ch <= 0x3F) ) ) {
@@ -213,11 +214,11 @@ Transition CSI_Param::input_state_rule( wchar_t ch ) const
}
if ( (0x20 <= ch) && (ch <= 0x2F) ) {
- return Transition( shared::make_shared< Collect >(), &family->s_CSI_Intermediate );
+ return Transition( std::make_shared<Collect>(), &family->s_CSI_Intermediate );
}
if ( (0x40 <= ch) && (ch <= 0x7E) ) {
- return Transition( shared::make_shared< CSI_Dispatch >(), &family->s_Ground );
+ return Transition( std::make_shared<CSI_Dispatch>(), &family->s_Ground );
}
return Transition();
@@ -226,15 +227,15 @@ Transition CSI_Param::input_state_rule( wchar_t ch ) const
Transition CSI_Intermediate::input_state_rule( wchar_t ch ) const
{
if ( C0_prime( ch ) ) {
- return Transition( shared::make_shared< Execute >() );
+ return Transition( std::make_shared<Execute>() );
}
if ( (0x20 <= ch) && (ch <= 0x2F) ) {
- return Transition( shared::make_shared< Collect >() );
+ return Transition( std::make_shared<Collect>() );
}
if ( (0x40 <= ch) && (ch <= 0x7E) ) {
- return Transition( shared::make_shared< CSI_Dispatch >(), &family->s_Ground );
+ return Transition( std::make_shared<CSI_Dispatch>(), &family->s_Ground );
}
if ( (0x30 <= ch) && (ch <= 0x3F) ) {
@@ -247,7 +248,7 @@ Transition CSI_Intermediate::input_state_rule( wchar_t ch ) const
Transition CSI_Ignore::input_state_rule( wchar_t ch ) const
{
if ( C0_prime( ch ) ) {
- return Transition( shared::make_shared< Execute >() );
+ return Transition( std::make_shared<Execute>() );
}
if ( (0x40 <= ch) && (ch <= 0x7E) ) {
@@ -259,13 +260,13 @@ Transition CSI_Ignore::input_state_rule( wchar_t ch ) const
ActionPointer DCS_Entry::enter( void ) const
{
- return shared::make_shared< Clear >();
+ return std::make_shared<Clear>();
}
Transition DCS_Entry::input_state_rule( wchar_t ch ) const
{
if ( (0x20 <= ch) && (ch <= 0x2F) ) {
- return Transition( shared::make_shared< Collect >(), &family->s_DCS_Intermediate );
+ return Transition( std::make_shared<Collect>(), &family->s_DCS_Intermediate );
}
if ( ch == 0x3A ) {
@@ -273,11 +274,11 @@ Transition DCS_Entry::input_state_rule( wchar_t ch ) const
}
if ( ( (0x30 <= ch) && (ch <= 0x39) ) || ( ch == 0x3B ) ) {
- return Transition( shared::make_shared< Param >(), &family->s_DCS_Param );
+ return Transition( std::make_shared<Param>(), &family->s_DCS_Param );
}
if ( (0x3C <= ch) && (ch <= 0x3F) ) {
- return Transition( shared::make_shared< Collect >(), &family->s_DCS_Param );
+ return Transition( std::make_shared<Collect>(), &family->s_DCS_Param );
}
if ( (0x40 <= ch) && (ch <= 0x7E) ) {
@@ -290,7 +291,7 @@ Transition DCS_Entry::input_state_rule( wchar_t ch ) const
Transition DCS_Param::input_state_rule( wchar_t ch ) const
{
if ( ( (0x30 <= ch) && (ch <= 0x39) ) || ( ch == 0x3B ) ) {
- return Transition( shared::make_shared< Param >() );
+ return Transition( std::make_shared<Param>() );
}
if ( ( ch == 0x3A ) || ( (0x3C <= ch) && (ch <= 0x3F) ) ) {
@@ -298,7 +299,7 @@ Transition DCS_Param::input_state_rule( wchar_t ch ) const
}
if ( (0x20 <= ch) && (ch <= 0x2F) ) {
- return Transition( shared::make_shared< Collect >(), &family->s_DCS_Intermediate );
+ return Transition( std::make_shared<Collect>(), &family->s_DCS_Intermediate );
}
if ( (0x40 <= ch) && (ch <= 0x7E) ) {
@@ -311,7 +312,7 @@ Transition DCS_Param::input_state_rule( wchar_t ch ) const
Transition DCS_Intermediate::input_state_rule( wchar_t ch ) const
{
if ( (0x20 <= ch) && (ch <= 0x2F) ) {
- return Transition( shared::make_shared< Collect >() );
+ return Transition( std::make_shared<Collect>() );
}
if ( (0x40 <= ch) && (ch <= 0x7E) ) {
@@ -327,18 +328,18 @@ Transition DCS_Intermediate::input_state_rule( wchar_t ch ) const
ActionPointer DCS_Passthrough::enter( void ) const
{
- return shared::make_shared< Hook >();
+ return std::make_shared<Hook>();
}
ActionPointer DCS_Passthrough::exit( void ) const
{
- return shared::make_shared< Unhook >();
+ return std::make_shared<Unhook>();
}
Transition DCS_Passthrough::input_state_rule( wchar_t ch ) const
{
if ( C0_prime( ch ) || ( (0x20 <= ch) && (ch <= 0x7E) ) ) {
- return Transition( shared::make_shared< Put >() );
+ return Transition( std::make_shared<Put>() );
}
if ( ch == 0x9C ) {
@@ -359,18 +360,18 @@ Transition DCS_Ignore::input_state_rule( wchar_t ch ) const
ActionPointer OSC_String::enter( void ) const
{
- return shared::make_shared< OSC_Start >();
+ return std::make_shared<OSC_Start>();
}
ActionPointer OSC_String::exit( void ) const
{
- return shared::make_shared< OSC_End >();
+ return std::make_shared<OSC_End>();
}
Transition OSC_String::input_state_rule( wchar_t ch ) const
{
if ( (0x20 <= ch) && (ch <= 0x7F) ) {
- return Transition( shared::make_shared< OSC_Put >() );
+ return Transition( std::make_shared<OSC_Put>() );
}
if ( (ch == 0x9C) || (ch == 0x07) ) { /* 0x07 is xterm non-ANSI variant */
diff --git a/src/terminal/parserstate.h b/src/terminal/parserstate.h
index 39116e6..07c4573 100644
--- a/src/terminal/parserstate.h
+++ b/src/terminal/parserstate.h
@@ -50,8 +50,8 @@ namespace Parser {
public:
void setfamily( StateFamily *s_family ) { family = s_family; }
Transition input( wchar_t ch ) const;
- virtual ActionPointer enter( void ) const { return shared::make_shared< Ignore >(); }
- virtual ActionPointer exit( void ) const { return shared::make_shared< Ignore >(); }
+ virtual ActionPointer enter( void ) const { return std::make_shared<Ignore>(); }
+ virtual ActionPointer exit( void ) const { return std::make_shared<Ignore>(); }
State() : family( NULL ) {};
virtual ~State() {};
diff --git a/src/terminal/parsertransition.h b/src/terminal/parsertransition.h
index 8a5c205..cc2c6f5 100644
--- a/src/terminal/parsertransition.h
+++ b/src/terminal/parsertransition.h
@@ -58,14 +58,14 @@ namespace Parser {
return *this;
}
- Transition( ActionPointer s_action=shared::make_shared< Ignore >(), State *s_next_state=NULL )
+ Transition( ActionPointer s_action = std::make_shared<Ignore>(), State *s_next_state=NULL )
: action( s_action ), next_state( s_next_state )
{}
// This is only ever used in the 1-argument form;
// we use this instead of an initializer to
// tell Coverity the object never owns *action.
- Transition( State *s_next_state, ActionPointer s_action=shared::make_shared< Ignore >() )
+ Transition( State *s_next_state, ActionPointer s_action = std::make_shared<Ignore>() )
: action( s_action ), next_state( s_next_state )
{}
};
diff --git a/src/terminal/terminaldisplay.cc b/src/terminal/terminaldisplay.cc
index 013c6f8..1cc8c59 100644
--- a/src/terminal/terminaldisplay.cc
+++ b/src/terminal/terminaldisplay.cc
@@ -160,7 +160,7 @@ std::string Display::new_frame( bool initialized, const Framebuffer &last, const
/* Extend rows if we've gotten a resize and new is wider than old */
if ( frame.last_frame.ds.get_width() < f.ds.get_width() ) {
for ( Framebuffer::rows_type::iterator p = rows.begin(); p != rows.end(); p++ ) {
- *p = make_shared<Row>( **p );
+ *p = std::make_shared<Row>( **p );
(*p)->cells.resize( f.ds.get_width(), Cell( f.ds.get_background_rendition() ) );
}
}
@@ -169,7 +169,7 @@ std::string Display::new_frame( bool initialized, const Framebuffer &last, const
// get a proper blank row
const size_t w = f.ds.get_width();
const color_type c = 0;
- blank_row = make_shared<Row>( w, c );
+ blank_row = std::make_shared<Row>( w, c );
rows.resize( f.ds.get_height(), blank_row );
}
@@ -215,7 +215,7 @@ std::string Display::new_frame( bool initialized, const Framebuffer &last, const
if ( blank_row.get() == NULL ) {
const size_t w = f.ds.get_width();
const color_type c = 0;
- blank_row = make_shared<Row>( w, c );
+ blank_row = std::make_shared<Row>( w, c );
}
frame.update_rendition( initial_rendition(), true );
diff --git a/src/terminal/terminalframebuffer.cc b/src/terminal/terminalframebuffer.cc
index 7a469a9..1abab39 100644
--- a/src/terminal/terminalframebuffer.cc
+++ b/src/terminal/terminalframebuffer.cc
@@ -84,7 +84,7 @@ Framebuffer::Framebuffer( int s_width, int s_height )
assert( s_width > 0 );
const size_t w = s_width;
const color_type c = 0;
- rows = rows_type(s_height, row_pointer(make_shared<Row>( w, c )));
+ rows = rows_type(s_height, row_pointer(std::make_shared<Row>( w, c )));
}
Framebuffer::Framebuffer( const Framebuffer &other )
@@ -417,7 +417,7 @@ void Framebuffer::resize( int s_width, int s_height )
for ( rows_type::iterator i = rows.begin();
i != rows.end() && *i != blankrow;
i++ ) {
- *i = make_shared<Row>( **i );
+ *i = std::make_shared<Row>( **i );
(*i)->set_wrap( false );
(*i)->cells.resize( s_width, Cell( ds.get_background_rendition() ) );
}
diff --git a/src/terminal/terminalframebuffer.h b/src/terminal/terminalframebuffer.h
index 430f5c1..cd94640 100644
--- a/src/terminal/terminalframebuffer.h
+++ b/src/terminal/terminalframebuffer.h
@@ -37,18 +37,15 @@
#include <limits.h>
#include <stdint.h>
-#include <vector>
#include <deque>
-#include <string>
#include <list>
-
-#include "src/util/shared.h"
+#include <memory>
+#include <string>
+#include <vector>
/* Terminal framebuffer */
namespace Terminal {
- using shared::shared_ptr;
- using shared::make_shared;
typedef uint32_t color_type;
class Renditions {
@@ -372,7 +369,7 @@ namespace Terminal {
// * If no row is shared, the frame has not been modified.
public:
typedef std::vector<wchar_t> title_type;
- typedef shared_ptr<Row> row_pointer;
+ typedef std::shared_ptr<Row> row_pointer;
typedef std::vector<row_pointer> rows_type; /* can be either std::vector or std::deque */
private:
@@ -387,7 +384,7 @@ namespace Terminal {
{
const size_t w = ds.get_width();
const color_type c = ds.get_background_rendition();
- return make_shared<Row>( w, c );
+ return std::make_shared<Row>( w, c );
}
public:
@@ -422,7 +419,7 @@ namespace Terminal {
row_pointer &mutable_row = rows.at( row );
// If the row is shared, copy it.
if (!mutable_row.unique()) {
- mutable_row = make_shared<Row>( *mutable_row );
+ mutable_row = std::make_shared<Row>( *mutable_row );
}
return mutable_row.get();
}
diff --git a/src/tests/ocb-aes.cc b/src/tests/ocb-aes.cc
index 943a704..8eefb8d 100644
--- a/src/tests/ocb-aes.cc
+++ b/src/tests/ocb-aes.cc
@@ -40,13 +40,13 @@
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
+#include <memory>
#include "src/crypto/ae.h"
#include "src/crypto/crypto.h"
#include "src/crypto/prng.h"
#include "src/util/fatal_assert.h"
#include "test_utils.h"
-#include "src/util/shared.h"
#define KEY_LEN 16
#define NONCE_LEN 12
@@ -61,7 +61,7 @@ static bool equal( const AlignedBuffer &a, const AlignedBuffer &b ) {
&& !memcmp( a.data(), b.data(), a.len() );
}
-typedef shared::shared_ptr< AlignedBuffer > AlignedPointer;
+using AlignedPointer = std::shared_ptr<AlignedBuffer>;
static AlignedBuffer *get_ctx( const AlignedBuffer &key ) {
AlignedBuffer *ctx_buf = new AlignedBuffer( ae_ctx_sizeof() );
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index 7cd7a50..408d5b7 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -2,4 +2,4 @@ AM_CXXFLAGS = -I$(top_srcdir)/ $(WARNING_CXXFLAGS) $(PICKY_CXXFLAGS) $(HARDEN_CF
noinst_LIBRARIES = libmoshutil.a
-libmoshutil_a_SOURCES = locale_utils.cc locale_utils.h swrite.cc swrite.h dos_assert.h fatal_assert.h select.h select.cc timestamp.h timestamp.cc pty_compat.cc pty_compat.h shared.h
+libmoshutil_a_SOURCES = locale_utils.cc locale_utils.h swrite.cc swrite.h dos_assert.h fatal_assert.h select.h select.cc timestamp.h timestamp.cc pty_compat.cc pty_compat.h
diff --git a/src/util/shared.h b/src/util/shared.h
deleted file mode 100644
index 4b97a58..0000000
--- a/src/util/shared.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- Mosh: the mobile shell
- Copyright 2012 Keith Winstein
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-
- In addition, as a special exception, the copyright holders give
- permission to link the code of portions of this program with the
- OpenSSL library under certain conditions as described in each
- individual source file, and distribute linked combinations including
- the two.
-
- You must obey the GNU General Public License in all respects for all
- of the code used other than OpenSSL. If you modify file(s) with this
- exception, you may extend this exception to your version of the
- file(s), but you are not obligated to do so. If you do not wish to do
- so, delete this exception statement from your version. If you delete
- this exception statement from all source files in the program, then
- also delete it here.
-*/
-
-#ifndef SHARED_HPP
-#define SHARED_HPP
-
-#include "src/include/config.h"
-
-#ifdef HAVE_MEMORY
-#include <memory>
-#endif
-
-#ifdef HAVE_TR1_MEMORY
-#include <tr1/memory>
-#endif
-
-namespace shared {
-#ifdef HAVE_STD_SHARED_PTR
- using std::shared_ptr;
- using std::make_shared;
-#else
-#ifdef HAVE_STD_TR1_SHARED_PTR
- using std::tr1::shared_ptr;
-
- // make_shared emulation.
- template<typename Tp>
- inline shared_ptr<Tp>
- make_shared()
- {
- return shared_ptr<Tp>(new Tp());
- }
- template<typename Tp, typename A1>
- inline shared_ptr<Tp>
- make_shared(const A1& a1)
- {
- return shared_ptr<Tp>(new Tp(a1));
- }
- template<typename Tp, typename A1, typename A2>
- inline shared_ptr<Tp>
- make_shared(const A1& a1, const A2& a2)
- {
- return shared_ptr<Tp>(new Tp(a1, a2));
- }
- template<typename Tp, typename A1, typename A2, typename A3>
- inline shared_ptr<Tp>
- make_shared(const A1& a1, const A2& a2, const A3& a3)
- {
- return shared_ptr<Tp>(new Tp(a1, a2, a3));
- }
- template<typename Tp, typename A1, typename A2, typename A3, typename A4>
- inline shared_ptr<Tp>
- make_shared(const A1& a1, const A2& a2, const A3& a3, const A4& a4)
- {
- return shared_ptr<Tp>(new Tp(a1, a2, a3, a4));
- }
-#else
-#error Need a shared_ptr class. Try Boost::TR1.
-#endif
-#endif
-}
-#endif