From 592abc460c96b63b1b1e0d15914f7b64a0c88038 Mon Sep 17 00:00:00 2001
From: Nat Goodspeed <nat@lindenlab.com>
Date: Fri, 26 Aug 2022 22:49:16 -0400
Subject: [PATCH] DRTVWR-568: More cleanup of deleted obsolete std library
 features.

---
 indra/cmake/00-Common.cmake           | 15 ++---
 indra/llcommon/llsd.h                 | 12 ++--
 indra/llcommon/llstl.h                | 81 +++++++++++++--------------
 indra/llcommon/tests/llleap_test.cpp  |  2 +-
 indra/llmessage/llioutil.h            |  2 +-
 indra/llmessage/llmessagethrottle.cpp | 23 --------
 indra/newview/llgesturemgr.cpp        |  4 +-
 7 files changed, 56 insertions(+), 83 deletions(-)

diff --git a/indra/cmake/00-Common.cmake b/indra/cmake/00-Common.cmake
index 572422d080e..16367f1d919 100644
--- a/indra/cmake/00-Common.cmake
+++ b/indra/cmake/00-Common.cmake
@@ -46,6 +46,13 @@ endif()
 set(CMAKE_CONFIGURATION_TYPES "RelWithDebInfo;Release" CACHE STRING
     "Supported build types." FORCE)
 
+# The viewer code base can now be successfully compiled with -std=c++14. But
+# turning that on in the generic viewer-build-variables/variables file would
+# potentially require tweaking each of our ~50 third-party library builds.
+# Until we decide to set -std=c++14 in viewer-build-variables/variables, set
+# it locally here: we want to at least prevent inadvertently reintroducing
+# viewer code that would fail with C++14.
+set(CMAKE_CXX_STANDARD 17)
 
 # Platform-specific compilation flags.
 
@@ -173,13 +180,7 @@ if (DARWIN)
   # see Variables.cmake.
   string(REPLACE "-gdwarf-2" "-g${CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT}"
     CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
-  # The viewer code base can now be successfully compiled with -std=c++14. But
-  # turning that on in the generic viewer-build-variables/variables file would
-  # potentially require tweaking each of our ~50 third-party library builds.
-  # Until we decide to set -std=c++14 in viewer-build-variables/variables, set
-  # it locally here: we want to at least prevent inadvertently reintroducing
-  # viewer code that would fail with C++14.
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DARWIN_extra_cstar_flags} -std=c++14")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DARWIN_extra_cstar_flags}")
   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}  ${DARWIN_extra_cstar_flags}")
   # NOTE: it's critical that the optimization flag is put in front.
   # NOTE: it's critical to have both CXX_FLAGS and C_FLAGS covered.
diff --git a/indra/llcommon/llsd.h b/indra/llcommon/llsd.h
index 24cb9bbce17..3daaef44fc8 100644
--- a/indra/llcommon/llsd.h
+++ b/indra/llcommon/llsd.h
@@ -421,42 +421,42 @@ class LL_COMMON_API LLSD
 	static std::string		typeString(Type type);		// Return human-readable type as a string
 };
 
-struct llsd_select_bool : public std::unary_function<LLSD, LLSD::Boolean>
+struct llsd_select_bool
 {
 	LLSD::Boolean operator()(const LLSD& sd) const
 	{
 		return sd.asBoolean();
 	}
 };
-struct llsd_select_integer : public std::unary_function<LLSD, LLSD::Integer>
+struct llsd_select_integer
 {
 	LLSD::Integer operator()(const LLSD& sd) const
 	{
 		return sd.asInteger();
 	}
 };
-struct llsd_select_real : public std::unary_function<LLSD, LLSD::Real>
+struct llsd_select_real
 {
 	LLSD::Real operator()(const LLSD& sd) const
 	{
 		return sd.asReal();
 	}
 };
-struct llsd_select_float : public std::unary_function<LLSD, F32>
+struct llsd_select_float
 {
 	F32 operator()(const LLSD& sd) const
 	{
 		return (F32)sd.asReal();
 	}
 };
