From ce91caa820a85e58bcdf820de960d95a67f0c407 Mon Sep 17 00:00:00 2001
From: John Preston <johnprestonmail@gmail.com>
Date: Tue, 1 Sep 2020 23:56:25 +0400
Subject: [PATCH] Fix build on macOS.

---
 .../chat_helpers/stickers_list_widget.h       | 43 +++++++++++++------
 .../SourceFiles/core/core_cloud_password.cpp  |  6 +--
 Telegram/SourceFiles/data/data_cloud_file.cpp |  2 +-
 Telegram/SourceFiles/data/data_photo.cpp      |  2 +-
 .../SourceFiles/data/data_replies_list.cpp    |  4 +-
 Telegram/SourceFiles/data/data_shared_media.h |  4 +-
 .../export/output/export_output_html.cpp      |  2 +-
 .../media/streaming/media_streaming_file.cpp  |  2 +-
 .../media_streaming_loader_mtproto.cpp        |  2 +-
 .../media/view/media_view_overlay_widget.cpp  |  2 +-
 .../SourceFiles/ui/image/image_location.cpp   | 16 +++----
 Telegram/lib_base                             |  2 +-
 Telegram/lib_storage                          |  2 +-
 13 files changed, 52 insertions(+), 37 deletions(-)

diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h
index e77320894..b996f0214 100644
--- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h
+++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.h
@@ -121,29 +121,44 @@ private:
 		int section = 0;
 		int index = 0;
 		bool overDelete = false;
+
+		inline bool operator==(OverSticker other) const {
+			return (section == other.section)
+				&& (index == other.index)
+				&& (overDelete == other.overDelete);
+		}
+		inline bool operator!=(OverSticker other) const {
+			return !(*this == other);
+		}
 	};
 	struct OverSet {
 		int section = 0;
+
+		inline bool operator==(OverSet other) const {
+			return (section == other.section);
+		}
+		inline bool operator!=(OverSet other) const {
+			return !(*this == other);
+		}
 	};
 	struct OverButton {
 		int section = 0;
+
+		inline bool operator==(OverButton other) const {
+			return (section == other.section);
+		}
+		inline bool operator!=(OverButton other) const {
+			return !(*this == other);
+		}
 	};
 	struct OverGroupAdd {
+		inline bool operator==(OverGroupAdd other) const {
+			return true;
+		}
+		inline bool operator!=(OverGroupAdd other) const {
+			return !(*this == other);
+		}
 	};
-	friend inline bool operator==(OverSticker a, OverSticker b) {
-		return (a.section == b.section)
-			&& (a.index == b.index)
-			&& (a.overDelete == b.overDelete);
-	}
-	friend inline bool operator==(OverSet a, OverSet b) {
-		return (a.section == b.section);
-	}
-	friend inline bool operator==(OverButton a, OverButton b) {
-		return (a.section == b.section);
-	}
-	friend inline bool operator==(OverGroupAdd a, OverGroupAdd b) {
-		return true;
-	}
 	using OverState = std::variant<
 		v::null_t,
 		OverSticker,
