Replace boost::optional with std::optional (#4877)

This commit is contained in:
pajlada
2023-10-08 18:50:48 +02:00
committed by GitHub
parent fe4d6121a2
commit fec45889a8
88 changed files with 428 additions and 383 deletions
+2 -2
View File
@@ -43,7 +43,7 @@ std::vector<FfzBadges::Badge> FfzBadges::getUserBadges(const UserId &id)
return badges;
}
boost::optional<FfzBadges::Badge> FfzBadges::getBadge(const int badgeID)
std::optional<FfzBadges::Badge> FfzBadges::getBadge(const int badgeID)
{
auto it = this->badges.find(badgeID);
if (it != this->badges.end())
@@ -51,7 +51,7 @@ boost::optional<FfzBadges::Badge> FfzBadges::getBadge(const int badgeID)
return it->second;
}
return boost::none;
return std::nullopt;
}
void FfzBadges::load()
+2 -2
View File
@@ -4,10 +4,10 @@
#include "common/Singleton.hpp"
#include "util/QStringHash.hpp"
#include <boost/optional.hpp>
#include <QColor>
#include <memory>
#include <optional>
#include <set>
#include <shared_mutex>
#include <unordered_map>
@@ -32,7 +32,7 @@ public:
std::vector<Badge> getUserBadges(const UserId &id);
private:
boost::optional<Badge> getBadge(int badgeID);
std::optional<Badge> getBadge(int badgeID);
void load();
+7 -7
View File
@@ -119,10 +119,10 @@ namespace {
return emotes;
}
boost::optional<EmotePtr> parseAuthorityBadge(const QJsonObject &badgeUrls,
const QString &tooltip)
std::optional<EmotePtr> parseAuthorityBadge(const QJsonObject &badgeUrls,
const QString &tooltip)
{
boost::optional<EmotePtr> authorityBadge;
std::optional<EmotePtr> authorityBadge;
if (!badgeUrls.isEmpty())
{
@@ -173,7 +173,7 @@ std::shared_ptr<const EmoteMap> FfzEmotes::emotes() const
return this->global_.get();
}
boost::optional<EmotePtr> FfzEmotes::emote(const EmoteName &name) const
std::optional<EmotePtr> FfzEmotes::emote(const EmoteName &name) const
{
auto emotes = this->global_.get();
auto it = emotes->find(name);
@@ -181,7 +181,7 @@ boost::optional<EmotePtr> FfzEmotes::emote(const EmoteName &name) const
{
return it->second;
}
return boost::none;
return std::nullopt;
}
void FfzEmotes::loadEmotes()
@@ -214,8 +214,8 @@ void FfzEmotes::setEmotes(std::shared_ptr<const EmoteMap> emotes)
void FfzEmotes::loadChannel(
std::weak_ptr<Channel> channel, const QString &channelID,
std::function<void(EmoteMap &&)> emoteCallback,
std::function<void(boost::optional<EmotePtr>)> modBadgeCallback,
std::function<void(boost::optional<EmotePtr>)> vipBadgeCallback,
std::function<void(std::optional<EmotePtr>)> modBadgeCallback,
std::function<void(std::optional<EmotePtr>)> vipBadgeCallback,
bool manualRefresh)
{
qCDebug(chatterinoFfzemotes)
+4 -5
View File
@@ -3,9 +3,8 @@
#include "common/Aliases.hpp"
#include "common/Atomic.hpp"
#include <boost/optional.hpp>
#include <memory>
#include <optional>
namespace chatterino {
@@ -20,14 +19,14 @@ public:
FfzEmotes();
std::shared_ptr<const EmoteMap> emotes() const;
boost::optional<EmotePtr> emote(const EmoteName &name) const;
std::optional<EmotePtr> emote(const EmoteName &name) const;
void loadEmotes();
void setEmotes(std::shared_ptr<const EmoteMap> emotes);
static void loadChannel(
std::weak_ptr<Channel> channel, const QString &channelId,
std::function<void(EmoteMap &&)> emoteCallback,
std::function<void(boost::optional<EmotePtr>)> modBadgeCallback,
std::function<void(boost::optional<EmotePtr>)> vipBadgeCallback,
std::function<void(std::optional<EmotePtr>)> modBadgeCallback,
std::function<void(std::optional<EmotePtr>)> vipBadgeCallback,
bool manualRefresh);
private: