From 3b1e4bbb3df6a0de8aa0693038449c6f0359ce91 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Tue, 23 Jan 2024 10:13:00 +0900 Subject: Replace auto_ptr Signed-off-by: Michele Calgaro (cherry picked from commit d2f343cc239e1fa25c9581cf35bada96692c41db) --- indexlib/create.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'indexlib/create.cpp') diff --git a/indexlib/create.cpp b/indexlib/create.cpp index e47d116a..c64e2158 100644 --- a/indexlib/create.cpp +++ b/indexlib/create.cpp @@ -56,41 +56,41 @@ indexlib::index_type::type type_of( const char* basename ) { } } -std::auto_ptr indexlib::create( const char* basename, indexlib::index_type::type flags ) { +std::unique_ptr indexlib::create( const char* basename, indexlib::index_type::type flags ) { using namespace indexlib::version; - if ( type_of( basename ) != indexlib::index_type::none ) return std::auto_ptr( 0 ); + if ( type_of( basename ) != indexlib::index_type::none ) return std::unique_ptr(); try { if ( basename[ strlen( basename ) - 1 ] == '/' && !isdir( basename ) ) { - if ( !indexlib::detail::mkdir_trailing( basename ) ) return std::auto_ptr( 0 ); + if ( !indexlib::detail::mkdir_trailing( basename ) ) return std::unique_ptr(); } std::ofstream info( path_concat( basename, "info" ).c_str() ); info << marker << std::endl; info << "version " << major << '.' << minor << "\n"; if ( flags == index_type::quotes ) { info << "quotes" << std::endl; - return std::auto_ptr( new quotes( basename ) ); + return std::unique_ptr( new quotes( basename ) ); } if ( flags == index_type::ifile ) { info << "ifile" << std::endl; - return std::auto_ptr( new ifile( basename ) ); + return std::unique_ptr( new ifile( basename ) ); } } catch ( const std::exception& e ) { std::cerr << "index creation failed: " << e.what() << std::endl; } - return std::auto_ptr( 0 ); + return std::unique_ptr(); } -std::auto_ptr indexlib::open( const char* basename, unsigned flags ) { +std::unique_ptr indexlib::open( const char* basename, unsigned flags ) { using namespace indexlib; switch ( type_of( basename ) ) { - case index_type::ifile: return std::auto_ptr( new ifile( basename ) ); - case index_type::quotes: return std::auto_ptr( new quotes( basename ) ); + case index_type::ifile: return std::unique_ptr( new ifile( basename ) ); + case index_type::quotes: return std::unique_ptr( new quotes( basename ) ); case index_type::none: - if ( flags == open_flags::fail_if_nonexistant ) return std::auto_ptr(); + if ( flags == open_flags::fail_if_nonexistant ) return std::unique_ptr(); return create( basename, index_type::type( flags ) ); } logfile() << format( "%s:%s: Unexpected code reached!\n" ) % __FILE__ % __LINE__; - return std::auto_ptr( 0 ); + return std::unique_ptr(); } bool indexlib::exists( const char* basename ) { -- cgit v1.2.3