-
-
Notifications
You must be signed in to change notification settings - Fork 458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace boost::optional with std::optional #4877
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
@@ -11,9 +11,9 @@ class UserDataController : public IUserDataController | |||
|
|||
// Get extra data about a user | |||
// If the user does not have any extra data, return none | |||
boost::optional<UserData> getUser(const QString &userID) const override | |||
std::optional<UserData> getUser(const QString &userID) const override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: parameter 'userID' is unused [misc-unused-parameters]
std::optional<UserData> getUser(const QString &userID) const override | |
std::optional<UserData> getUser(const QString & /*userID*/) const override |
@@ -127,7 +127,7 @@ int HotkeyController::replaceHotkey(QString oldName, | |||
return this->hotkeys_.append(newHotkey); | |||
} | |||
|
|||
boost::optional<HotkeyCategory> HotkeyController::hotkeyCategoryFromName( | |||
std::optional<HotkeyCategory> HotkeyController::hotkeyCategoryFromName( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'hotkeyCategoryFromName' can be made const [readability-make-member-function-const]
src/controllers/hotkeys/HotkeyController.hpp:53:
- std::optional<HotkeyCategory> hotkeyCategoryFromName(QString categoryName);
+ std::optional<HotkeyCategory> hotkeyCategoryFromName(QString categoryName) const;
src/controllers/hotkeys/HotkeyController.cpp:130:
- QString categoryName)
+ QString categoryName) const
@@ -67,8 +67,8 @@ void UserDataController::setUserColor(const QString &userID, | |||
{ | |||
auto c = this->getUsers(); | |||
auto it = c.find(userID); | |||
boost::optional<QColor> finalColor = | |||
boost::make_optional(!colorString.isEmpty(), QColor(colorString)); | |||
std::optional<QColor> finalColor = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'finalColor' of type 'std::optional' can be declared 'const' [misc-const-correctness]
std::optional<QColor> finalColor = | |
std::optional<QColor> const finalColor = |
@@ -727,14 +727,14 @@ void PubSub::registerNonce(QString nonce, NonceInfo info) | |||
this->nonces_[nonce] = std::move(info); | |||
} | |||
|
|||
boost::optional<PubSub::NonceInfo> PubSub::findNonceInfo(QString nonce) | |||
std::optional<PubSub::NonceInfo> PubSub::findNonceInfo(QString nonce) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: the parameter 'nonce' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
std::optional<PubSub::NonceInfo> PubSub::findNonceInfo(QString nonce) | |
std::optional<PubSub::NonceInfo> PubSub::findNonceInfo(const QString& nonce) |
src/providers/twitch/PubSubManager.hpp:190:
- std::optional<NonceInfo> findNonceInfo(QString nonce);
+ std::optional<NonceInfo> findNonceInfo(const QString& nonce);
@@ -955,13 +955,13 @@ void TwitchChannel::updateSeventvData(const QString &newUserID, | |||
return; | |||
} | |||
|
|||
boost::optional<QString> oldUserID = boost::make_optional( | |||
std::optional<QString> oldUserID = makeConditionedOptional( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'oldUserID' of type 'std::optional' can be declared 'const' [misc-const-correctness]
std::optional<QString> oldUserID = makeConditionedOptional( | |
std::optional<QString> const oldUserID = makeConditionedOptional( |
boost::make_optional(!this->seventvEmoteSetID_.isEmpty() && | ||
this->seventvEmoteSetID_ != newEmoteSetID, | ||
this->seventvEmoteSetID_); | ||
std::optional<QString> oldEmoteSetID = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'oldEmoteSetID' of type 'std::optional' can be declared 'const' [misc-const-correctness]
std::optional<QString> oldEmoteSetID = | |
std::optional<QString> const oldEmoteSetID = |
return Success; | ||
} | ||
|
||
return Failure; | ||
} | ||
|
||
boost::optional<EmotePtr> TwitchMessageBuilder::getTwitchBadge( | ||
const Badge &badge) | ||
std::optional<EmotePtr> TwitchMessageBuilder::getTwitchBadge(const Badge &badge) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'getTwitchBadge' can be made const [readability-make-member-function-const]
std::optional<EmotePtr> TwitchMessageBuilder::getTwitchBadge(const Badge &badge) | |
std::optional<EmotePtr> TwitchMessageBuilder::getTwitchBadge(const Badge &badge) const |
src/providers/twitch/TwitchMessageBuilder.hpp:110:
- std::optional<EmotePtr> getTwitchBadge(const Badge &badge);
+ std::optional<EmotePtr> getTwitchBadge(const Badge &badge) const;
src/widgets/helper/ChannelView.cpp
Outdated
@@ -308,15 +307,17 @@ void ChannelView::pause(PauseReason reason, boost::optional<uint> msecs) | |||
else | |||
{ | |||
/// If the new time point is newer then we override. | |||
if (it->second && it->second.get() < timePoint) | |||
if (it->second && it->second.value() < timePoint) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: unchecked access to optional value [bugprone-unchecked-optional-access]
if (it->second && it->second.value() < timePoint)
^
… image" This reverts commit 2e9a351.
This reverts commit fec4588.
Description
The commits are split up into two parts: