From a2552a555669490dc2ca173a48989d1b30e62c56 Mon Sep 17 00:00:00 2001
From: Alexander Gavriliuk <alexandrgproductengine@lindenlab.com>
Date: Thu, 8 Feb 2024 21:03:59 +0100
Subject: [PATCH] Build fix for Visual Studio patch

---
 indra/llcommon/llbase64.cpp            | 4 ++--
 indra/llcommon/llrand.cpp              | 2 +-
 indra/llcommon/llsd.h                  | 4 ++--
 indra/llcommon/llsdserialize.cpp       | 2 +-
 indra/llcommon/llsdserialize_xml.cpp   | 4 ++--
 indra/llcommon/llsys.cpp               | 2 +-
 indra/llcommon/lltrace.cpp             | 2 +-
 indra/llcommon/lltraceaccumulators.cpp | 2 +-
 indra/llcorehttp/bufferarray.cpp       | 2 +-
 indra/newview/llmaterialeditor.cpp     | 8 ++++----
 10 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/indra/llcommon/llbase64.cpp b/indra/llcommon/llbase64.cpp
index bb85fe32a3c..433b54f6f82 100644
--- a/indra/llcommon/llbase64.cpp
+++ b/indra/llcommon/llbase64.cpp
@@ -42,7 +42,7 @@ std::string LLBase64::encode(const U8* input, size_t input_size)
 		&& input_size > 0)
 	{
 		// Yes, it returns int.
-		int b64_buffer_length = apr_base64_encode_len(narrow(input_size));
+		int b64_buffer_length = apr_base64_encode_len(narrow<size_t>(input_size));
 		char* b64_buffer = new char[b64_buffer_length];
 		
 		// This is faster than apr_base64_encode() if you know
@@ -52,7 +52,7 @@ std::string LLBase64::encode(const U8* input, size_t input_size)
 		b64_buffer_length = apr_base64_encode_binary(
 			b64_buffer,
 			input,
-			narrow(input_size));
+			narrow<size_t>(input_size));
 		output.assign(b64_buffer);
 		delete[] b64_buffer;
 	}
diff --git a/indra/llcommon/llrand.cpp b/indra/llcommon/llrand.cpp
index e4065e23bf1..01921115742 100644
--- a/indra/llcommon/llrand.cpp
+++ b/indra/llcommon/llrand.cpp
@@ -85,7 +85,7 @@ inline F32 ll_internal_random<F32>()
 	// Per Monty, it's important to clamp using the correct fmodf() rather
 	// than expanding to F64 for fmod() and then truncating back to F32. Prior
 	// to this change, we were getting sporadic ll_frand() == 1.0 results.
-	F32 rv{ narrow(gRandomGenerator()) };
+	F32 rv{ narrow<F32>(gRandomGenerator()) };
 	if(!((rv >= 0.0f) && (rv < 1.0f))) return fmodf(rv, 1.0f);
 	return rv;
 }
diff --git a/indra/llcommon/llsd.h b/indra/llcommon/llsd.h
index cdb9a7ed8aa..8ed254919ca 100644
--- a/indra/llcommon/llsd.h
+++ b/indra/llcommon/llsd.h
@@ -197,12 +197,12 @@ class LL_COMMON_API LLSD
 				  typename std::enable_if<std::is_integral<VALUE>::value &&
 										  ! std::is_same<VALUE, Boolean>::value,
 										  bool>::type = true>
-		LLSD(VALUE v): LLSD(Integer(narrow(v))) {}
+		LLSD(VALUE v): LLSD(Integer(narrow<VALUE>(v))) {}
 		// support construction from F32 et al.
 		template <typename VALUE,
 				  typename std::enable_if<std::is_floating_point<VALUE>::value,
 										  bool>::type = true>
-		LLSD(VALUE v): LLSD(Real(narrow(v))) {}
+		LLSD(VALUE v): LLSD(Real(narrow<VALUE>(v))) {}
 	//@}
 	
 	/** @name Scalar Assignment */
diff --git a/indra/llcommon/llsdserialize.cpp b/indra/llcommon/llsdserialize.cpp
index a475be62934..76171f2dfd2 100644
--- a/indra/llcommon/llsdserialize.cpp
+++ b/indra/llcommon/llsdserialize.cpp
@@ -2174,7 +2174,7 @@ std::string zip_llsd(LLSD& data)
 
 	U8 out[CHUNK];
 
-	strm.avail_in = narrow(source.size());
+	strm.avail_in = narrow<size_t>(source.size());
 	strm.next_in = (U8*) source.data();
 	U8* output = NULL;
 
diff --git a/indra/llcommon/llsdserialize_xml.cpp b/indra/llcommon/llsdserialize_xml.cpp
index 38b11eb32b3..15119835965 100644
--- a/indra/llcommon/llsdserialize_xml.cpp
+++ b/indra/llcommon/llsdserialize_xml.cpp
@@ -196,12 +196,12 @@ S32 LLSDXMLFormatter::format_impl(const LLSD& data, std::ostream& ostr,
 			// *FIX: memory inefficient.
 			// *TODO: convert to use LLBase64
 			ostr << pre << "<binary encoding=\"base64\">";
-			int b64_buffer_length = apr_base64_encode_len(narrow(buffer.size()));
+			int b64_buffer_length = apr_base64_encode_len(narrow<size_t>(buffer.size()));
 			char* b64_buffer = new char[b64_buffer_length];
 			b64_buffer_length = apr_base64_encode_binary(
 				b64_buffer,
 				&buffer[0],
-				narrow(buffer.size()));
+				narrow<size_t>(buffer.size()));
 			ostr.write(b64_buffer, b64_buffer_length - 1);
 			delete[] b64_buffer;
 			ostr << "</binary>" << post;
diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index 938685bae6d..2bf12fb0eb1 100644
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -917,7 +917,7 @@ void LLMemoryInfo::stream(std::ostream& s) const
 	// Now stream stats
 	BOOST_FOREACH(const MapEntry& pair, inMap(mStatsMap))
 	{
-		s << pfx << std::setw(narrow(key_width+1)) << (pair.first + ':') << ' ';
+		s << pfx << std::setw(narrow<size_t>(key_width+1)) << (pair.first + ':') << ' ';
 		LLSD value(pair.second);
 		if (value.isInteger())
 			s << std::setw(12) << value.asInteger();
diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp
index bce186054f0..87457ad9077 100644
--- a/indra/llcommon/lltrace.cpp
+++ b/indra/llcommon/lltrace.cpp
@@ -63,7 +63,7 @@ void TimeBlockTreeNode::setParent( BlockTimerStatHandle* parent )
 	llassert_always(parent != mBlock);
 	llassert_always(parent != NULL);
 
-	TimeBlockTreeNode* parent_tree_node = get_thread_recorder()->getTimeBlockTreeNode(narrow(parent->getIndex()));
+	TimeBlockTreeNode* parent_tree_node = get_thread_recorder()->getTimeBlockTreeNode(narrow<size_t>(parent->getIndex()));
 	if (!parent_tree_node) return;
 
 	if (mParent)
diff --git a/indra/llcommon/lltraceaccumulators.cpp b/indra/llcommon/lltraceaccumulators.cpp
index 5fafb53832a..b5b32cba38f 100644
--- a/indra/llcommon/lltraceaccumulators.cpp
+++ b/indra/llcommon/lltraceaccumulators.cpp
@@ -77,7 +77,7 @@ void AccumulatorBufferGroup::makeCurrent()
 	// update stacktimer parent pointers
 	for (size_t i = 0, end_i = mStackTimers.size(); i < end_i; i++)
 	{
-		TimeBlockTreeNode* tree_node = thread_recorder->getTimeBlockTreeNode(narrow(i));
+		TimeBlockTreeNode* tree_node = thread_recorder->getTimeBlockTreeNode(narrow<size_t>(i));
 		if (tree_node)
 		{
 			timer_accumulator_buffer[i].mParent = tree_node->mParent;
diff --git a/indra/llcorehttp/bufferarray.cpp b/indra/llcorehttp/bufferarray.cpp
index 8d2e7c6a63b..c780c06b4e0 100644
--- a/indra/llcorehttp/bufferarray.cpp
+++ b/indra/llcorehttp/bufferarray.cpp
@@ -288,7 +288,7 @@ int BufferArray::findBlock(size_t pos, size_t * ret_offset)
 	if (pos >= mLen)
 		return -1;		// Doesn't exist
 
-	const int block_limit(narrow(mBlocks.size()));
+	const int block_limit(narrow<size_t>(mBlocks.size()));
 	for (int i(0); i < block_limit; ++i)
 	{
 		if (pos < mBlocks[i]->mUsed)
diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp
index 292ddb765f0..1f5974c74dd 100644
--- a/indra/newview/llmaterialeditor.cpp
+++ b/indra/newview/llmaterialeditor.cpp
@@ -2228,7 +2228,7 @@ bool LLMaterialEditor::canModifyObjectsMaterial()
     LLSelectedTEGetMatData func(true);
     LLPermissions permissions;
     LLViewerInventoryItem* item_out;
-    return can_use_objects_material(func, std::vector({PERM_MODIFY}), ItemSource::OBJECT, permissions, item_out);
+    return can_use_objects_material(func, std::vector<PermissionBit>({PERM_MODIFY}), ItemSource::OBJECT, permissions, item_out);
 }
 
 bool LLMaterialEditor::canSaveObjectsMaterial()
@@ -2236,7 +2236,7 @@ bool LLMaterialEditor::canSaveObjectsMaterial()
     LLSelectedTEGetMatData func(true);
     LLPermissions permissions;
     LLViewerInventoryItem* item_out;
-    return can_use_objects_material(func, std::vector({PERM_COPY, PERM_MODIFY}), ItemSource::AGENT, permissions, item_out);
+    return can_use_objects_material(func, std::vector<PermissionBit>({PERM_COPY, PERM_MODIFY}), ItemSource::AGENT, permissions, item_out);
 }
 
 bool LLMaterialEditor::canClipboardObjectsMaterial()
@@ -2262,7 +2262,7 @@ bool LLMaterialEditor::canClipboardObjectsMaterial()
     LLSelectedTEGetMatData func(true);
     LLPermissions permissions;
     LLViewerInventoryItem* item_out;
-    return can_use_objects_material(func, std::vector({PERM_COPY, PERM_MODIFY, PERM_TRANSFER}), ItemSource::OBJECT, permissions, item_out);
+    return can_use_objects_material(func, std::vector<PermissionBit>({PERM_COPY, PERM_MODIFY, PERM_TRANSFER}), ItemSource::OBJECT, permissions, item_out);
 }
 
 void LLMaterialEditor::saveObjectsMaterialAs()
@@ -2270,7 +2270,7 @@ void LLMaterialEditor::saveObjectsMaterialAs()
     LLSelectedTEGetMatData func(true);
     LLPermissions permissions;
     LLViewerInventoryItem* item = nullptr;
-    bool allowed = can_use_objects_material(func, std::vector({PERM_COPY, PERM_MODIFY}), ItemSource::AGENT, permissions, item);
+    bool allowed = can_use_objects_material(func, std::vector<PermissionBit>({PERM_COPY, PERM_MODIFY}), ItemSource::AGENT, permissions, item);
     if (!allowed)
     {
         LL_WARNS("MaterialEditor") << "Failed to save GLTF material from object" << LL_ENDL;
-- 
GitLab