From a5e064b13ed72fc3e2bc7d15bb57d1c1569c04e2 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Wed, 27 Apr 2022 12:49:05 -0400
Subject: [PATCH] Start replacing boost::shared_ptr with std for better
 debugging

---
 indra/llcommon/lldoubledispatch.h      | 17 +++++++----------
 indra/llcommon/llerror.cpp             | 14 +++++++-------
 indra/llcommon/llerrorcontrol.h        |  4 ++--
 indra/llcommon/llprocess.h             |  2 +-
 indra/llcommon/llrun.h                 |  3 +--
 indra/llplugin/llpluginclassmedia.h    |  2 +-
 indra/llplugin/llpluginprocessparent.h |  5 ++---
 indra/newview/llviewermenufile.h       |  2 +-
 indra/test/test.cpp                    |  4 ++--
 9 files changed, 24 insertions(+), 29 deletions(-)

diff --git a/indra/llcommon/lldoubledispatch.h b/indra/llcommon/lldoubledispatch.h
index 6860d59e720..1d15618ae5e 100644
--- a/indra/llcommon/lldoubledispatch.h
+++ b/indra/llcommon/lldoubledispatch.h
@@ -30,10 +30,7 @@
 #define LL_LLDOUBLEDISPATCH_H
 
 #include <list>