-struct llsd_select_uuid : public std::unary_function<LLSD, LLSD::UUID>
+struct llsd_select_uuid
 {
 	LLSD::UUID operator()(const LLSD& sd) const
 	{
 		return sd.asUUID();
 	}
 };
-struct llsd_select_string : public std::unary_function<LLSD, LLSD::String>
+struct llsd_select_string
 {
 	LLSD::String operator()(const LLSD& sd) const
 	{
diff --git a/indra/llcommon/llstl.h b/indra/llcommon/llstl.h
index a90c2c7e087..25131291f91 100644
--- a/indra/llcommon/llstl.h
+++ b/indra/llcommon/llstl.h
@@ -142,7 +142,7 @@ struct DeletePairedPointerArray
 //                     llselect2nd<map_type::value_type>()));
 
 template<typename T>
-struct DeletePointerFunctor : public std::unary_function<T*, bool>
+struct DeletePointerFunctor
 {
 	bool operator()(T* ptr) const
 	{
@@ -153,7 +153,7 @@ struct DeletePointerFunctor : public std::unary_function<T*, bool>
 
 // See notes about DeleteArray for why you should consider avoiding this.
 template<typename T>
-struct DeleteArrayFunctor : public std::unary_function<T*, bool>
+struct DeleteArrayFunctor
 {
 	bool operator()(T* ptr) const
 	{
@@ -395,16 +395,17 @@ OutputIter ll_transform_n(
 // select... with the stl. Look up usage on the sgi website.
 
 template <class _Pair>
-struct _LLSelect1st : public std::unary_function<_Pair, typename _Pair::first_type> {
-  const typename _Pair::first_type& operator()(const _Pair& __x) const {
+struct _LLSelect1st
+{
+  const auto& operator()(const _Pair& __x) const {
     return __x.first;
   }
 };
 
 template <class _Pair>
-struct _LLSelect2nd : public std::unary_function<_Pair, typename _Pair::second_type>
+struct _LLSelect2nd
 {
-  const typename _Pair::second_type& operator()(const _Pair& __x) const {
+  const auto& operator()(const _Pair& __x) const {
     return __x.second;
   }
 };
@@ -416,9 +417,7 @@ template <class _Pair> struct llselect2nd : public _LLSelect2nd<_Pair> {};
 // compose... with the stl. Look up usage on the sgi website.
 
 template <class _Operation1, class _Operation2>
-class ll_unary_compose :
-	public std::unary_function<typename _Operation2::argument_type,
-							   typename _Operation1::result_type>
+class ll_unary_compose
 {
 protected:
   _Operation1 __op1;
@@ -426,8 +425,9 @@ class ll_unary_compose :
 public:
   ll_unary_compose(const _Operation1& __x, const _Operation2& __y)
     : __op1(__x), __op2(__y) {}
-  typename _Operation1::result_type
-  operator()(const typename _Operation2::argument_type& __x) const {
+  template <typename _Op2Arg>
+  auto
+  operator()(const _Op2Arg& __x) const {
     return __op1(__op2(__x));
   }
 };
@@ -441,8 +441,7 @@ llcompose1(const _Operation1& __op1, const _Operation2& __op2)
 
 template <class _Operation1, class _Operation2, class _Operation3>
 class ll_binary_compose
-  : public std::unary_function<typename _Operation2::argument_type,
-							   typename _Operation1::result_type> {
+{
 protected:
   _Operation1 _M_op1;
   _Operation2 _M_op2;
@@ -451,8 +450,9 @@ class ll_binary_compose
   ll_binary_compose(const _Operation1& __x, const _Operation2& __y,
 					const _Operation3& __z)
     : _M_op1(__x), _M_op2(__y), _M_op3(__z) { }
-  typename _Operation1::result_type
-  operator()(const typename _Operation2::argument_type& __x) const {
+  template<typename OP2ARG>
+  auto
+  operator()(const OP2ARG& __x) const {
     return _M_op1(_M_op2(__x), _M_op3(__x));
   }
 };
@@ -468,54 +468,51 @@ llcompose2(const _Operation1& __op1, const _Operation2& __op2,
 
 // helpers to deal with the fact that MSDev does not package
 // bind... with the stl. Again, this is from sgi.
-template <class _Operation>
-class llbinder1st :
-	public std::unary_function<typename _Operation::second_argument_type,
-							   typename _Operation::result_type> {
+template <class _Operation, typename _Arg1>
+class llbinder1st
+{
 protected:
   _Operation op;
-  typename _Operation::first_argument_type value;
+  _Arg1 value;
 public:
-  llbinder1st(const _Operation& __x,
-			  const typename _Operation::first_argument_type& __y)
+  llbinder1st(const _Operation& __x, const _Arg1& __y)
       : op(__x), value(__y) {}
-	typename _Operation::result_type
-	operator()(const typename _Operation::second_argument_type& __x) const {
-		return op(value, __x);
-	}
+    template <typename _Arg2>
+    auto
+    operator()(const _Arg2& __x) const {
+        return op(value, __x);
+    }
 };
 
 template <class _Operation, class _Tp>
-inline llbinder1st<_Operation>
+inline auto
 llbind1st(const _Operation& __oper, const _Tp& __x)
 {
-  typedef typename _Operation::first_argument_type _Arg1_type;
-  return llbinder1st<_Operation>(__oper, _Arg1_type(__x));
+  return llbinder1st<_Operation, _Tp>(__oper, __x);
 }
 
-template <class _Operation>
+template <class _Operation, typename _Arg2>
 class llbinder2nd
-	: public std::unary_function<typename _Operation::first_argument_type,
-								 typename _Operation::result_type> {
+{
 protected:
 	_Operation op;
-	typename _Operation::second_argument_type value;
+	_Arg2 value;
 public:
 	llbinder2nd(const _Operation& __x,
-				const typename _Operation::second_argument_type& __y)
+				const _Arg2& __y)
 		: op(__x), value(__y) {}
-	typename _Operation::result_type
-	operator()(const typename _Operation::first_argument_type& __x) const {
+	template <typename _Arg1>
+	auto
+	operator()(const _Arg1& __x) const {
 		return op(__x, value);
 	}
 };
 
 template <class _Operation, class _Tp>
-inline llbinder2nd<_Operation>
+inline auto
 llbind2nd(const _Operation& __oper, const _Tp& __x)
 {
-  typedef typename _Operation::second_argument_type _Arg2_type;
-  return llbinder2nd<_Operation>(__oper, _Arg2_type(__x));
+  return llbinder2nd<_Operation, _Tp>(__oper, __x);
 }
 
 /**
@@ -548,8 +545,7 @@ bool before(const std::type_info* lhs, const std::type_info* rhs)
 namespace std
 {
 	template <>
-	struct less<const std::type_info*>:
-		public std::binary_function<const std::type_info*, const std::type_info*, bool>
+	struct less<const std::type_info*>
 	{
 		bool operator()(const std::type_info* lhs, const std::type_info* rhs) const
 		{
@@ -558,8 +554,7 @@ namespace std
 	};
 
 	template <>
-	struct less<std::type_info*>:
-		public std::binary_function<std::type_info*, std::type_info*, bool>
+	struct less<std::type_info*>
 	{
 		bool operator()(std::type_info* lhs, std::type_info* rhs) const
 		{
diff --git a/indra/llcommon/tests/llleap_test.cpp b/indra/llcommon/tests/llleap_test.cpp
index daa84df792c..7ee36a9ea6a 100644
--- a/indra/llcommon/tests/llleap_test.cpp
+++ b/indra/llcommon/tests/llleap_test.cpp
@@ -525,7 +525,7 @@ namespace tut
         result.ensure();
     }
 
-    struct TestLargeMessage: public std::binary_function<size_t, size_t, bool>
+    struct TestLargeMessage
     {
         TestLargeMessage(const std::string& PYTHON_, const std::string& reader_module_,
                          const std::string& test_name_):
diff --git a/indra/llmessage/llioutil.h b/indra/llmessage/llioutil.h
index e8d245f530b..c404a98bed3 100644
--- a/indra/llmessage/llioutil.h
+++ b/indra/llmessage/llioutil.h
@@ -147,7 +147,7 @@ class LLIOAddChain : public LLIOPipe
  * }
  * </code>
  */
-class LLChangeChannel //: public unary_function<T, void>
+class LLChangeChannel
 {
 public:
 	/** 
diff --git a/indra/llmessage/llmessagethrottle.cpp b/indra/llmessage/llmessagethrottle.cpp
index 579d6d71878..14582aaf320 100644
--- a/indra/llmessage/llmessagethrottle.cpp
+++ b/indra/llmessage/llmessagethrottle.cpp
@@ -32,18 +32,8 @@
 #include "llframetimer.h"
 
 // This is used for the stl search_n function.
-#if _MSC_VER >= 1500 // VC9 has a bug in search_n
-struct eq_message_throttle_entry : public std::binary_function< LLMessageThrottleEntry, LLMessageThrottleEntry, bool >
-{
-	bool operator()(const LLMessageThrottleEntry& a, const LLMessageThrottleEntry& b) const
-	{
-		return a.getHash() == b.getHash();
-	}
-};
-#else
 bool eq_message_throttle_entry(LLMessageThrottleEntry a, LLMessageThrottleEntry b)
  		{ return a.getHash() == b.getHash(); }
-#endif
 
 const U64 SEC_TO_USEC = 1000000;
 		
@@ -118,14 +108,8 @@ BOOL LLMessageThrottle::addViewerAlert(const LLUUID& to, const std::string& mesg
 	LLMessageThrottleEntry entry(hash, LLFrameTimer::getTotalTime());
 
 	// Check if this message is already in the list.
-#if _MSC_VER >= 1500 // VC9 has a bug in search_n
-	// SJB: This *should* work but has not been tested yet *TODO: Test!
-	message_list_iterator_t found = std::find_if(message_list->begin(), message_list->end(),
-												 std::bind2nd(eq_message_throttle_entry(), entry));
-#else
  	message_list_iterator_t found = std::search_n(message_list->begin(), message_list->end(),
  												  1, entry, eq_message_throttle_entry);
-#endif
 	if (found == message_list->end())
 	{
 		// This message was not found.  Add it to the list.
@@ -152,15 +136,8 @@ BOOL LLMessageThrottle::addAgentAlert(const LLUUID& agent, const LLUUID& task, c
 	LLMessageThrottleEntry entry(hash, LLFrameTimer::getTotalTime());
 
 	// Check if this message is already in the list.
-#if _MSC_VER >= 1500 // VC9 has a bug in search_n
-	// SJB: This *should* work but has not been tested yet *TODO: Test!
-	message_list_iterator_t found = std::find_if(message_list->begin(), message_list->end(),
-												 std::bind2nd(eq_message_throttle_entry(), entry));
-#else
 	message_list_iterator_t found = std::search_n(message_list->begin(), message_list->end(),
 												  1, entry, eq_message_throttle_entry);
-#endif
-	
 	if (found == message_list->end())
 	{
 		// This message was not found.  Add it to the list.
diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp
index 489d34edca4..c0f773968d1 100644
--- a/indra/newview/llgesturemgr.cpp
+++ b/indra/newview/llgesturemgr.cpp
@@ -757,11 +757,11 @@ S32 LLGestureMgr::getPlayingCount() const
 }
 
 
-struct IsGesturePlaying : public std::unary_function<LLMultiGesture*, bool>
+struct IsGesturePlaying
 {
 	bool operator()(const LLMultiGesture* gesture) const
 	{
-		return gesture->mPlaying ? true : false;
+		return bool(gesture->mPlaying);
 	}
 };
 
-- 
GitLab