Replace boost::optional with std::optional (#4877)
This commit is contained in:
@@ -3,11 +3,10 @@
|
||||
#include "common/Aliases.hpp"
|
||||
#include "messages/ImageSet.hpp"
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace chatterino {
|
||||
@@ -24,7 +23,7 @@ struct Emote {
|
||||
* If this emote is aliased, this contains
|
||||
* the original (base) name of the emote.
|
||||
*/
|
||||
boost::optional<EmoteName> baseName;
|
||||
std::optional<EmoteName> baseName;
|
||||
|
||||
// FOURTF: no solution yet, to be refactored later
|
||||
const QString &getCopyString() const
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
#include "messages/LimitedQueueSnapshot.hpp"
|
||||
|
||||
#include <boost/circular_buffer.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <shared_mutex>
|
||||
#include <vector>
|
||||
|
||||
@@ -62,13 +62,13 @@ public:
|
||||
* @param[in] index the index of the item to fetch
|
||||
* @return the item at the index if it's populated, or none if it's not
|
||||
*/
|
||||
[[nodiscard]] boost::optional<T> get(size_t index) const
|
||||
[[nodiscard]] std::optional<T> get(size_t index) const
|
||||
{
|
||||
std::shared_lock lock(this->mutex_);
|
||||
|
||||
if (index >= this->buffer_.size())
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return this->buffer_[index];
|
||||
@@ -79,13 +79,13 @@ public:
|
||||
*
|
||||
* @return the item at the front of the queue if it's populated, or none the queue is empty
|
||||
*/
|
||||
[[nodiscard]] boost::optional<T> first() const
|
||||
[[nodiscard]] std::optional<T> first() const
|
||||
{
|
||||
std::shared_lock lock(this->mutex_);
|
||||
|
||||
if (this->buffer_.empty())
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return this->buffer_.front();
|
||||
@@ -96,13 +96,13 @@ public:
|
||||
*
|
||||
* @return the item at the back of the queue if it's populated, or none the queue is empty
|
||||
*/
|
||||
[[nodiscard]] boost::optional<T> last() const
|
||||
[[nodiscard]] std::optional<T> last() const
|
||||
{
|
||||
std::shared_lock lock(this->mutex_);
|
||||
|
||||
if (this->buffer_.empty())
|
||||
{
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
return this->buffer_.back();
|
||||
@@ -293,14 +293,14 @@ public:
|
||||
*
|
||||
* The contents of the LimitedQueue are iterated over from front to back
|
||||
* until the first element that satisfies `pred(item)`. If no item
|
||||
* satisfies the predicate, or if the queue is empty, then boost::none
|
||||
* satisfies the predicate, or if the queue is empty, then std::nullopt
|
||||
* is returned.
|
||||
*
|
||||
* @param[in] pred predicate that will be applied to items
|
||||
* @return the first item found or boost::none
|
||||
* @return the first item found or std::nullopt
|
||||
*/
|
||||
template <typename Predicate>
|
||||
[[nodiscard]] boost::optional<T> find(Predicate pred) const
|
||||
[[nodiscard]] std::optional<T> find(Predicate pred) const
|
||||
{
|
||||
std::shared_lock lock(this->mutex_);
|
||||
|
||||
@@ -312,7 +312,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,14 +320,14 @@ public:
|
||||
*
|
||||
* The contents of the LimitedQueue are iterated over from back to front
|
||||
* until the first element that satisfies `pred(item)`. If no item
|
||||
* satisfies the predicate, or if the queue is empty, then boost::none
|
||||
* satisfies the predicate, or if the queue is empty, then std::nullopt
|
||||
* is returned.
|
||||
*
|
||||
* @param[in] pred predicate that will be applied to items
|
||||
* @return the first item found or boost::none
|
||||
* @return the first item found or std::nullopt
|
||||
*/
|
||||
template <typename Predicate>
|
||||
[[nodiscard]] boost::optional<T> rfind(Predicate pred) const
|
||||
[[nodiscard]] std::optional<T> rfind(Predicate pred) const
|
||||
{
|
||||
std::shared_lock lock(this->mutex_);
|
||||
|
||||
@@ -339,7 +339,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -788,7 +788,7 @@ void TwitchModerationElement::addToContainer(MessageLayoutContainer &container,
|
||||
if (auto image = action.getImage())
|
||||
{
|
||||
container.addElement(
|
||||
(new ImageLayoutElement(*this, image.get(), size))
|
||||
(new ImageLayoutElement(*this, *image, size))
|
||||
->setLink(Link(Link::UserAction, action.getAction())));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -175,7 +175,7 @@ void SharedMessageBuilder::parseHighlights()
|
||||
|
||||
if (highlightResult.customSoundUrl)
|
||||
{
|
||||
this->highlightSoundUrl_ = highlightResult.customSoundUrl.get();
|
||||
this->highlightSoundUrl_ = *highlightResult.customSoundUrl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -277,4 +277,5 @@ QString SharedMessageBuilder::stylizeUsername(const QString &username,
|
||||
|
||||
return usernameText;
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
Reference in New Issue
Block a user