diff --git a/Telegram/SourceFiles/core/core_cloud_password.cpp b/Telegram/SourceFiles/core/core_cloud_password.cpp
index e076ac646..576285f13 100644
--- a/Telegram/SourceFiles/core/core_cloud_password.cpp
+++ b/Telegram/SourceFiles/core/core_cloud_password.cpp
@@ -202,7 +202,7 @@ CloudPasswordAlgo ValidateNewCloudPasswordAlgo(CloudPasswordAlgo &&parsed) {
 	if (!v::is<CloudPasswordAlgoModPow>(parsed)) {
 		return v::null;
 	}
-	auto &value = std::get<CloudPasswordAlgoModPow>(parsed);
+	auto &value = v::get<CloudPasswordAlgoModPow>(parsed);
 	const auto already = value.salt1.size();
 	value.salt1.resize(already + kAdditionalSalt);
 	bytes::set_random(bytes::make_span(value.salt1).subspan(already));
@@ -273,7 +273,7 @@ SecureSecretAlgo ValidateNewSecureSecretAlgo(SecureSecretAlgo &&parsed) {
 	if (!v::is<SecureSecretAlgoPBKDF2>(parsed)) {
 		return v::null;
 	}
-	auto &value = std::get<SecureSecretAlgoPBKDF2>(parsed);
+	auto &value = v::get<SecureSecretAlgoPBKDF2>(parsed);
 	const auto already = value.salt.size();
 	value.salt.resize(already + kAdditionalSalt);
 	bytes::set_random(bytes::make_span(value.salt).subspan(already));
@@ -317,4 +317,4 @@ CloudPasswordState ParseCloudPasswordState(
 	return result;
 }
 
-} // namespace Core
\ No newline at end of file
+} // namespace Core
diff --git a/Telegram/SourceFiles/data/data_cloud_file.cpp b/Telegram/SourceFiles/data/data_cloud_file.cpp
index 63aba99fb..aa5bfa6c3 100644
--- a/Telegram/SourceFiles/data/data_cloud_file.cpp
+++ b/Telegram/SourceFiles/data/data_cloud_file.cpp
@@ -177,7 +177,7 @@ void UpdateCloudFile(
 	auto cacheBytes = !data.bytes.isEmpty()
 		? data.bytes
 		: v::is<InMemoryLocation>(file.location.file().data)
-		? std::get<InMemoryLocation>(file.location.file().data).bytes
+		? v::get<InMemoryLocation>(file.location.file().data).bytes
 		: QByteArray();
 	if (!cacheBytes.isEmpty()) {
 		if (const auto cacheKey = data.location.file().cacheKey()) {
diff --git a/Telegram/SourceFiles/data/data_photo.cpp b/Telegram/SourceFiles/data/data_photo.cpp
index cee9f857b..254417ed2 100644
--- a/Telegram/SourceFiles/data/data_photo.cpp
+++ b/Telegram/SourceFiles/data/data_photo.cpp
@@ -448,7 +448,7 @@ auto PhotoData::createStreamingLoader(
 	return v::is<StorageFileLocation>(videoLocation().file().data)
 		? std::make_unique<Media::Streaming::LoaderMtproto>(
 			&session().downloader(),
-			std::get<StorageFileLocation>(videoLocation().file().data),
+			v::get<StorageFileLocation>(videoLocation().file().data),
 			videoByteSize(),
 			origin)
 		: nullptr;
diff --git a/Telegram/SourceFiles/data/data_replies_list.cpp b/Telegram/SourceFiles/data/data_replies_list.cpp
index 5105d3295..62104e616 100644
--- a/Telegram/SourceFiles/data/data_replies_list.cpp
+++ b/Telegram/SourceFiles/data/data_replies_list.cpp
@@ -102,8 +102,8 @@ bool RepliesList::buildFromData(not_null<Viewer*> viewer) {
 	const auto i = around
 		? ranges::lower_bound(_list, around, std::greater<>())
 		: end(_list);
-	const auto availableBefore = (end(_list) - i);
-	const auto availableAfter = (i - begin(_list));
+	const auto availableBefore = int(end(_list) - i);
+	const auto availableAfter = int(i - begin(_list));
 	const auto useBefore = std::min(availableBefore, viewer->limitBefore + 1);
 	const auto useAfter = std::min(availableAfter, viewer->limitAfter);
 	const auto slice = &viewer->slice;
diff --git a/Telegram/SourceFiles/data/data_shared_media.h b/Telegram/SourceFiles/data/data_shared_media.h
index f98c31679..c73de5bb7 100644
--- a/Telegram/SourceFiles/data/data_shared_media.h
+++ b/Telegram/SourceFiles/data/data_shared_media.h
@@ -120,7 +120,7 @@ public:
 			key.peerId,
 			key.migratedPeerId,
 			v::is<MessageId>(key.universalId)
-				? std::get<MessageId>(key.universalId)
+				? v::get<MessageId>(key.universalId)
 				: ServerMaxMsgId - 1
 		};
 	}
@@ -165,7 +165,7 @@ private:
 				? ComputeId(key.peerId, *messageId)
 				: ComputeId(key.migratedPeerId, ServerMaxMsgId + *messageId);
 		}
-		return std::get<not_null<PhotoData*>>(key.universalId);
+		return v::get<not_null<PhotoData*>>(key.universalId);
 	}
 
 	bool isolatedInSlice() const {
diff --git a/Telegram/SourceFiles/export/output/export_output_html.cpp b/Telegram/SourceFiles/export/output/export_output_html.cpp
index e072619d7..ba9074d5a 100644
--- a/Telegram/SourceFiles/export/output/export_output_html.cpp
+++ b/Telegram/SourceFiles/export/output/export_output_html.cpp
@@ -1095,7 +1095,7 @@ auto HtmlWriter::Wrap::pushMessage(
 	if (!serviceText.isEmpty()) {
 		const auto &content = message.action.content;
 		const auto photo = v::is<ActionChatEditPhoto>(content)
-			? &std::get<ActionChatEditPhoto>(content).photo
+			? &v::get<ActionChatEditPhoto>(content).photo
 			: nullptr;
 		return { info, pushServiceMessage(
 			message.id,
diff --git a/Telegram/SourceFiles/media/streaming/media_streaming_file.cpp b/Telegram/SourceFiles/media/streaming/media_streaming_file.cpp
index 1549cefb0..8c5079832 100644
--- a/Telegram/SourceFiles/media/streaming/media_streaming_file.cpp
+++ b/Telegram/SourceFiles/media/streaming/media_streaming_file.cpp
@@ -326,7 +326,7 @@ void File::Context::readNextPacket() {
 	} else {
 		// Still trying to read by drain.
 		Assert(v::is<FFmpeg::AvErrorWrap>(result));
-		Assert(std::get<FFmpeg::AvErrorWrap>(result).code() == AVERROR_EOF);
+		Assert(v::get<FFmpeg::AvErrorWrap>(result).code() == AVERROR_EOF);
 		processQueuedPackets(SleepPolicy::Allowed);
 		if (!finished()) {
 			handleEndOfFile();
diff --git a/Telegram/SourceFiles/media/streaming/media_streaming_loader_mtproto.cpp b/Telegram/SourceFiles/media/streaming/media_streaming_loader_mtproto.cpp
index d7d0b38a1..f18f6a288 100644
--- a/Telegram/SourceFiles/media/streaming/media_streaming_loader_mtproto.cpp
+++ b/Telegram/SourceFiles/media/streaming/media_streaming_loader_mtproto.cpp
@@ -31,7 +31,7 @@ LoaderMtproto::LoaderMtproto(
 }
 
 Storage::Cache::Key LoaderMtproto::baseCacheKey() const {
-	return std::get<StorageFileLocation>(
+	return v::get<StorageFileLocation>(
 		location().data
 	).bigFileBaseCacheKey();
 }
diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp
index 9e922cee8..d5743d6a8 100644
--- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp
+++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp
@@ -1624,7 +1624,7 @@ Data::FileOrigin OverlayWidget::fileOrigin(const Entity &entity) const {
 	} else if (!v::is<not_null<PhotoData*>>(entity.data)) {
 		return Data::FileOrigin();
 	}
-	const auto photo = std::get<not_null<PhotoData*>>(entity.data);
+	const auto photo = v::get<not_null<PhotoData*>>(entity.data);
 	if (_user) {
 		return Data::FileOriginUserPhoto(_user->bareId(), photo->id);
 	} else if (_peer && _peer->userpicPhotoId() == photo->id) {
diff --git a/Telegram/SourceFiles/ui/image/image_location.cpp b/Telegram/SourceFiles/ui/image/image_location.cpp
index 5a872490f..dea8c72b5 100644
--- a/Telegram/SourceFiles/ui/image/image_location.cpp
+++ b/Telegram/SourceFiles/ui/image/image_location.cpp
@@ -682,7 +682,7 @@ std::optional<StorageImageLocation> StorageImageLocation::FromSerialized(
 
 QByteArray DownloadLocation::serialize() const {
 	if (!valid() || v::is<StorageFileLocation>(data)) {
-		return std::get<StorageFileLocation>(data).serialize();
+		return v::get<StorageFileLocation>(data).serialize();
 	}
 	auto result = QByteArray();
 	auto buffer = QBuffer(&result);
@@ -719,7 +719,7 @@ QByteArray DownloadLocation::serialize() const {
 
 int DownloadLocation::serializeSize() const {
 	if (!valid() || v::is<StorageFileLocation>(data)) {
-		return std::get<StorageFileLocation>(data).serializeSize();
+		return v::get<StorageFileLocation>(data).serializeSize();
 	}
 	auto result = sizeof(quint16) + sizeof(quint8) + sizeof(quint8);
 	v::match(data, [&](const StorageFileLocation &data) {
@@ -812,7 +812,7 @@ DownloadLocation DownloadLocation::convertToModern(
 	if (!v::is<StorageFileLocation>(data)) {
 		return *this;
 	}
-	auto &file = std::get<StorageFileLocation>(data);
+	auto &file = v::get<StorageFileLocation>(data);
 	return DownloadLocation{ file.convertToModern(type, id, accessHash) };
 }
 
@@ -838,7 +838,7 @@ Storage::Cache::Key DownloadLocation::cacheKey() const {
 
 Storage::Cache::Key DownloadLocation::bigFileBaseCacheKey() const {
 	return v::is<StorageFileLocation>(data)
-		? std::get<StorageFileLocation>(data).bigFileBaseCacheKey()
+		? v::get<StorageFileLocation>(data).bigFileBaseCacheKey()
 		: Storage::Cache::Key();
 }
 
@@ -858,7 +858,7 @@ bool DownloadLocation::valid() const {
 
 bool DownloadLocation::isLegacy() const {
 	return v::is<StorageFileLocation>(data)
-		? std::get<StorageFileLocation>(data).isLegacy()
+		? v::get<StorageFileLocation>(data).isLegacy()
 		: false;
 }
 
@@ -866,14 +866,14 @@ QByteArray DownloadLocation::fileReference() const {
 	if (!v::is<StorageFileLocation>(data)) {
 		return QByteArray();
 	}
-	return std::get<StorageFileLocation>(data).fileReference();
+	return v::get<StorageFileLocation>(data).fileReference();
 }
 
 bool DownloadLocation::refreshFileReference(const QByteArray &data) {
 	if (!v::is<StorageFileLocation>(this->data)) {
 		return false;
 	}
-	auto &file = std::get<StorageFileLocation>(this->data);
+	auto &file = v::get<StorageFileLocation>(this->data);
 	return file.refreshFileReference(data);
 }
 
@@ -882,7 +882,7 @@ bool DownloadLocation::refreshFileReference(
 	if (!v::is<StorageFileLocation>(data)) {
 		return false;
 	}
-	auto &file = std::get<StorageFileLocation>(data);
+	auto &file = v::get<StorageFileLocation>(data);
 	return file.refreshFileReference(updates);
 }
 
diff --git a/Telegram/lib_base b/Telegram/lib_base
index 172948039..8609bff8b 160000
--- a/Telegram/lib_base
+++ b/Telegram/lib_base
@@ -1 +1 @@
-Subproject commit 1729480399aa34241b1a5bdacfdf284e041072dd
+Subproject commit 8609bff8bd418be81f4ed52060576e5d06e4b9a4
diff --git a/Telegram/lib_storage b/Telegram/lib_storage
index 52b8d0456..cbd295476 160000
--- a/Telegram/lib_storage
+++ b/Telegram/lib_storage
@@ -1 +1 @@
-Subproject commit 52b8d0456fec25f80ca96e6d354dd7583f7fa350
+Subproject commit cbd295476b7910cc7fad7039e5da4a04edf33200