Skip to content

Commit

Permalink
Refactor with C++17 guaranteed RVO
Browse files Browse the repository at this point in the history
No need to declare undefined move constructors.
Only HouseEvent still needs the phony constructor due to NRVO.

- xml::StreamElement
- gui::test::SignalSpy

Issue #250
  • Loading branch information
rakhimov committed Jan 5, 2018
1 parent 47b2af8 commit 96f0628
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
4 changes: 1 addition & 3 deletions gui/tests/help.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017 Olzhas Rakhimov
* Copyright (C) 2017-2018 Olzhas Rakhimov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -87,8 +87,6 @@ class SignalSpy : public QObject,
connect(sender, sig, this, &SignalSpy::accept, Qt::DirectConnection);
}

SignalSpy(SignalSpy &&); ///< Only to enable RVO. Undefined.

private:
/// Stores the signal arguments.
void accept(Ts... args) { this->emplace_back(args...); }
Expand Down
11 changes: 1 addition & 10 deletions src/xml_stream.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2017 Olzhas Rakhimov
* Copyright (C) 2016-2018 Olzhas Rakhimov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -199,15 +199,6 @@ class StreamElement {
detail::FileStream* out)
: StreamElement(name, 0, nullptr, indenter, out) {}

/// Move constructor is only declared
/// to make the compiler happy.
/// The code must rely on the RVO, NRVO, and copy elision
/// instead of this constructor.
///
/// The constructor is not defined,
/// so the use of this constructor will produce a linker error.
StreamElement(StreamElement&&);

/// Puts the closing tag.
///
/// @pre No child element is alive.
Expand Down

0 comments on commit 96f0628

Please sign in to comment.