-#include <boost/shared_ptr.hpp>
-#include <boost/function.hpp>
-#include <boost/bind.hpp>
-#include <boost/ref.hpp>
+#include <memory>
 
 /**
  * This class supports function calls which are virtual on the dynamic type of
@@ -157,9 +154,9 @@ class LLDoubleDispatch
         insert(t1, t2, func);
         if (symmetrical)
         {
-            // Use boost::bind() to construct a param-swapping thunk. Don't
+            // Use std::bind() to construct a param-swapping thunk. Don't
             // forget to reverse the parameters too.
-            insert(t2, t1, boost::bind(func, _2, _1));
+            insert(t2, t1, std::bind(func, std::placeholders::_2, std::placeholders::_1));
         }
     }
 
@@ -194,7 +191,7 @@ class LLDoubleDispatch
         insert(Type<Type1>(), Type<Type2>(), func, insertion);
         if (symmetrical)
         {
-            insert(Type<Type2>(), Type<Type1>(), boost::bind(func, _2, _1), insertion);
+            insert(Type<Type2>(), Type<Type1>(), std::bind(func, _2, _1), insertion);
         }
     }
 
@@ -255,7 +252,7 @@ class LLDoubleDispatch
     };
 
     /// shared_ptr manages Entry lifespan for us
-    typedef boost::shared_ptr<EntryBase> EntryPtr;
+    typedef std::shared_ptr<EntryBase> EntryPtr;
     /// use a @c list to make it easy to insert
     typedef std::list<EntryPtr> DispatchTable;
     DispatchTable mDispatch;
@@ -272,8 +269,8 @@ class LLDoubleDispatch
     typename DispatchTable::iterator find(const ParamBaseType& param1, const ParamBaseType& param2)
     {
         return std::find_if(mDispatch.begin(), mDispatch.end(),
-                            boost::bind(&EntryBase::matches, _1,
-                                        boost::ref(param1), boost::ref(param2)));
+                            std::bind(&EntryBase::matches, std::placeholders::_1,
+                                        std::ref(param1), std::ref(param2)));
     }
 
     /// Look up the first matching entry.
diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp
index 8d262cfdf6b..72ff14f0253 100644
--- a/indra/llcommon/llerror.cpp
+++ b/indra/llcommon/llerror.cpp
@@ -771,7 +771,7 @@ namespace
 		}
 
 #if LL_WINDOWS
-		LLError::RecorderPtr recordToWinDebug = boost::make_shared<RecordToWinDebug>();
+		LLError::RecorderPtr recordToWinDebug = std::make_shared<RecordToWinDebug>();
 		LLError::addRecorder(std::move(recordToWinDebug));
 #endif
 
@@ -1081,7 +1081,7 @@ namespace LLError
     //
     // NOTE!!! Requires external mutex lock!!!
     template <typename RECORDER>
-    std::pair<boost::shared_ptr<RECORDER>, Recorders::iterator>
+    std::pair<std::shared_ptr<RECORDER>, Recorders::iterator>
     findRecorderPos(SettingsConfigPtr &s)
     {
         // Since we promise to return an iterator, use a classic iterator
@@ -1092,7 +1092,7 @@ namespace LLError
             // *it is a RecorderPtr, a shared_ptr<Recorder>. Use a
             // dynamic_pointer_cast to try to downcast to test if it's also a
             // shared_ptr<RECORDER>.
-            auto ptr = boost::dynamic_pointer_cast<RECORDER>(*it);
+            auto ptr = std::dynamic_pointer_cast<RECORDER>(*it);
             if (ptr)
             {
                 // found the entry we want
@@ -1112,7 +1112,7 @@ namespace LLError
     // shared_ptr might be empty (operator!() returns true) if there was no
     // such RECORDER subclass instance in mRecorders.
     template <typename RECORDER>
-    boost::shared_ptr<RECORDER> findRecorder()
+    std::shared_ptr<RECORDER> findRecorder()
     {
         SettingsConfigPtr s = Globals::getInstance()->getSettingsConfig();
         LLMutexLock lock(&s->mRecorderMutex);
@@ -1145,7 +1145,7 @@ namespace LLError
 
 		if (!file_name.empty())
 		{
-			boost::shared_ptr<RecordToFile> recordToFile = boost::make_shared<RecordToFile>(file_name);
+			auto recordToFile = std::make_shared<RecordToFile>(file_name);
 			if (recordToFile->okay())
 			{
 				addRecorder(std::move(recordToFile));
@@ -1163,7 +1163,7 @@ namespace LLError
     {
         if (! findRecorder<RecordToStderr>())
         {
-			RecorderPtr recordToStdErr = boost::make_shared<RecordToStderr>(stderrLogWantsTime());
+			RecorderPtr recordToStdErr = std::make_shared<RecordToStderr>(stderrLogWantsTime());
             addRecorder(std::move(recordToStdErr));
         }
     }
@@ -1175,7 +1175,7 @@ namespace LLError
 
 		if (fixedBuffer)
 		{
-			RecorderPtr recordToFixedBuffer = boost::make_shared<RecordToFixedBuffer>(fixedBuffer);
+			RecorderPtr recordToFixedBuffer = std::make_shared<RecordToFixedBuffer>(fixedBuffer);
 			addRecorder(std::move(recordToFixedBuffer));
 		}
 	}
diff --git a/indra/llcommon/llerrorcontrol.h b/indra/llcommon/llerrorcontrol.h
index b7f1c248496..1d59eecc991 100644
--- a/indra/llcommon/llerrorcontrol.h
+++ b/indra/llcommon/llerrorcontrol.h
@@ -174,7 +174,7 @@ namespace LLError
 		bool mWantsMultiline;
 	};
 
-	typedef boost::shared_ptr<Recorder> RecorderPtr;
+	typedef std::shared_ptr<Recorder> RecorderPtr;
 
     /**
      * Instantiate GenericRecorder with a callable(level, message) to get
@@ -197,7 +197,7 @@ namespace LLError
     };
 
 	/**
-	 * @NOTE: addRecorder() and removeRecorder() uses the boost::shared_ptr to allow for shared ownership
+	 * @NOTE: addRecorder() and removeRecorder() uses the std::shared_ptr to allow for shared ownership
 	 * while still ensuring that the allocated memory is eventually freed
 	 */
 	LL_COMMON_API void addRecorder(RecorderPtr);
diff --git a/indra/llcommon/llprocess.h b/indra/llcommon/llprocess.h
index 0c3b4b02ea8..98021450e1c 100644
--- a/indra/llcommon/llprocess.h
+++ b/indra/llcommon/llprocess.h
@@ -49,7 +49,7 @@ class LLEventPump;
 class LLProcess;
 /// LLProcess instances are created on the heap by static factory methods and
 /// managed by ref-counted pointers.
-typedef boost::shared_ptr<LLProcess> LLProcessPtr;
+typedef std::shared_ptr<LLProcess> LLProcessPtr;
 
 /**
  * LLProcess handles launching an external process with specified command line
diff --git a/indra/llcommon/llrun.h b/indra/llcommon/llrun.h
index 88c1c8f3fbb..f74200a71ee 100644
--- a/indra/llcommon/llrun.h
+++ b/indra/llcommon/llrun.h
@@ -30,7 +30,6 @@
 #define LL_LLRUN_H
 
 #include <vector>
-#include <boost/shared_ptr.hpp>
 
 class LLRunnable;
 
@@ -48,7 +47,7 @@ class LL_COMMON_API LLRunner
 	/**
 	 * @brief The pointer to a runnable.
 	 */
