Skip to content

Commit

Permalink
Merge pull request DOCGroup#2109 from jwillemsen/jwi-autoptrcpp17_cle…
Browse files Browse the repository at this point in the history
…anup

C++17 removed std::auto_ptr, updated ACE/TAO to not use std::auto_ptr anymore
  • Loading branch information
jwillemsen authored Sep 4, 2023
2 parents 0853054 + eb0d6c1 commit 81db2de
Show file tree
Hide file tree
Showing 256 changed files with 477 additions and 537 deletions.
5 changes: 2 additions & 3 deletions ACE/ACEXML/common/HttpCharStream.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "ace/ACE.h"
#include "ace/ace_wchar.h"
#include "ace/Auto_Ptr.h"
#include "ace/OS_NS_stdio.h"
#include "ace/OS_NS_string.h"
#include "ace/Truncate.h"
Expand Down Expand Up @@ -272,7 +271,7 @@ int
ACEXML_HttpCharStream::send_request ()
{
char* path = ACE::strnew (ACE_TEXT_ALWAYS_CHAR (this->url_addr_->get_path_name()));
ACE_Auto_Basic_Array_Ptr<char> path_ptr (path);
std::unique_ptr<char[]> path_ptr (path);
size_t commandsize = ACE_OS::strlen (path)
+ ACE_OS::strlen (this->url_addr_->get_host_name ())
+ 20 // Extra
Expand All @@ -283,7 +282,7 @@ ACEXML_HttpCharStream::send_request ()
ACE_NEW_RETURN (command, char[commandsize], -1);

// Ensure that the <command> memory is deallocated.
ACE_Auto_Basic_Array_Ptr<char> cmd_ptr (command);
std::unique_ptr<char[]> cmd_ptr (command);

int bytes = ACE_OS::sprintf (command, "GET %s HTTP/1.0\r\n", path);
bytes += ACE_OS::sprintf (&command[bytes], "Host: %s\r\n",
Expand Down
4 changes: 2 additions & 2 deletions ACE/ACEXML/common/URL_Addr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#endif /* __ACEXML_INLINE__ */

#include "ace/Log_Msg.h"
#include "ace/Auto_Ptr.h"
#include "ace/OS_Memory.h"
#include "ace/OS_NS_stdio.h"
#include "ace/OS_NS_stdlib.h"
#include "ace/OS_NS_string.h"
#include <memory>

ACEXML_URL_Addr::ACEXML_URL_Addr ()
: path_name_ (0),
Expand Down Expand Up @@ -94,7 +94,7 @@ ACEXML_URL_Addr::string_to_addr (const ACEXML_Char* s,
ACE_NEW_RETURN (host_name, ACEXML_Char[host_len + 1], -1);
ACE_OS::strncpy (host_name, s + http_len, host_len);
host_name[host_len] = '\0';
ACE_Auto_Basic_Array_Ptr<ACEXML_Char> cleanup_host_name (host_name);
std::unique_ptr<ACEXML_Char[]> cleanup_host_name (host_name);

// Get the port number (if any)
unsigned short port = ACE_DEFAULT_HTTP_PORT;
Expand Down
6 changes: 3 additions & 3 deletions ACE/ACEXML/common/XML_Codecs.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// -*- C++ -*-

#include "ace/Auto_Ptr.h"
#include "ace/OS_Memory.h"
#include "ace/OS_NS_string.h"
#include "ACEXML/common/XML_Codecs.h"
#include <memory>

ACEXML_Char*
ACEXML_Base64::encode (const ACEXML_Char* input,
Expand All @@ -17,7 +17,7 @@ ACEXML_Base64::encode (const ACEXML_Char* input,
ACE_NEW_RETURN (buf,
ACE_Byte[len],
0);
ACE_Auto_Basic_Array_Ptr<ACE_Byte> cleanup_buf (buf);
std::unique_ptr<ACE_Byte[]> cleanup_buf (buf);

for (size_t i = 0; i < len; ++i)
buf[i] = (ACE_Byte)input[i];
Expand Down Expand Up @@ -59,7 +59,7 @@ ACEXML_Base64::decode (const ACEXML_Char* input,
ACE_Byte[len],
0);

ACE_Auto_Basic_Array_Ptr<ACE_Byte> cleanup (buf);
std::unique_ptr<ACE_Byte[]> cleanup (buf);

for (size_t i = 0; i < len; ++i)
buf[i] = (ACE_Byte)input[i];
Expand Down
1 change: 0 additions & 1 deletion ACE/ACEXML/examples/SAXPrint/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "Print_Handler.h"
#include "SAXPrint_Handler.h"
#include "ace/Get_Opt.h"
#include "ace/Auto_Ptr.h"
#include "ace/Log_Msg.h"
#include "ace/OS_main.h"

Expand Down
7 changes: 4 additions & 3 deletions ACE/ACEXML/parser/parser/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "ACEXML/parser/parser/ParserInternals.h"
#include "ace/OS_NS_string.h"
#include "ace/OS_NS_strings.h"
#include <memory>

static const ACEXML_Char default_attribute_type[] = ACE_TEXT ("CDATA");
static const ACEXML_Char empty_string[] = { 0 };
Expand Down Expand Up @@ -318,7 +319,7 @@ ACEXML_Parser::parse_external_dtd ()
if (this->validate_)
{
ACEXML_Char* uri = this->normalize_systemid (systemId);
ACE_Auto_Basic_Array_Ptr<ACEXML_Char> cleanup_uri (uri);
std::unique_ptr<ACEXML_Char[]> cleanup_uri (uri);
ACEXML_InputSource* ip = 0;
if (this->entity_resolver_)
{
Expand Down Expand Up @@ -2091,7 +2092,7 @@ ACEXML_Parser::parse_entity_reference ()
else
{
ACEXML_Char* uri = this->normalize_systemid (systemId);
ACE_Auto_Basic_Array_Ptr<ACEXML_Char> cleanup_uri (uri);
std::unique_ptr<ACEXML_Char[]> cleanup_uri (uri);
ACEXML_InputSource* ip = 0;
if (this->entity_resolver_)
{
Expand Down Expand Up @@ -2184,7 +2185,7 @@ ACEXML_Parser::parse_PE_reference ()
else if (this->external_entity_ && this->validate_)
{
ACEXML_Char* uri = this->normalize_systemid (systemId);
ACE_Auto_Basic_Array_Ptr<ACEXML_Char> cleanup_uri (uri);
std::unique_ptr<ACEXML_Char[]> cleanup_uri (uri);
ACEXML_InputSource* ip = 0;
if (this->entity_resolver_)
{
Expand Down
1 change: 0 additions & 1 deletion ACE/ACEXML/parser/parser/Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "ace/Hash_Map_Manager.h"
#include "ace/Unbounded_Set.h"
#include "ace/Containers_T.h"
#include "ace/Auto_Ptr.h"
#include "ACEXML/parser/parser/Entity_Manager.h"
#include "ACEXML/parser/parser/ParserInternals.h"
#include "ACEXML/parser/parser/ParserContext.h"
Expand Down
6 changes: 3 additions & 3 deletions ACE/Kokyu/Default_Dispatcher_Impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Default_Dispatcher_Impl::init_i (const Dispatcher_Attributes& attrs)
//ACE_DEBUG ((LM_DEBUG, "after new on task array\n" ));
tasks_.reset(tasks_array);

//ACE_DEBUG ((LM_DEBUG, "task array auto_ptr set\n" ));
//ACE_DEBUG ((LM_DEBUG, "task array unique_ptr set\n" ));

ConfigInfoSet& config_set =
const_cast<ConfigInfoSet&> (attrs.config_info_set_);
Expand All @@ -52,8 +52,8 @@ Default_Dispatcher_Impl::init_i (const Dispatcher_Attributes& attrs)
Dispatcher_Task (*config,
ACE_Thread_Manager::instance()),
-1);
std::unique_ptr<Dispatcher_Task> tmp_task_auto_ptr (task);
tasks_[i++] = std::move(tmp_task_auto_ptr);
std::unique_ptr<Dispatcher_Task> tmp_task_unique_ptr (task);
tasks_[i++] = std::move(tmp_task_unique_ptr);
}

this->thr_creation_flags_ = attrs.thread_creation_flags ();
Expand Down
2 changes: 1 addition & 1 deletion ACE/Kokyu/Default_Dispatcher_Impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace Kokyu

private:
typedef std::unique_ptr<Dispatcher_Task> Dispatcher_Task_Auto_Ptr;
ACE_Auto_Array_Ptr<Dispatcher_Task_Auto_Ptr> tasks_;
std::unique_ptr<Dispatcher_Task_Auto_Ptr[]> tasks_;
int ntasks_;
ConfigInfoSet curr_config_info_;
int activated_;
Expand Down
1 change: 0 additions & 1 deletion ACE/Kokyu/Kokyu_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include /**/ "ace/pre.h"
#include "ace/Containers_T.h"
#include "ace/Time_Value.h"
#include "ace/Auto_Ptr.h"
#include "ace/Message_Block.h"
#include "ace/Sched_Params.h"
#include "ace/Malloc_Allocator.h"
Expand Down
1 change: 0 additions & 1 deletion ACE/Kokyu/tests/DSRT_MIF/MIF.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "ace/ACE.h"
#include "ace/Auto_Ptr.h"
#include "ace/Task.h"
#include "ace/Sched_Params.h"
#include "ace/Atomic_Op.h"
Expand Down
6 changes: 6 additions & 0 deletions ACE/NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
USER VISIBLE CHANGES BETWEEN ACE-7.1.1 and ACE-7.1.2
====================================================

. C++17 removed std::auto_ptr, updated ACE/TAO to not
use std::auto_ptr anymore and also not provide our
own auto_ptr. With C++17 ACE doesn't provide ACE_Auto_Ptr,
ACE_Auto_Basic_Ptr, ACE_Auto_Basic_Array_Ptr, ACE_Auto_Array_Ptr,
and ACE_auto_ptr_reset anymore, just use std::unique_ptr

USER VISIBLE CHANGES BETWEEN ACE-7.1.0 and ACE-7.1.1
====================================================

Expand Down
1 change: 0 additions & 1 deletion ACE/ace/ACE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "ace/Basic_Types.h"
#include "ace/Handle_Set.h"
#include "ace/Auto_Ptr.h"
#include "ace/SString.h"
#include "ace/Version.h"
#include "ace/Message_Block.h"
Expand Down
5 changes: 2 additions & 3 deletions ACE/ace/Auto_Functor.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Auto_Functor
typedef Functor functor_type;

/// Constructor
explicit Auto_Functor (X * p = 0,
explicit Auto_Functor (X * p = nullptr,
Functor functor = Functor()); // noexcept

Auto_Functor (Auto_Functor & rhs); // noexcept
Expand All @@ -82,7 +82,7 @@ class Auto_Functor

X * release(); // noexcept

void reset (X * p = 0); // noexcept
void reset (X * p = nullptr); // noexcept

void reset (X * p, Functor f); // noexcept

Expand All @@ -98,7 +98,6 @@ class Auto_Functor

private:
X * p_;

Functor f_;
};
} // namespace ACE_Utils
Expand Down
4 changes: 4 additions & 0 deletions ACE/ace/Auto_Ptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "ace/Auto_Ptr.h"

#if !defined (ACE_HAS_CPP17)

#if defined (ACE_HAS_ALLOC_HOOKS)
# include "ace/Malloc_Base.h"
#endif /* ACE_HAS_ALLOC_HOOKS */
Expand All @@ -18,4 +20,6 @@ ACE_ALLOC_HOOK_DEFINE_Tt(ACE_Auto_Basic_Array_Ptr)

ACE_END_VERSIONED_NAMESPACE_DECL

#endif /* ACE_HAS_CPP17 */

#endif /* ACE_AUTO_PTR_CPP */
10 changes: 8 additions & 2 deletions ACE/ace/Auto_Ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

// C++17 removed std::auto_ptr<>, so also disable the ACE versions when
// using C++17.
#if !defined (ACE_HAS_CPP17)

#if defined (_MSC_VER)
// Suppress warning e.g. "return type for
// 'ACE_Auto_Array_Pointer<type>::operator ->' is 'type *' (i.e., not a UDT
Expand All @@ -44,7 +48,7 @@ class ACE_Auto_Basic_Ptr
public:
typedef X element_type;

explicit ACE_Auto_Basic_Ptr (X * p = 0) : p_ (p) {}
explicit ACE_Auto_Basic_Ptr (X * p = nullptr) : p_ (p) {}

ACE_Auto_Basic_Ptr (ACE_Auto_Basic_Ptr<X> & ap);
ACE_Auto_Basic_Ptr<X> &operator= (ACE_Auto_Basic_Ptr<X> & rhs);
Expand All @@ -54,7 +58,7 @@ class ACE_Auto_Basic_Ptr
X &operator *() const;
X *get () const;
X *release ();
void reset (X * p = 0);
void reset (X * p = nullptr);

/// Dump the state of an object.
void dump () const;
Expand Down Expand Up @@ -198,5 +202,7 @@ ACE_END_VERSIONED_NAMESPACE_DECL
# pragma warning(pop)
#endif /* _MSC_VER */

#endif /* ACE_HAS_CPP17 */

#include /**/ "ace/post.h"
#endif /* ACE_AUTO_PTR_H */
6 changes: 5 additions & 1 deletion ACE/ace/Auto_Ptr.inl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// -*- C++ -*-
#include "ace/Global_Macros.h"

#if !defined (ACE_HAS_CPP17)

#if defined (ACE_HAS_ALLOC_HOOKS)
# include "ace/Malloc_Base.h"
#endif /* ACE_HAS_ALLOC_HOOKS */
Expand Down Expand Up @@ -42,7 +44,7 @@ ACE_Auto_Basic_Ptr<X>::release ()
{
ACE_TRACE ("ACE_Auto_Basic_Ptr<X>::release");
X *old = this->p_;
this->p_ = 0;
this->p_ = nullptr;
return old;
}

Expand Down Expand Up @@ -175,3 +177,5 @@ ACE_Auto_Array_Ptr<X>::operator->() const
}

ACE_END_VERSIONED_NAMESPACE_DECL

#endif /* ACE_HAS_CPP17 */
10 changes: 5 additions & 5 deletions ACE/ace/CDR_Stream.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "ace/CDR_Stream.h"
#include "ace/SString.h"
#include "ace/Auto_Ptr.h"
#include "ace/Truncate.h"
#include <memory>

#if !defined (__ACE_INLINE__)
# include "ace/CDR_Stream.inl"
Expand Down Expand Up @@ -1530,7 +1530,7 @@ ACE_InputCDR::read_string (ACE_CDR::Char *&x)
0);
#endif /* ACE_HAS_ALLOC_HOOKS */

ACE_Auto_Basic_Array_Ptr<ACE_CDR::Char> safe_data (x);
std::unique_ptr<ACE_CDR::Char[]> safe_data (x);

if (this->read_char_array (x, len))
{
Expand Down Expand Up @@ -1563,10 +1563,10 @@ ACE_InputCDR::read_string (ACE_CDR::Char *&x)
ACE_CDR::Boolean
ACE_InputCDR::read_string (ACE_CString &x)
{
ACE_CDR::Char * data = 0;
ACE_CDR::Char * data = nullptr;
if (this->read_string (data))
{
ACE_Auto_Basic_Array_Ptr<ACE_CDR::Char> safe_data (data);
std::unique_ptr<ACE_CDR::Char[]> safe_data (data);
x = data;
return true;
}
Expand Down Expand Up @@ -1604,7 +1604,7 @@ ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x)
// the memory is allocated.
if (len > 0 && len <= this->length ())
{
ACE_Auto_Basic_Array_Ptr<ACE_CDR::WChar> safe_data;
std::unique_ptr<ACE_CDR::WChar[]> safe_data;

if (static_cast<ACE_CDR::Short> (this->major_version_) == 1
&& static_cast<ACE_CDR::Short> (this->minor_version_) == 2)
Expand Down
4 changes: 2 additions & 2 deletions ACE/ace/DLL_Manager.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "ace/DLL_Manager.h"

#include "ace/Auto_Ptr.h"
#include "ace/Log_Category.h"
#include "ace/ACE.h"
#include "ace/Framework_Component.h"
Expand All @@ -12,6 +11,7 @@
#include "ace/Guard_T.h"
#include "ace/OS_NS_dlfcn.h"
#include "ace/OS_NS_string.h"
#include <memory>

ACE_BEGIN_VERSIONED_NAMESPACE_DECL

Expand Down Expand Up @@ -243,7 +243,7 @@ ACE_DLL_Handle::symbol (const ACE_TCHAR *sym_name, bool ignore_errors, ACE_TStri
ACE_TRACE ("ACE_DLL_Handle::symbol");
ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0));

ACE_Auto_Array_Ptr <ACE_TCHAR> auto_name (ACE::ldname (sym_name));
std::unique_ptr <ACE_TCHAR[]> auto_name (ACE::ldname (sym_name));
// handle_ can be invalid especially when ACE_DLL_Handle resigned ownership
// BTW. Handle lifecycle management is a little crazy in ACE
if (this->handle_ != ACE_SHLIB_INVALID_HANDLE)
Expand Down
2 changes: 1 addition & 1 deletion ACE/ace/Log_Msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ class ACE_Export ACE_Log_Msg
/// passed "true" for the delete_ostream argument to msg_ostream).
/// If we are reference counting, this points to a shared count that will
/// be deleted when it reaches zero. Since we want optional but shared
/// ownership neither std::auto_ptr nor ACE_Strong_Bound_Ptr have the right
/// ownership neither std::unique_ptr nor ACE_Strong_Bound_Ptr have the right
/// semantics. *Bound_Ptr also doesn't take advantage of Atomic_Op.
typedef ACE_Atomic_Op<ACE_SYNCH_MUTEX, unsigned long> Atomic_ULong;
Atomic_ULong *ostream_refcount_;
Expand Down
1 change: 0 additions & 1 deletion ACE/ace/Pagefile_Memory_Pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#endif /* __ACE_INLINE__ */

#include "ace/Log_Category.h"
#include "ace/Auto_Ptr.h"
#include "ace/RW_Thread_Mutex.h"
#include "ace/OS_NS_sys_mman.h"
#include "ace/OS_NS_string.h"
Expand Down
1 change: 0 additions & 1 deletion ACE/ace/Proactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

// This only works on Win32 platforms and on Unix platforms with aio
// calls.
#include "ace/Auto_Ptr.h"
#include "ace/Proactor_Impl.h"
#include "ace/Object_Manager.h"
#include "ace/Task_T.h"
Expand Down
Loading

0 comments on commit 81db2de

Please sign in to comment.