Skip to content

Commit

Permalink
Replace std::unary_function<> with std::function<>
Browse files Browse the repository at this point in the history
(deprecated in C++11) and removed in C++17

Add missing #include <memory>

Make the hack clear:
    respect review comment
    ace/Auto_Ptr.h must still include <memory>
  • Loading branch information
ClausKlein committed Aug 22, 2023
1 parent 694a7f3 commit b192a37
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 11 deletions.
11 changes: 9 additions & 2 deletions ACE/ace/Auto_Ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@ class ACE_Auto_Basic_Ptr

ACE_END_VERSIONED_NAMESPACE_DECL

// NOTE: ACE7 and TAO3 require C++11 support or newer; jwillemsen commented on Jun 1, 2021
#if !defined (ACE_LACKS_AUTO_PTR)
#include <memory>
using std::auto_ptr;
# include <memory>

# ifdef ACE_HAS_CPP17
// NOTE: we must only use std::unique_ptr; CK
# else
// FIXME: we are still using std::auto_ptr;
# endif

#else /* !ACE_LACKS_AUTO_PTR */

ACE_BEGIN_VERSIONED_NAMESPACE_DECL
Expand Down
2 changes: 1 addition & 1 deletion ACE/tests/Reactor_Remove_Resume_Test_Dev_Poll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ dev_poll_reactor_factory ()
*
* Reactor test execution functor.
*/
struct Run_Test : public std::unary_function<reactor_factory_type, void>
struct Run_Test : public std::function<void(reactor_factory_type)>
{
/// Function call operator overload.
void operator() (reactor_factory_type factory)
Expand Down
2 changes: 2 additions & 0 deletions TAO/orbsvcs/orbsvcs/Event/ECG_CDR_Message_Receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "ace/ACE.h"
#include "ace/OS_NS_string.h"

#include <memory>

#if !defined(__ACE_INLINE__)
#include "orbsvcs/Event/ECG_CDR_Message_Receiver.inl"
#endif /* __ACE_INLINE__ */
Expand Down
7 changes: 4 additions & 3 deletions TAO/orbsvcs/orbsvcs/Notify/Refcountable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <map>
#include <string>
#include <memory>
#include <typeinfo.h>

TAO_BEGIN_VERSIONED_NAMESPACE_DECL
Expand Down Expand Up @@ -44,8 +45,8 @@ class TAO_Notify_Tracker
TAO_Notify_Tracker();
~TAO_Notify_Tracker();

friend class std::auto_ptr< TAO_Notify_Tracker >;
static std::auto_ptr< TAO_Notify_Tracker > s_instance;
friend class std::unique_ptr< TAO_Notify_Tracker >;
static std::unique_ptr< TAO_Notify_Tracker > s_instance;
mutable TAO_SYNCH_MUTEX lock_;
typedef std::map<int, Entry> EntityMap;
EntityMap map_;
Expand Down Expand Up @@ -133,7 +134,7 @@ TAO_Notify_Refcountable::_decr_refcnt ()

#if (TAO_NOTIFY_REFCOUNT_DIAGNOSTICS != 0)

std::auto_ptr< TAO_Notify_Tracker > TAO_Notify_Tracker::s_instance;
std::unique_ptr< TAO_Notify_Tracker > TAO_Notify_Tracker::s_instance;

TAO_Notify_Tracker::TAO_Notify_Tracker()
: id_counter_(0)
Expand Down
2 changes: 1 addition & 1 deletion TAO/tests/Any/Recursive/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ directly_recursive_valuetype_typecodefactory_test (CORBA::ORB_ptr /* orb */,
* Test method invocation functor.
*/
template <typename T>
struct Caller : public std::unary_function<T, void>
struct Caller : public std::function<void(T)>
{
/// Constructor.
Caller (CORBA::ORB_ptr o, Test::Hello_ptr h)
Expand Down
2 changes: 1 addition & 1 deletion TAO/tests/Bug_2804_Regression/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ recursive_union_test (CORBA::ORB_ptr /* orb */,
* Test method invocation functor.
*/
template <typename T>
struct Caller : public std::unary_function<T, void>
struct Caller : public std::function<void(T)>
{
/// Constructor.
Caller (CORBA::ORB_ptr o, Test::Hello_ptr h)
Expand Down
2 changes: 1 addition & 1 deletion TAO/tests/Bug_2844_Regression/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ nested_recursive_struct_test (CORBA::ORB_ptr /* orb */,
* Test method invocation functor.
*/
template <typename T>
struct Caller : public std::unary_function<T, void>
struct Caller : public std::function<void(T)>
{
/// Constructor.
Caller (CORBA::ORB_ptr o, Test::Hello_ptr h)
Expand Down
2 changes: 1 addition & 1 deletion TAO/tests/Bug_2918_Regression/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ repeated_struct_test (CORBA::ORB_ptr /* orb */,
* Test method invocation functor.
*/
template <typename T>
struct Caller : public std::unary_function<T, void>
struct Caller : public std::function<void(T)>
{
/// Constructor.
Caller (CORBA::ORB_ptr o, Test::Hello_ptr h)
Expand Down
2 changes: 1 addition & 1 deletion TAO/tests/Bug_3919_Regression/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ nested_recursive_typecode_test (CORBA::ORB_ptr /* orb */,
* Test method invocation functor.
*/
template <typename T>
struct Caller : public std::unary_function<T, void>
struct Caller : public std::function<void(T)>
{
/// Constructor.
Caller (CORBA::ORB_ptr o, Test::Hello_ptr h)
Expand Down

0 comments on commit b192a37

Please sign in to comment.