Skip to content
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

C++20 #4803

Merged
merged 12 commits into from
Jun 26, 2022
Merged

C++20 #4803

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ endif()

#######################################################################

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
if(MSVC)
# Ensure MSVC populates __cplusplus correctly.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus")
Expand Down
9 changes: 6 additions & 3 deletions lib/benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,12 @@ else()
add_cxx_compiler_flag(-Wall)
add_cxx_compiler_flag(-Wextra)
add_cxx_compiler_flag(-Wshadow)
add_cxx_compiler_flag(-Werror RELEASE)
add_cxx_compiler_flag(-Werror RELWITHDEBINFO)
add_cxx_compiler_flag(-Werror MINSIZEREL)
# Disable -Werror because of gcc bug
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ok to simply inline the patch here. It's only a workaround that should hopefully become obsolete in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand. So its fine as is or should I also commit a (imo redundant) patch file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how soon this will be fixed though. Neither google seems to make any effort working around this issue, nor the gcc team sees that as very urgent...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All fine. Hopefully, we don't need to update the lib anytime soon.

# https://github.com/google/benchmark/issues/1398
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105329
# add_cxx_compiler_flag(-Werror RELEASE)
# add_cxx_compiler_flag(-Werror RELWITHDEBINFO)
# add_cxx_compiler_flag(-Werror MINSIZEREL)
if (NOT BENCHMARK_ENABLE_TESTING)
# Disable warning when compiling tests as gtest does not use 'override'.
add_cxx_compiler_flag(-Wsuggest-override)
Expand Down
6 changes: 3 additions & 3 deletions src/controllers/dlgprefcontrollers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ DlgPrefControllers::DlgPrefControllers(DlgPreferences* pPreferences,
createLinkColor();
setupControllerWidgets();

connect(btnOpenUserMappings, &QPushButton::clicked, [=]() {
connect(btnOpenUserMappings, &QPushButton::clicked, [=, this]() {
QString mappingsPath = userMappingsPath(m_pConfig);
openLocalFile(mappingsPath);
});
Expand Down Expand Up @@ -132,8 +132,8 @@ void DlgPrefControllers::destroyControllerWidgets() {
// to keep this dialog and the controllermanager consistent.
QList<Controller*> controllerList =
m_pControllerManager->getControllerList(false, true);
for (auto controller : controllerList) {
controller->disconnect(this);
for (auto* pController : controllerList) {
pController->disconnect(this);
}
while (!m_controllerPages.isEmpty()) {
DlgPrefController* pControllerDlg = m_controllerPages.takeLast();
Expand Down
2 changes: 1 addition & 1 deletion src/effects/effectchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ EffectChain::EffectChain(const QString& group,
connect(m_pControlChainSuperParameter.get(),
&ControlObject::valueChanged,
this,
[=](double value) { slotControlChainSuperParameter(value, false); });
[=, this](double value) { slotControlChainSuperParameter(value, false); });
m_pControlChainSuperParameter->set(0.0);
m_pControlChainSuperParameter->setDefaultValue(0.0);

Expand Down
2 changes: 1 addition & 1 deletion src/effects/effectslot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ EffectSlot::EffectSlot(const QString& group,
connect(m_pControlMetaParameter.get(),
&ControlObject::valueChanged,
this,
[=](double value) { slotEffectMetaParameter(value); });
[=, this](double value) { slotEffectMetaParameter(value); });
m_pControlMetaParameter->set(0.0);
m_pControlMetaParameter->setDefaultValue(0.0);

Expand Down
15 changes: 11 additions & 4 deletions src/engine/channels/enginechannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,20 @@ void EngineChannel::slotOrientationCenter(double v) {
}

EngineChannel::ChannelOrientation EngineChannel::getOrientation() const {
double dOrientation = m_pOrientation->get();
if (dOrientation == LEFT) {
const double dOrientation = m_pOrientation->get();
const int iOrientation = static_cast<int>(dOrientation);
if (dOrientation != iOrientation) {
return CENTER;
}
switch (iOrientation) {
case LEFT:
return LEFT;
} else if (dOrientation == CENTER) {
case CENTER:
return CENTER;
} else if (dOrientation == RIGHT) {
case RIGHT:
return RIGHT;
default:
return CENTER;
}
return CENTER;
}
8 changes: 6 additions & 2 deletions src/engine/controls/loopingcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,12 @@ LoopingControl::LoopingControl(const QString& group,
// DEPRECATED: Use beatloop_size and beatloop_set instead.
// Activates a beatloop of a specified number of beats.
m_pCOBeatLoop = new ControlObject(ConfigKey(group, "beatloop"), false);
connect(m_pCOBeatLoop, &ControlObject::valueChanged, this,
[=](double value){slotBeatLoop(value);}, Qt::DirectConnection);
connect(
m_pCOBeatLoop,
&ControlObject::valueChanged,
this,
[=, this](double value) { slotBeatLoop(value); },
Qt::DirectConnection);

m_pCOBeatLoopSize = new ControlObject(ConfigKey(group, "beatloop_size"),
true, false, false, 4.0);
Expand Down
2 changes: 1 addition & 1 deletion src/engine/enginebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ EngineBuffer::EngineBuffer(const QString& group,
m_pScaleLinear = new EngineBufferScaleLinear(m_pReadAheadManager);
m_pScaleST = new EngineBufferScaleST(m_pReadAheadManager);
m_pScaleRB = new EngineBufferScaleRubberBand(m_pReadAheadManager);
if (m_pKeylockEngine->get() == SOUNDTOUCH) {
if (m_pKeylockEngine->get() == static_cast<double>(SOUNDTOUCH)) {
m_pScaleKeylock = m_pScaleST;
} else {
m_pScaleKeylock = m_pScaleRB;
Expand Down
2 changes: 1 addition & 1 deletion src/library/analysisfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void AnalysisFeature::bindLibraryWidget(WLibrary* libraryWidget,
connect(m_pAnalysisView,
&DlgAnalysis::loadTrackToPlayer,
this,
[=](TrackPointer track, const QString& group) {
[=, this](TrackPointer track, const QString& group) {
emit loadTrackToPlayer(track, group, false);
});
connect(m_pAnalysisView,
Expand Down
1 change: 0 additions & 1 deletion src/library/autodj/autodjprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ AutoDJProcessor::AutoDJProcessor(
int iAutoDJPlaylistId)
: QObject(pParent),
m_pConfig(pConfig),
m_pPlayerManager(pPlayerManager),
m_pAutoDJTableModel(nullptr),
m_eState(ADJ_DISABLED),
m_transitionProgress(0.0),
Expand Down
5 changes: 2 additions & 3 deletions src/library/autodj/autodjprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ class DeckAttributes : public QObject {
virtual ~DeckAttributes();

bool isLeft() const {
return m_orientation.get() == EngineChannel::LEFT;
return m_orientation.get() == static_cast<double>(EngineChannel::LEFT);
}

bool isRight() const {
return m_orientation.get() == EngineChannel::RIGHT;
return m_orientation.get() == static_cast<double>(EngineChannel::RIGHT);
}

bool isPlaying() const {
Expand Down Expand Up @@ -278,7 +278,6 @@ class AutoDJProcessor : public QObject {
bool removeTrackFromTopOfQueue(TrackPointer pTrack);
void maybeFillRandomTracks();
UserSettingsPointer m_pConfig;
PlayerManagerInterface* m_pPlayerManager;
PlaylistTableModel* m_pAutoDJTableModel;

AutoDJState m_eState;
Expand Down
10 changes: 5 additions & 5 deletions src/network/jsonwebtask.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ namespace network {
struct JsonWebRequest final {
public:
JsonWebRequest() = delete;
JsonWebRequest(const JsonWebRequest&) = default;
JsonWebRequest(JsonWebRequest&&) = default;

JsonWebRequest& operator=(const JsonWebRequest&) = default;
JsonWebRequest& operator=(JsonWebRequest&&) = default;
JsonWebRequest(HttpRequestMethod method, QString path, QUrlQuery query, QJsonDocument content)
: method(std::move(method)),
path(std::move(path)),
query(std::move(query)),
content(std::move(content)){};

HttpRequestMethod method;
QString path;
Expand Down
5 changes: 3 additions & 2 deletions src/preferences/dialog/dlgprefdeck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ DlgPrefDeck::DlgPrefDeck(QWidget* parent,
// Create text color for the cue mode link "?" to the manual
createLinkColor();

m_pNumDecks->connectValueChanged(this, [=](double value){slotNumDecksChanged(value);});
m_pNumDecks->connectValueChanged(this, [=, this](double value) { slotNumDecksChanged(value); });
slotNumDecksChanged(m_pNumDecks->get(), true);

m_pNumSamplers->connectValueChanged(this, [=](double value){slotNumSamplersChanged(value);});
m_pNumSamplers->connectValueChanged(
this, [=, this](double value) { slotNumSamplersChanged(value); });
slotNumSamplersChanged(m_pNumSamplers->get(), true);

// Set default value in config file and control objects, if not present
Expand Down
4 changes: 2 additions & 2 deletions src/util/class.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
// A macro to disallow the copy constructor and operator= functions
// This should be used in the private: declarations for a class
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \
void operator=(const TypeName&)
TypeName(const TypeName&) = delete; \
void operator=(const TypeName&) = delete;
2 changes: 1 addition & 1 deletion src/util/fifo.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ class FIFO {
private:
std::vector<DataType> m_data;
PaUtilRingBuffer m_ringBuffer;
DISALLOW_COPY_AND_ASSIGN(FIFO<DataType>);
DISALLOW_COPY_AND_ASSIGN(FIFO);
};
10 changes: 2 additions & 8 deletions src/util/messagepipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ class MessagePipe {
rigtorp::SPSCQueue<ReceiverMessageType>& m_sender_messages;
QScopedPointer<BaseReferenceHolder> m_pTwoWayMessagePipeReference;

#define COMMA ,
DISALLOW_COPY_AND_ASSIGN(MessagePipe<SenderMessageType COMMA ReceiverMessageType>);
#undef COMMA
DISALLOW_COPY_AND_ASSIGN(MessagePipe);
};

// TwoWayMessagePipe is a bare-bones wrapper around the above rigtorp::SPSCQueue class that
Expand Down Expand Up @@ -106,9 +104,5 @@ class TwoWayMessagePipe {
// Messages waiting to be delivered to the sender.
rigtorp::SPSCQueue<ReceiverMessageType> m_sender_messages;

// This #define is because the macro gets confused by the template
// parameters.
#define COMMA ,
DISALLOW_COPY_AND_ASSIGN(TwoWayMessagePipe<SenderMessageType COMMA ReceiverMessageType>);
#undef COMMA
DISALLOW_COPY_AND_ASSIGN(TwoWayMessagePipe);
};
9 changes: 7 additions & 2 deletions src/widget/wtrackmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ void WTrackMenu::createMenus() {

void WTrackMenu::createActions() {
const auto hideRemoveKeySequence =
QKeySequence(kHideRemoveShortcutModifier | kHideRemoveShortcutKey);
// TODO(XXX): Qt6 replace enum | with QKeyCombination
QKeySequence(static_cast<int>(kPropertiesShortcutModifier) |
kPropertiesShortcutKey);

if (featureIsEnabled(Feature::AutoDJ)) {
m_pAutoDJBottomAct = new QAction(tr("Add to Auto DJ Queue (bottom)"), this);
Expand Down Expand Up @@ -253,7 +255,10 @@ void WTrackMenu::createActions() {
// The keypress is caught in WTrackTableView::keyPressEvent
if (m_pTrackModel) {
m_pPropertiesAct->setShortcut(
QKeySequence(kPropertiesShortcutModifier | kPropertiesShortcutKey));
// TODO(XXX): Qt6 replace enum | with QKeyCombination
QKeySequence(
static_cast<int>(kPropertiesShortcutModifier) |
kPropertiesShortcutKey));
Swiftb0y marked this conversation as resolved.
Show resolved Hide resolved
}
connect(m_pPropertiesAct, &QAction::triggered, this, &WTrackMenu::slotShowDlgTrackInfo);
}
Expand Down