Use reset instead of assignment when updating auto_ptr/unique_ptr

This commit is contained in:
Phil Nash 2014-10-02 18:47:07 +01:00
parent b1936d3b0e
commit 4b3fa4742b

View File

@ -620,7 +620,7 @@ namespace Clara {
m_throwOnUnrecognisedTokens( other.m_throwOnUnrecognisedTokens ) m_throwOnUnrecognisedTokens( other.m_throwOnUnrecognisedTokens )
{ {
if( other.m_floatingArg.get() ) if( other.m_floatingArg.get() )
m_floatingArg = ArgAutoPtr( new Arg( *other.m_floatingArg ) ); m_floatingArg.reset( new Arg( *other.m_floatingArg ) );
} }
CommandLine& setThrowOnUnrecognisedTokens( bool shouldThrow = true ) { CommandLine& setThrowOnUnrecognisedTokens( bool shouldThrow = true ) {
@ -649,7 +649,7 @@ namespace Clara {
ArgBuilder operator[]( UnpositionalTag ) { ArgBuilder operator[]( UnpositionalTag ) {
if( m_floatingArg.get() ) if( m_floatingArg.get() )
throw std::logic_error( "Only one unpositional argument can be added" ); throw std::logic_error( "Only one unpositional argument can be added" );
m_floatingArg = ArgAutoPtr( new Arg() ); m_floatingArg.reset( new Arg() );
ArgBuilder builder( m_floatingArg.get() ); ArgBuilder builder( m_floatingArg.get() );
return builder; return builder;
} }