-	typedef boost::shared_ptr<LLRunnable> run_ptr_t;
+	typedef std::shared_ptr<LLRunnable> run_ptr_t;
 
 	/**
 	 * @brief The handle for use in the API.
diff --git a/indra/llplugin/llpluginclassmedia.h b/indra/llplugin/llpluginclassmedia.h
index e4c2bab1e6e..8d392d17c7f 100644
--- a/indra/llplugin/llpluginclassmedia.h
+++ b/indra/llplugin/llpluginclassmedia.h
@@ -350,7 +350,7 @@ class LLPluginClassMedia final : public LLPluginProcessParentOwner
 	// "init_history" message 
 	void initializeUrlHistory(const LLSD& url_history);
 
-	boost::shared_ptr<LLPluginClassMedia> getSharedPrt() { return boost::dynamic_pointer_cast<LLPluginClassMedia>(shared_from_this()); } // due to enable_shared_from_this
+	std::shared_ptr<LLPluginClassMedia> getSharedPrt() { return std::dynamic_pointer_cast<LLPluginClassMedia>(shared_from_this()); } // due to enable_shared_from_this
 
 protected:
 
diff --git a/indra/llplugin/llpluginprocessparent.h b/indra/llplugin/llpluginprocessparent.h
index 2a32bdcdaa9..f7e675a676f 100644
--- a/indra/llplugin/llpluginprocessparent.h
+++ b/indra/llplugin/llpluginprocessparent.h
@@ -30,7 +30,6 @@
 #define LL_LLPLUGINPROCESSPARENT_H
 
 #include <queue>
-#include <boost/enable_shared_from_this.hpp>
 
 #include "llapr.h"
 #include "llprocess.h"
@@ -43,7 +42,7 @@
 #include "llsd.h"
 #include "llevents.h"
 
-class LLPluginProcessParentOwner : public boost::enable_shared_from_this < LLPluginProcessParentOwner > 
+class LLPluginProcessParentOwner : public std::enable_shared_from_this < LLPluginProcessParentOwner > 
 {
 public:
 	virtual ~LLPluginProcessParentOwner() = default;
@@ -60,7 +59,7 @@ class LLPluginProcessParent final : public LLPluginMessagePipeOwner
 
     LLPluginProcessParent(LLPluginProcessParentOwner *owner);
 public:
-    typedef boost::shared_ptr<LLPluginProcessParent> ptr_t;
+    typedef std::shared_ptr<LLPluginProcessParent> ptr_t;
 
 	~LLPluginProcessParent();
 		
diff --git a/indra/newview/llviewermenufile.h b/indra/newview/llviewermenufile.h
index 77c0c68b371..07dbd37e279 100644
--- a/indra/newview/llviewermenufile.h
+++ b/indra/newview/llviewermenufile.h
@@ -138,7 +138,7 @@ class LLMediaFilePicker : public LLFilePickerThread
     virtual void notify(const std::vector<std::string>& filenames);
 
 private:
-    boost::shared_ptr<LLPluginClassMedia> mPlugin;
+    std::shared_ptr<LLPluginClassMedia> mPlugin;
 };
 
 
diff --git a/indra/test/test.cpp b/indra/test/test.cpp
index f49bbd8b783..1025131579c 100644
--- a/indra/test/test.cpp
+++ b/indra/test/test.cpp
@@ -152,12 +152,12 @@ class LLReplayLogReal: public LLReplayLog, public boost::noncopyable
 
 	virtual void reset()
 	{
-		boost::dynamic_pointer_cast<RecordToTempFile>(mRecorder)->reset();
+		std::dynamic_pointer_cast<RecordToTempFile>(mRecorder)->reset();
 	}
 
 	virtual void replay(std::ostream& out)
 	{
-		boost::dynamic_pointer_cast<RecordToTempFile>(mRecorder)->replay(out);
+		std::dynamic_pointer_cast<RecordToTempFile>(mRecorder)->replay(out);
 	}
 
 private:
-- 
GitLab