Apply formatting/style tweaks to comply with compile time diagnostics for g++ and clang++ (#686)

* Add compilation flags: -Wshadow -Weffc++ -pedantic -pedantic-errors
* Delete implicit copy & move constructors & assignment operators
  in classes with pointer data members.
* An exception to the above: Add default copy & move constructors &
  assignment operators for the Binary class.
* Convert boolean RegEx operators to binary operators.
* Initialize all members in all classes in ctors.
* Let default ctor delegate to the converting ctor in
  Binary and RegEx
* Don't change any tests except regex_test (as a result of the change
  to binary operators).

Note: https://bugzilla.redhat.com/show_bug.cgi?id=1544675 makes
-Weffc++ report a false positive in "include/yaml-cpp/node/impl.h".
This commit is contained in:
Ted Lyngmo
2019-03-13 23:18:34 +01:00
committed by Jesse Beder
parent eca9cfd648
commit 0d5c57150c
40 changed files with 285 additions and 241 deletions

View File

@@ -8,8 +8,8 @@
#endif
#include <memory>
#include <utility>
#include <vector>
#include "yaml-cpp/noncopyable.h"
namespace YAML {
class SettingChangeBase;
@@ -18,6 +18,7 @@ template <typename T>
class Setting {
public:
Setting() : m_value() {}
Setting(const T& value) : m_value() { set(value); }
const T get() const { return m_value; }
std::unique_ptr<SettingChangeBase> set(const T& value);
@@ -36,10 +37,14 @@ class SettingChangeBase {
template <typename T>
class SettingChange : public SettingChangeBase {
public:
SettingChange(Setting<T>* pSetting) : m_pCurSetting(pSetting) {
// copy old setting to save its state
m_oldSetting = *pSetting;
}
SettingChange(Setting<T>* pSetting)
: m_pCurSetting(pSetting),
m_oldSetting(*pSetting) // copy old setting to save its state
{}
SettingChange(const SettingChange&) = delete;
SettingChange(SettingChange&&) = delete;
SettingChange& operator=(const SettingChange&) = delete;
SettingChange& operator=(SettingChange&&) = delete;
virtual void pop() { m_pCurSetting->restore(m_oldSetting); }
@@ -55,9 +60,12 @@ inline std::unique_ptr<SettingChangeBase> Setting<T>::set(const T& value) {
return pChange;
}
class SettingChanges : private noncopyable {
class SettingChanges {
public:
SettingChanges() {}
SettingChanges() : m_settingChanges{} {}
SettingChanges(const SettingChanges&) = delete;
SettingChanges(SettingChanges&&) = default;
SettingChanges& operator=(const SettingChanges&) = delete;
~SettingChanges() { clear(); }
void clear() {
@@ -90,6 +98,6 @@ class SettingChanges : private noncopyable {
typedef std::vector<std::unique_ptr<SettingChangeBase>> setting_changes;
setting_changes m_settingChanges;
};
}
} // namespace YAML
#endif // SETTING_H_62B23520_7C8E_11DE_8A39_0800200C9A66