diff --git a/ChangeLog.txt b/ChangeLog.txt index 1985351f2..945750c37 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -62,6 +62,7 @@ - Puzzle app. Horizontal piece flipping. - Mirror line. - Fold line. +- Minimal Qt version increased to Qt 5.15. Minimal C++ standard to C++17. # Valentina 0.7.52 September 12, 2022 - Fix crash when default locale is ru. diff --git a/appveyor.yml b/appveyor.yml index fb2672c12..029febafb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -158,18 +158,6 @@ environment: WINDEPLOYQT_NO_COMPILER_RUNTIME: "false" DEPLOY: true RUN_TESTS: true - - - job_name: Windows_Qt_5_6_(GCC_x86) - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - COMPILER: mingw - QT: Qt\5.6\mingw49_32 - QT_VERSION: Qt5_6 - BUILD_SYSTEM: "make" - MINGW_PATH: C:\Qt\Tools\mingw492_32\bin - ARCH: x86 - PYTHON: "C:\\Python38" - PLATFORM: "WindowsXP+" - DEPLOY: true - job_name: Windows_Qt_5_15_(make_GCC_x86) APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 @@ -259,18 +247,6 @@ environment: PLATFORM: "macOS_10.13+" DEPLOY: false - - job_name: Windows_Qt_5_6_(MSVC_x64) - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - COMPILER: msvc - QT: Qt\5.6\msvc2015_64 - QT_VERSION: Qt5_6 - BUILD_SYSTEM: "nmake" - VSVER: 14 - ARCH: x64 - PYTHON: "C:\\Python38-x64" - PLATFORM: "WindowsXP+" - DEPLOY: false - matrix: fast_finish: false exclude: @@ -286,8 +262,6 @@ matrix: job_name: Windows_Qt_5_15_(qbs_GCC_x64) - platform: x86 job_name: Windows_Qt_5_15_(qbs_MSVC_x64) - - platform: x86 - job_name: Windows_Qt_5_6_(MSVC_x64) - platform: x86 job_name: MacOS_12_Qt_6_4 (multibundle) - platform: x86 @@ -302,8 +276,6 @@ matrix: job_name: Windows_Qt_5_15_(make_GCC_x86) - platform: x64 job_name: Windows_Qt_5_15_(qbs_GCC_x86) - - platform: x64 - job_name: Windows_Qt_5_6_(GCC_x86) for: @@ -449,8 +421,6 @@ for: - job_name: Windows_Qt_5_15_(make_GCC_x86) - job_name: Windows_Qt_5_15_(make_GCC_x64) - job_name: Windows_Qt_5_15_(nmake_MSVC_x64) - - job_name: Windows_Qt_5_6_(GCC_x86) - - job_name: Windows_Qt_5_6_(MSVC_x64) # clone directory clone_folder: c:\projects\valentina diff --git a/dist/win/openssl/win32/libeay32.dll b/dist/win/openssl/win32/libeay32.dll deleted file mode 100644 index 9eefd6e30..000000000 Binary files a/dist/win/openssl/win32/libeay32.dll and /dev/null differ diff --git a/dist/win/openssl/win32/ssleay32.dll b/dist/win/openssl/win32/ssleay32.dll deleted file mode 100644 index 1d7fb6acf..000000000 Binary files a/dist/win/openssl/win32/ssleay32.dll and /dev/null differ diff --git a/dist/win/openssl/win64/libeay32.dll b/dist/win/openssl/win64/libeay32.dll deleted file mode 100644 index b11cdb9b2..000000000 Binary files a/dist/win/openssl/win64/libeay32.dll and /dev/null differ diff --git a/dist/win/openssl/win64/ssleay32.dll b/dist/win/openssl/win64/ssleay32.dll deleted file mode 100644 index 31ea2e5a8..000000000 Binary files a/dist/win/openssl/win64/ssleay32.dll and /dev/null differ diff --git a/qbs/imports/VApp.qbs b/qbs/imports/VApp.qbs index 3c8941ef9..7acaa9e42 100644 --- a/qbs/imports/VApp.qbs +++ b/qbs/imports/VApp.qbs @@ -42,9 +42,7 @@ CppApplication { cpp.cxxLanguageVersion: { if (Qt.core.versionMajor >= 6) // Start building with C++20 since Qt 6.0 return "c++20"; - else if(Qt.core.versionMajor >= 5 && Qt.core.versionMinor >= 12) // Since Qt 5.12 available support for C++17 - return "c++17"; - return "c++11"; + return "c++17"; } Properties { @@ -52,11 +50,7 @@ CppApplication { cpp.minimumWindowsVersion: { if (Qt.core.versionMajor >= 6) return "6.02"; // should be 10.0 - - if (Qt.core.versionMajor >= 5 && Qt.core.versionMinor >= 7) - return "6.00"; - - return "5.01"; + return "6.00"; } } @@ -80,31 +74,18 @@ CppApplication { files.push("msvcr120.dll"); // Minimal supported OpenSSL version since Qt 5.12.4 is 1.1.1. - if (Utilities.versionCompare(Qt.core.version, "5.12.4") >= 0) { - if (qbs.architecture.contains("x86_64")) { - files.push( - "openssl/win64/libcrypto-1_1-x64.dll", - "openssl/win64/libssl-1_1-x64.dll" - ); - } else { - files.push( - "openssl/win32/libcrypto-1_1.dll", - "openssl/win32/libssl-1_1.dll" - ); - } + if (qbs.architecture.contains("x86_64")) { + files.push( + "openssl/win64/libcrypto-1_1-x64.dll", + "openssl/win64/libssl-1_1-x64.dll" + ); } else { - if (qbs.architecture.contains("x86_64")) { - files.push( - "openssl/win64/libeay32.dll", - "openssl/win64/ssleay32.dll" - ); - } else { - files.push( - "openssl/win32/libeay32.dll", - "openssl/win32/ssleay32.dll" - ); - } + files.push( + "openssl/win32/libcrypto-1_1.dll", + "openssl/win32/libssl-1_1.dll" + ); } + return files; } qbs.install: true diff --git a/qbs/imports/VLib.qbs b/qbs/imports/VLib.qbs index 29d1f4d35..851bcb3fa 100644 --- a/qbs/imports/VLib.qbs +++ b/qbs/imports/VLib.qbs @@ -26,9 +26,7 @@ Library { cpp.cxxLanguageVersion: { if (Qt.core.versionMajor >= 6) // Start building with C++20 since Qt 6.0 return "c++20"; - else if(Qt.core.versionMajor >= 5 && Qt.core.versionMinor >= 12) // Since Qt 5.12 available support for C++17 - return "c++17"; - return "c++11"; + return "c++17"; } Properties { @@ -37,10 +35,7 @@ Library { if (Qt.core.versionMajor >= 6) return "6.02"; // should be 10.0 - if (Qt.core.versionMajor >= 5 && Qt.core.versionMinor >= 7) - return "6.00"; - - return "5.01"; + return "6.00"; } } diff --git a/qbs/modules/buildconfig/buildconfig.qbs b/qbs/modules/buildconfig/buildconfig.qbs index 24b899caa..2899f8c04 100644 --- a/qbs/modules/buildconfig/buildconfig.qbs +++ b/qbs/modules/buildconfig/buildconfig.qbs @@ -157,34 +157,8 @@ Module { return "10.15"; // Qt 6.4 and above } - if (Qt.core.versionMajor >= 5) { - // See page https://doc.qt.io/qt-5.15/supported-platforms.html - // For qt 5.14 https://doc.qt.io/archives/qt-5.14/supported-platforms.html - if (Qt.core.versionMinor >= 14) // Qt 5.14 - return "10.13"; - - // For Qt 5.13 https://doc.qt.io/archives/qt-5.13/supported-platforms.html - // For Qt 5.12 https://doc.qt.io/archives/qt-5.12/supported-platforms.html - if (Qt.core.versionMinor >= 12) // Qt 5.12 - return "10.12"; - - // For older versions https://doc.qt.io/archives/qt-5.11/supported-platforms-and-configurations.html - if (Qt.core.versionMinor >= 10) // Qt 5.11 and Qt 5.10 - return "10.11"; - - if (Qt.core.versionMinor >= 9) // Qt 5.9 - return "10.10"; - - if (Qt.core.versionMinor >= 8) // Qt 5.8 - return "10.9"; - - if (Qt.core.versionMinor >= 7) // Qt 5.7 - return "10.8"; - - return "10.7"; - } - - return undefined; + // See page https://doc.qt.io/qt-5.15/supported-platforms.html + return "10.13"; } cpp.separateDebugInformation: true diff --git a/qbs/modules/ebr/ebr.qbs b/qbs/modules/ebr/ebr.qbs index 567009342..eda117dc3 100644 --- a/qbs/modules/ebr/ebr.qbs +++ b/qbs/modules/ebr/ebr.qbs @@ -24,14 +24,8 @@ Module { var enableCompression = input.moduleProperty("ebr", "enableCompression"); if (enableCompression) { var compressAlgorithm = input.moduleProperty("ebr", "compressAlgorithm"); - if (product.Qt.core.versionMajor >= 5 && product.Qt.core.versionMinor >= 13) { - // Since Qt 5.13 we have option to select compress algorithm - if (compressAlgorithm !== "zstd") - args.push("-compress-algo", compressAlgorithm); - } else { - if (compressAlgorithm !== "zlib") - compressAlgorithm = "zlib"; - } + if (compressAlgorithm !== "zstd") + args.push("-compress-algo", compressAlgorithm); var thresholdLevel = input.moduleProperty("ebr", "thresholdLevel"); if (thresholdLevel !== 70) diff --git a/src/app/puzzle/carousel/vpcarrousel.cpp b/src/app/puzzle/carousel/vpcarrousel.cpp index 73f45003b..f67a4526b 100644 --- a/src/app/puzzle/carousel/vpcarrousel.cpp +++ b/src/app/puzzle/carousel/vpcarrousel.cpp @@ -32,9 +32,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../layout/vplayout.h" #include "../layout/vpsheet.h" diff --git a/src/app/puzzle/carousel/vpcarrousel.h b/src/app/puzzle/carousel/vpcarrousel.h index 4eb8b67bf..33cd47304 100644 --- a/src/app/puzzle/carousel/vpcarrousel.h +++ b/src/app/puzzle/carousel/vpcarrousel.h @@ -35,9 +35,6 @@ #include #include "../layout/layoutdef.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif namespace Ui { diff --git a/src/app/puzzle/carousel/vpcarrouselpiece.h b/src/app/puzzle/carousel/vpcarrouselpiece.h index 2dc5b54fa..c06bd3416 100644 --- a/src/app/puzzle/carousel/vpcarrouselpiece.h +++ b/src/app/puzzle/carousel/vpcarrouselpiece.h @@ -32,9 +32,6 @@ #include #include "../layout/layoutdef.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif class VPCarrouselPiece : public QListWidgetItem { diff --git a/src/app/puzzle/carousel/vpcarrouselpiecelist.cpp b/src/app/puzzle/carousel/vpcarrouselpiecelist.cpp index 71b395383..7bdf0103d 100644 --- a/src/app/puzzle/carousel/vpcarrouselpiecelist.cpp +++ b/src/app/puzzle/carousel/vpcarrouselpiecelist.cpp @@ -43,10 +43,6 @@ #include "vpcarrouselpiece.h" #include "vpmimedatapiece.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) diff --git a/src/app/puzzle/carousel/vpmimedatapiece.h b/src/app/puzzle/carousel/vpmimedatapiece.h index 1096ae87b..33b1dd907 100644 --- a/src/app/puzzle/carousel/vpmimedatapiece.h +++ b/src/app/puzzle/carousel/vpmimedatapiece.h @@ -34,9 +34,6 @@ #include #include "../layout/layoutdef.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif class VPMimeDataPiece : public QMimeData { diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp index 074ef1f87..1d9e8ecef 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.cpp @@ -34,10 +34,6 @@ #include "../vmisc/vabstractshortcutmanager.h" #include "ui_puzzlepreferencesconfigurationpage.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - #include //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.h b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.h index 8398bbdf3..1e3309258 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.h +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferencesconfigurationpage.h @@ -30,10 +30,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace Ui { class PuzzlePreferencesConfigurationPage; diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.cpp b/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.cpp index 45d4ec549..3ae348679 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.cpp +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferenceslayoutpage.cpp @@ -26,15 +26,12 @@ ** *************************************************************************/ #include "puzzlepreferenceslayoutpage.h" -#include "ui_puzzlepreferenceslayoutpage.h" #include "../../vpapplication.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) +#include "ui_puzzlepreferenceslayoutpage.h" //--------------------------------------------------------------------------------------------------------------------- -PuzzlePreferencesLayoutPage::PuzzlePreferencesLayoutPage(QWidget *parent) : - QWidget(parent), +PuzzlePreferencesLayoutPage::PuzzlePreferencesLayoutPage(QWidget *parent) + : QWidget(parent), ui(new Ui::PuzzlePreferencesLayoutPage) { ui->setupUi(this); @@ -49,47 +46,48 @@ PuzzlePreferencesLayoutPage::PuzzlePreferencesLayoutPage(QWidget *parent) : ReadSettings(); - connect(ui->comboBoxLayoutUnit, QOverload::of(&QComboBox::currentIndexChanged), - this, &PuzzlePreferencesLayoutPage::ConvertPaperSize); + connect(ui->comboBoxLayoutUnit, QOverload::of(&QComboBox::currentIndexChanged), this, + &PuzzlePreferencesLayoutPage::ConvertPaperSize); - connect(ui->comboBoxSheetTemplates, QOverload::of(&QComboBox::currentIndexChanged), - this, [this] - { - SheetSize(SheetTemplate()); m_settingsChanged = true; - }); - connect(ui->comboBoxTileTemplates, QOverload::of(&QComboBox::currentIndexChanged), - this, [this] - { - TileSize(TileTemplate()); - m_settingsChanged = true; - }); + connect(ui->comboBoxSheetTemplates, QOverload::of(&QComboBox::currentIndexChanged), this, + [this] + { + SheetSize(SheetTemplate()); + m_settingsChanged = true; + }); + connect(ui->comboBoxTileTemplates, QOverload::of(&QComboBox::currentIndexChanged), this, + [this] + { + TileSize(TileTemplate()); + m_settingsChanged = true; + }); - connect(ui->doubleSpinBoxSheetPaperWidth, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &PuzzlePreferencesLayoutPage::SheetPaperSizeChanged); - connect(ui->doubleSpinBoxSheetPaperHeight, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &PuzzlePreferencesLayoutPage::SheetPaperSizeChanged); - connect(ui->doubleSpinBoxTilePaperWidth, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &PuzzlePreferencesLayoutPage::TilePaperSizeChanged); - connect(ui->doubleSpinBoxTilePaperHeight, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &PuzzlePreferencesLayoutPage::TilePaperSizeChanged); + connect(ui->doubleSpinBoxSheetPaperWidth, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &PuzzlePreferencesLayoutPage::SheetPaperSizeChanged); + connect(ui->doubleSpinBoxSheetPaperHeight, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &PuzzlePreferencesLayoutPage::SheetPaperSizeChanged); + connect(ui->doubleSpinBoxTilePaperWidth, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &PuzzlePreferencesLayoutPage::TilePaperSizeChanged); + connect(ui->doubleSpinBoxTilePaperHeight, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &PuzzlePreferencesLayoutPage::TilePaperSizeChanged); - connect(ui->doubleSpinBoxSheetPaperWidth, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &PuzzlePreferencesLayoutPage::FindSheetTemplate); - connect(ui->doubleSpinBoxSheetPaperHeight, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &PuzzlePreferencesLayoutPage::FindSheetTemplate); - connect(ui->doubleSpinBoxTilePaperWidth, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &PuzzlePreferencesLayoutPage::FindTileTemplate); - connect(ui->doubleSpinBoxTilePaperHeight, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &PuzzlePreferencesLayoutPage::FindTileTemplate); + connect(ui->doubleSpinBoxSheetPaperWidth, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &PuzzlePreferencesLayoutPage::FindSheetTemplate); + connect(ui->doubleSpinBoxSheetPaperHeight, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &PuzzlePreferencesLayoutPage::FindSheetTemplate); + connect(ui->doubleSpinBoxTilePaperWidth, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &PuzzlePreferencesLayoutPage::FindTileTemplate); + connect(ui->doubleSpinBoxTilePaperHeight, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &PuzzlePreferencesLayoutPage::FindTileTemplate); - connect(ui->doubleSpinBoxSheetPaperWidth, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &PuzzlePreferencesLayoutPage::CorrectMaxMargins); - connect(ui->doubleSpinBoxSheetPaperHeight, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &PuzzlePreferencesLayoutPage::CorrectMaxMargins); - connect(ui->doubleSpinBoxTilePaperWidth, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &PuzzlePreferencesLayoutPage::CorrectMaxMargins); - connect(ui->doubleSpinBoxTilePaperHeight, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &PuzzlePreferencesLayoutPage::CorrectMaxMargins); + connect(ui->doubleSpinBoxSheetPaperWidth, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &PuzzlePreferencesLayoutPage::CorrectMaxMargins); + connect(ui->doubleSpinBoxSheetPaperHeight, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &PuzzlePreferencesLayoutPage::CorrectMaxMargins); + connect(ui->doubleSpinBoxTilePaperWidth, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &PuzzlePreferencesLayoutPage::CorrectMaxMargins); + connect(ui->doubleSpinBoxTilePaperHeight, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &PuzzlePreferencesLayoutPage::CorrectMaxMargins); connect(ui->checkBoxLayoutIgnoreFileds, &QCheckBox::stateChanged, this, &PuzzlePreferencesLayoutPage::LayoutSheetIgnoreMargins); @@ -105,29 +103,31 @@ PuzzlePreferencesLayoutPage::PuzzlePreferencesLayoutPage(QWidget *parent) : connect(ui->toolButtonTileLandscapeOrientation, &QToolButton::toggled, this, &PuzzlePreferencesLayoutPage::SwapTileOrientation); - connect(ui->doubleSpinBoxSheetMarginLeft, QOverload::of(&QDoubleSpinBox::valueChanged), - this, [this](){m_settingsChanged=true;}); - connect(ui->doubleSpinBoxSheetMarginRight, QOverload::of(&QDoubleSpinBox::valueChanged), - this, [this](){m_settingsChanged=true;}); - connect(ui->doubleSpinBoxSheetMarginTop, QOverload::of(&QDoubleSpinBox::valueChanged), - this, [this](){m_settingsChanged=true;}); - connect(ui->doubleSpinBoxSheetMarginBottom, QOverload::of(&QDoubleSpinBox::valueChanged), - this, [this](){m_settingsChanged=true;}); + connect(ui->doubleSpinBoxSheetMarginLeft, QOverload::of(&QDoubleSpinBox::valueChanged), this, + [this]() { m_settingsChanged = true; }); + connect(ui->doubleSpinBoxSheetMarginRight, QOverload::of(&QDoubleSpinBox::valueChanged), this, + [this]() { m_settingsChanged = true; }); + connect(ui->doubleSpinBoxSheetMarginTop, QOverload::of(&QDoubleSpinBox::valueChanged), this, + [this]() { m_settingsChanged = true; }); + connect(ui->doubleSpinBoxSheetMarginBottom, QOverload::of(&QDoubleSpinBox::valueChanged), this, + [this]() { m_settingsChanged = true; }); - connect(ui->checkBoxTileShowTiles, &QCheckBox::stateChanged, this, [this](){m_settingsChanged=true;}); - connect(ui->checkBoxTileShowWatermark, &QCheckBox::stateChanged, this, [this](){m_settingsChanged=true;}); - connect(ui->checkBoxTileShowWatermark, &QCheckBox::stateChanged, this, [this](){m_settingsChanged=true;}); + connect(ui->checkBoxTileShowTiles, &QCheckBox::stateChanged, this, [this]() { m_settingsChanged = true; }); + connect(ui->checkBoxTileShowWatermark, &QCheckBox::stateChanged, this, [this]() { m_settingsChanged = true; }); + connect(ui->checkBoxTileShowWatermark, &QCheckBox::stateChanged, this, [this]() { m_settingsChanged = true; }); - connect(ui->doubleSpinBoxPiecesGap, QOverload::of(&QDoubleSpinBox::valueChanged), - this, [this](){m_settingsChanged=true;}); + connect(ui->doubleSpinBoxPiecesGap, QOverload::of(&QDoubleSpinBox::valueChanged), this, + [this]() { m_settingsChanged = true; }); ui->doubleSpinBoxPiecesGap->setSuffix(UnitsToStr(m_oldLayoutUnit)); ui->spinBoxLineWidth->setSuffix(UnitsToStr(Unit::Px)); - connect(ui->checkBoxWarningPiecesSuperposition, &QCheckBox::stateChanged, this, [this](){m_settingsChanged=true;}); - connect(ui->checkBoxStickyEdges, &QCheckBox::stateChanged, this, [this](){m_settingsChanged=true;}); - connect(ui->checkBoxWarningPiecesOutOfBound, &QCheckBox::stateChanged, this, [this](){m_settingsChanged=true;}); - connect(ui->checkBoxFollowGrainline, &QCheckBox::stateChanged, this, [this](){m_settingsChanged=true;}); + connect(ui->checkBoxWarningPiecesSuperposition, &QCheckBox::stateChanged, this, + [this]() { m_settingsChanged = true; }); + connect(ui->checkBoxStickyEdges, &QCheckBox::stateChanged, this, [this]() { m_settingsChanged = true; }); + connect(ui->checkBoxWarningPiecesOutOfBound, &QCheckBox::stateChanged, this, + [this]() { m_settingsChanged = true; }); + connect(ui->checkBoxFollowGrainline, &QCheckBox::stateChanged, this, [this]() { m_settingsChanged = true; }); } //--------------------------------------------------------------------------------------------------------------------- @@ -145,9 +145,9 @@ auto PuzzlePreferencesLayoutPage::Apply() -> QStringList settings->SetLayoutUnit(LayoutUnit()); settings->SetLayoutSheetPaperHeight( - UnitConvertor(ui->doubleSpinBoxSheetPaperHeight->value(), m_oldLayoutUnit, Unit::Px)); + UnitConvertor(ui->doubleSpinBoxSheetPaperHeight->value(), m_oldLayoutUnit, Unit::Px)); settings->SetLayoutSheetPaperWidth( - UnitConvertor(ui->doubleSpinBoxSheetPaperWidth->value(), m_oldLayoutUnit, Unit::Px)); + UnitConvertor(ui->doubleSpinBoxSheetPaperWidth->value(), m_oldLayoutUnit, Unit::Px)); settings->SetLayoutSheetIgnoreMargins(ui->checkBoxLayoutIgnoreFileds->isChecked()); settings->SetLayoutSheetMargins(GetSheetMargins()); @@ -156,9 +156,9 @@ auto PuzzlePreferencesLayoutPage::Apply() -> QStringList settings->SetLayoutTileShowWatermark(ui->checkBoxTileShowWatermark->isChecked()); settings->SetLayoutTilePaperHeight( - UnitConvertor(ui->doubleSpinBoxTilePaperHeight->value(), m_oldLayoutUnit, Unit::Px)); + UnitConvertor(ui->doubleSpinBoxTilePaperHeight->value(), m_oldLayoutUnit, Unit::Px)); settings->SetLayoutTilePaperWidth( - UnitConvertor(ui->doubleSpinBoxTilePaperWidth->value(), m_oldLayoutUnit, Unit::Px)); + UnitConvertor(ui->doubleSpinBoxTilePaperWidth->value(), m_oldLayoutUnit, Unit::Px)); settings->SetLayoutTileIgnoreMargins(ui->checkBoxTileIgnoreFileds->isChecked()); settings->SetLayoutTileMargins(GetTileMargins()); @@ -318,8 +318,8 @@ void PuzzlePreferencesLayoutPage::CorrectMaxMargins() const qreal sheetHeight = ui->doubleSpinBoxSheetPaperHeight->value(); // 80%/2 of paper size for each field - const qreal sheetWidthMargin = (sheetWidth*80.0/100.0)/2.0; - const qreal sheetHeightMargin = (sheetHeight*80.0/100.0)/2.0; + const qreal sheetWidthMargin = (sheetWidth * 80.0 / 100.0) / 2.0; + const qreal sheetHeightMargin = (sheetHeight * 80.0 / 100.0) / 2.0; ui->doubleSpinBoxSheetMarginLeft->setMaximum(sheetWidthMargin); ui->doubleSpinBoxSheetMarginRight->setMaximum(sheetWidthMargin); @@ -330,8 +330,8 @@ void PuzzlePreferencesLayoutPage::CorrectMaxMargins() const qreal tileHeight = ui->doubleSpinBoxTilePaperHeight->value(); // 80%/2 of paper size for each field - const qreal tileWidthMargin = (tileWidth*80.0/100.0)/2.0; - const qreal tileHeightMargin = (tileHeight*80.0/100.0)/2.0; + const qreal tileWidthMargin = (tileWidth * 80.0 / 100.0) / 2.0; + const qreal tileHeightMargin = (tileHeight * 80.0 / 100.0) / 2.0; ui->doubleSpinBoxTileMarginLeft->setMaximum(tileWidthMargin); ui->doubleSpinBoxTileMarginRight->setMaximum(tileWidthMargin); @@ -689,10 +689,10 @@ void PuzzlePreferencesLayoutPage::FindTemplate(QComboBox *box, qreal width, qrea const Unit paperUnit = LayoutUnit(); const int max = static_cast(VAbstractLayoutDialog::PaperSizeTemplate::Custom); - for (int i=0; i < max; ++i) + for (int i = 0; i < max; ++i) { - const QSizeF tmplSize = VAbstractLayoutDialog::GetTemplateSize( - static_cast(i), paperUnit); + const QSizeF tmplSize = + VAbstractLayoutDialog::GetTemplateSize(static_cast(i), paperUnit); if (QSizeF(width, height) == tmplSize || QSizeF(height, width) == tmplSize) { box->blockSignals(true); diff --git a/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.h b/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.h index 0b34b3a25..84be56a5b 100644 --- a/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.h +++ b/src/app/puzzle/dialogs/configpages/puzzlepreferencespathpage.h @@ -30,10 +30,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace Ui { class PuzzlePreferencesPathPage; diff --git a/src/app/puzzle/dialogs/dialogpuzzlepreferences.h b/src/app/puzzle/dialogs/dialogpuzzlepreferences.h index 16deab212..96aadd907 100644 --- a/src/app/puzzle/dialogs/dialogpuzzlepreferences.h +++ b/src/app/puzzle/dialogs/dialogpuzzlepreferences.h @@ -30,10 +30,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace Ui { class DialogPuzzlePreferences; diff --git a/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp b/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp index 3ed11d184..6c12b0fa7 100644 --- a/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp +++ b/src/app/puzzle/dialogs/dialogsavemanuallayout.cpp @@ -30,9 +30,6 @@ #include "../vlayout/vlayoutexporter.h" #include "../vpapplication.h" #include "ui_dialogsavemanuallayout.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include #include diff --git a/src/app/puzzle/dialogs/vpdialogabout.h b/src/app/puzzle/dialogs/vpdialogabout.h index 60d64d229..ea43e7465 100644 --- a/src/app/puzzle/dialogs/vpdialogabout.h +++ b/src/app/puzzle/dialogs/vpdialogabout.h @@ -31,10 +31,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace Ui { class VPDialogAbout; diff --git a/src/app/puzzle/layout/vppiece.h b/src/app/puzzle/layout/vppiece.h index dd30fee6a..8fc74e415 100644 --- a/src/app/puzzle/layout/vppiece.h +++ b/src/app/puzzle/layout/vppiece.h @@ -37,10 +37,6 @@ #include "../vlayout/vlayoutpiece.h" #include "vpiecegrainline.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - class VPLayout; class VPSheet; diff --git a/src/app/puzzle/layout/vpsheet.h b/src/app/puzzle/layout/vpsheet.h index acb4e0019..a5aafd245 100644 --- a/src/app/puzzle/layout/vpsheet.h +++ b/src/app/puzzle/layout/vpsheet.h @@ -39,10 +39,6 @@ #include "../vmisc/def.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - class VPLayout; class VPPiece; class VMainGraphicsScene; diff --git a/src/app/puzzle/main.cpp b/src/app/puzzle/main.cpp index 62746f1c8..b4157f038 100644 --- a/src/app/puzzle/main.cpp +++ b/src/app/puzzle/main.cpp @@ -32,12 +32,8 @@ #include "vpapplication.h" #if defined(APPIMAGE) && defined(Q_OS_LINUX) -#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) -#include "../vmisc/backport/qscopeguard.h" -#else -#include -#endif #include "../vmisc/appimage.h" +#include #endif // defined(APPIMAGE) && defined(Q_OS_LINUX) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -121,11 +117,9 @@ auto main(int argc, char *argv[]) -> int VPApplication app(argc, argv); app.InitOptions(); - QT_REQUIRE_VERSION(argc, argv, "5.6.0") // clazy:exclude=qstring-arg,qstring-allocations NOLINT + QT_REQUIRE_VERSION(argc, argv, "5.15.0") // clazy:exclude=qstring-arg,qstring-allocations NOLINT -#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) VPApplication::setDesktopFileName(QStringLiteral("ua.com.smart-pattern.puzzle.desktop")); -#endif QTimer::singleShot(0, &app, &VPApplication::ProcessCMD); diff --git a/src/app/puzzle/scene/vpgraphicspiece.cpp b/src/app/puzzle/scene/vpgraphicspiece.cpp index 22adaec14..76aac4eb4 100644 --- a/src/app/puzzle/scene/vpgraphicspiece.cpp +++ b/src/app/puzzle/scene/vpgraphicspiece.cpp @@ -135,7 +135,7 @@ inline auto LineFont(const TextLine &tl, const VSvgFont &base) -> VSvgFont //--------------------------------------------------------------------------------------------------------------------- inline auto LineAlign(const TextLine &tl, const QString &text, const QFontMetrics &fm, qreal width) -> qreal { - const int lineWidth = TextWidth(fm, text); + const int lineWidth = fm.horizontalAdvance(text); qreal dX = 0; if (tl.m_eAlign == 0 || (tl.m_eAlign & Qt::AlignLeft) > 0) @@ -553,7 +553,7 @@ void VPGraphicsPiece::InitPieceLabelOutlineFont(const QVector &labelSha for (auto c : qAsConst(tl.m_qsText)) { path.addPath(corrector.DrawChar(w, static_cast(fm.ascent()), c)); - w += TextWidth(fm, c); + w += fm.horizontalAdvance(c); } } else diff --git a/src/app/puzzle/scene/vpgraphicspiece.h b/src/app/puzzle/scene/vpgraphicspiece.h index 46f7bbbd1..55e2a35e0 100644 --- a/src/app/puzzle/scene/vpgraphicspiece.h +++ b/src/app/puzzle/scene/vpgraphicspiece.h @@ -35,10 +35,6 @@ #include "../layout/layoutdef.h" #include "scenedef.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - class VTextManager; class VGraphicsFillItem; diff --git a/src/app/puzzle/scene/vpgraphicspiececontrols.h b/src/app/puzzle/scene/vpgraphicspiececontrols.h index 2a4fd246d..02ef14fe8 100644 --- a/src/app/puzzle/scene/vpgraphicspiececontrols.h +++ b/src/app/puzzle/scene/vpgraphicspiececontrols.h @@ -34,10 +34,6 @@ #include "../layout/layoutdef.h" #include "scenedef.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - class VPLayout; class VPGraphicsPiece; class QGraphicsView; diff --git a/src/app/puzzle/scene/vpgraphicssheet.h b/src/app/puzzle/scene/vpgraphicssheet.h index 1b35b604a..3962627af 100644 --- a/src/app/puzzle/scene/vpgraphicssheet.h +++ b/src/app/puzzle/scene/vpgraphicssheet.h @@ -34,9 +34,6 @@ #include #include "../layout/layoutdef.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif class VPLayout; diff --git a/src/app/puzzle/scene/vpgraphicstilegrid.h b/src/app/puzzle/scene/vpgraphicstilegrid.h index ab0cc825c..3e0c1578d 100644 --- a/src/app/puzzle/scene/vpgraphicstilegrid.h +++ b/src/app/puzzle/scene/vpgraphicstilegrid.h @@ -35,10 +35,6 @@ #include "../layout/layoutdef.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - class VPTileFactory; class VPLayout; struct VWatermarkData; @@ -47,7 +43,7 @@ class VPGraphicsTileGrid : public QGraphicsItem { public: explicit VPGraphicsTileGrid(const VPLayoutPtr &layout, const QUuid &sheetUuid, QGraphicsItem *parent = nullptr); - ~VPGraphicsTileGrid() override =default; + ~VPGraphicsTileGrid() override = default; auto boundingRect() const -> QRectF override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; diff --git a/src/app/puzzle/undocommands/vpundocommand.h b/src/app/puzzle/undocommands/vpundocommand.h index fd97e833d..1406967b7 100644 --- a/src/app/puzzle/undocommands/vpundocommand.h +++ b/src/app/puzzle/undocommands/vpundocommand.h @@ -28,17 +28,13 @@ #ifndef VPUNDOCOMMAND_H #define VPUNDOCOMMAND_H +#include #include #include -#include - -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) namespace ML { -enum class UndoCommand: qint8 +enum class UndoCommand : qint8 { MovePiece = 0, MovePieces = 1, @@ -51,17 +47,18 @@ enum class UndoCommand: qint8 ZValueMovePiece = 8, ZValueMovePieces = 9, }; -} // namespace ML +} // namespace ML Q_DECLARE_LOGGING_CATEGORY(vpUndo) // NOLINT class VPUndoCommand : public QObject, public QUndoCommand { Q_OBJECT // NOLINT + public: explicit VPUndoCommand(QUndoCommand *parent = nullptr); explicit VPUndoCommand(bool allowMerge = false, QUndoCommand *parent = nullptr); - ~VPUndoCommand() override =default; + ~VPUndoCommand() override = default; auto AllowMerge() const -> bool; @@ -72,7 +69,6 @@ private: bool m_allowMerge{false}; }; - //--------------------------------------------------------------------------------------------------------------------- inline auto VPUndoCommand::AllowMerge() const -> bool { diff --git a/src/app/puzzle/undocommands/vpundopiecezvaluemove.h b/src/app/puzzle/undocommands/vpundopiecezvaluemove.h index 355721d5a..8b78f0a08 100644 --- a/src/app/puzzle/undocommands/vpundopiecezvaluemove.h +++ b/src/app/puzzle/undocommands/vpundopiecezvaluemove.h @@ -28,12 +28,8 @@ #ifndef VPUNDOPIECEZVALUEMOVE_H #define VPUNDOPIECEZVALUEMOVE_H -#include "vpundocommand.h" #include "../layout/layoutdef.h" - -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) +#include "vpundocommand.h" namespace ML { @@ -49,9 +45,10 @@ enum class ZValueMove class VPUndoPieceZValueMove : public VPUndoCommand { Q_OBJECT // NOLINT + public: VPUndoPieceZValueMove(const VPPiecePtr &piece, ML::ZValueMove move, QUndoCommand *parent = nullptr); - ~VPUndoPieceZValueMove() override =default; + ~VPUndoPieceZValueMove() override = default; void undo() override; void redo() override; @@ -74,9 +71,10 @@ private: class VPUndoPiecesZValueMove : public VPUndoCommand { Q_OBJECT // NOLINT + public: VPUndoPiecesZValueMove(const QList &pieces, ML::ZValueMove move, QUndoCommand *parent = nullptr); - ~VPUndoPiecesZValueMove() override =default; + ~VPUndoPiecesZValueMove() override = default; void undo() override; void redo() override; @@ -86,15 +84,15 @@ private: Q_DISABLE_COPY_MOVE(VPUndoPiecesZValueMove) // NOLINT QList m_pieces{}; - ML::ZValueMove m_move; + ML::ZValueMove m_move; QHash m_oldValues{}; auto Layout() const -> VPLayoutPtr; auto Sheet() const -> VPSheetPtr; auto PieceIds() const -> QVector; - static auto Levels(const QList &allPieces, const QVector &skipPieces, - bool skip) -> QList>; + static auto Levels(const QList &allPieces, const QVector &skipPieces, bool skip) + -> QList>; static auto LevelStep(const QList &pieces) -> qreal; }; diff --git a/src/app/puzzle/vpapplication.cpp b/src/app/puzzle/vpapplication.cpp index 211dea29b..badcefb61 100644 --- a/src/app/puzzle/vpapplication.cpp +++ b/src/app/puzzle/vpapplication.cpp @@ -115,26 +115,6 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con #endif // defined(V_NO_ASSERT) #if defined(Q_OS_MAC) -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - // Try hide very annoying, Qt related, warnings in Mac OS X - // QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton) - // https://bugreports.qt.io/browse/QTBUG-42846 - if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QNSView"))) - { - type = QtDebugMsg; - } -#endif - -#if QT_VERSION < QT_VERSION_CHECK(5, 9, 0) - // Hide Qt bug 'Assertion when reading an icns file' - // https://bugreports.qt.io/browse/QTBUG-45537 - // Remove after Qt fix will be released - if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QICNSHandler::read()"))) - { - type = QtDebugMsg; - } -#endif - // Hide anything that starts with QMacCGContext if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QMacCGContext::"))) { diff --git a/src/app/puzzle/vpcommandline.h b/src/app/puzzle/vpcommandline.h index 4191f9d90..99a498d59 100644 --- a/src/app/puzzle/vpcommandline.h +++ b/src/app/puzzle/vpcommandline.h @@ -37,10 +37,6 @@ #include // and, not, or #endif -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class VPCommandLine; using VPCommandLinePtr = std::shared_ptr; diff --git a/src/app/puzzle/vpmainwindow.cpp b/src/app/puzzle/vpmainwindow.cpp index a4bdfe5e7..40b7b67e7 100644 --- a/src/app/puzzle/vpmainwindow.cpp +++ b/src/app/puzzle/vpmainwindow.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -75,16 +76,6 @@ #include "xml/vplayoutfilereader.h" #include "xml/vplayoutfilewriter.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - -#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) -#include "../vmisc/backport/qscopeguard.h" -#else -#include -#endif - QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") QT_WARNING_DISABLE_INTEL(1418) @@ -93,16 +84,7 @@ Q_LOGGING_CATEGORY(pWindow, "p.window") // NOLINT QT_WARNING_POP -#if (defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) -// DO NOT WORK WITH GCC 4.8 -#else -#if __cplusplus >= 201402L using namespace std::chrono_literals; -#else -#include "../vmisc/bpstd/chrono.hpp" -using namespace bpstd::literals::chrono_literals; -#endif // __cplusplus >= 201402L -#endif //(defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) #if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) #include "../vmisc/compatibility.h" @@ -432,7 +414,7 @@ VPMainWindow::VPMainWindow(const VPCommandLinePtr &cmd, QWidget *parent) if (m_cmd->IsGuiEnabled()) { - QTimer::singleShot(V_SECONDS(1), this, &VPMainWindow::AskDefaultSettings); + QTimer::singleShot(1s, this, &VPMainWindow::AskDefaultSettings); } if (VAbstractShortcutManager *manager = VAbstractApplication::VApp()->GetShortcutManager()) @@ -3483,15 +3465,6 @@ void VPMainWindow::ShowToolTip(const QString &toolTip) //--------------------------------------------------------------------------------------------------------------------- void VPMainWindow::closeEvent(QCloseEvent *event) { -#if defined(Q_OS_MAC) && QT_VERSION < QT_VERSION_CHECK(5, 11, 1) - // Workaround for Qt bug https://bugreports.qt.io/browse/QTBUG-43344 - static int numCalled = 0; - if (numCalled++ >= 1) - { - return; - } -#endif - if (MaybeSave()) { WriteSettings(); diff --git a/src/app/puzzle/vptilefactory.cpp b/src/app/puzzle/vptilefactory.cpp index 0cc973645..90154e381 100644 --- a/src/app/puzzle/vptilefactory.cpp +++ b/src/app/puzzle/vptilefactory.cpp @@ -102,11 +102,6 @@ auto TriangleBasic() -> QPainterPath } } // namespace -// See https://stackoverflow.com/a/46719572/3045403 -#if __cplusplus < 201703L // C++17 -constexpr qreal VPTileFactory::tileStripeWidth; // NOLINT(readability-redundant-declaration) -#endif - //--------------------------------------------------------------------------------------------------------------------- VPTileFactory::VPTileFactory(const VPLayoutPtr &layout, VCommonSettings *commonSettings, QObject *parent) : QObject(parent), @@ -359,7 +354,7 @@ void VPTileFactory::DrawRuler(QPainter *painter, qreal scale) const qreal unitsWidth = 0; QFontMetrics fm(fnt); QString units = rulerUnits != Unit::Inch ? tr("cm", "unit") : tr("in", "unit"); - unitsWidth = TextWidth(fm, units); + unitsWidth = fm.horizontalAdvance(units); painter->drawText(QPointF(step * 0.5 - unitsWidth * 0.6, m_drawingAreaHeight - tileStripeWidth + notchHeight + shortNotchHeight), units); @@ -629,7 +624,7 @@ void VPTileFactory::DrawTextInformation(QPainter *painter, int row, int col, int td.setPageSize(QSizeF(m_drawingAreaHeight - UnitConvertor(2, Unit::Cm, Unit::Px), m_drawingAreaWidth)); QFontMetrics metrix = QFontMetrics(td.defaultFont()); - int maxWidth = TextWidth(metrix, QString().fill('z', 50)); + int maxWidth = metrix.horizontalAdvance(QString().fill('z', 50)); QString clippedSheetName = metrix.elidedText(sheetName, Qt::ElideMiddle, maxWidth); td.setHtml(QStringLiteral("" @@ -754,11 +749,7 @@ void VPTileFactory::PaintWatermarkImage(QPainter *painter, const QRectF &img, co return; } -#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) - qint64 fileSize = watermarkImage.byteCount(); -#else qint64 fileSize = watermarkImage.sizeInBytes(); -#endif qint64 pixelSize = fileSize / watermarkImage.height() / watermarkImage.width(); QSize scaledSize(qRound(watermarkImage.width() / xScale), qRound(watermarkImage.height() / yScale)); qint64 scaledImageSize = pixelSize * scaledSize.width() * scaledSize.height() / 1024; diff --git a/src/app/puzzle/vptilefactory.h b/src/app/puzzle/vptilefactory.h index d05d072dd..a5a729029 100644 --- a/src/app/puzzle/vptilefactory.h +++ b/src/app/puzzle/vptilefactory.h @@ -35,10 +35,6 @@ #include "../ifc/ifcdef.h" #include "layout/layoutdef.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - class QGraphicsScene; class VCommonSettings; class QPainter; diff --git a/src/app/puzzle/vpuzzleshortcutmanager.h b/src/app/puzzle/vpuzzleshortcutmanager.h index faa2d1a88..7302713dd 100644 --- a/src/app/puzzle/vpuzzleshortcutmanager.h +++ b/src/app/puzzle/vpuzzleshortcutmanager.h @@ -30,10 +30,6 @@ #include "../vmisc/vabstractshortcutmanager.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class VPuzzleShortcutManager : public VAbstractShortcutManager { Q_OBJECT // NOLINT diff --git a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp index 1c3a7e4ba..4c8291017 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp +++ b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.cpp @@ -37,10 +37,6 @@ #include "../vmisc/vabstractshortcutmanager.h" #include "ui_tapepreferencesconfigurationpage.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - #include //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.h b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.h index 45c57110d..0c13129f2 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.h +++ b/src/app/tape/dialogs/configpages/tapepreferencesconfigurationpage.h @@ -31,10 +31,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class QComboBox; namespace Ui diff --git a/src/app/tape/dialogs/configpages/tapepreferencespathpage.h b/src/app/tape/dialogs/configpages/tapepreferencespathpage.h index 108782f61..2d934ef98 100644 --- a/src/app/tape/dialogs/configpages/tapepreferencespathpage.h +++ b/src/app/tape/dialogs/configpages/tapepreferencespathpage.h @@ -30,10 +30,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace Ui { class TapePreferencesPathPage; diff --git a/src/app/tape/dialogs/dialogabouttape.h b/src/app/tape/dialogs/dialogabouttape.h index 0a9057eac..024c190fb 100644 --- a/src/app/tape/dialogs/dialogabouttape.h +++ b/src/app/tape/dialogs/dialogabouttape.h @@ -31,10 +31,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace Ui { class DialogAboutTape; diff --git a/src/app/tape/dialogs/dialogdimensioncustomnames.h b/src/app/tape/dialogs/dialogdimensioncustomnames.h index 53e2d38ba..44db142b6 100644 --- a/src/app/tape/dialogs/dialogdimensioncustomnames.h +++ b/src/app/tape/dialogs/dialogdimensioncustomnames.h @@ -32,10 +32,6 @@ #include "../vformat/vdimensions.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - namespace Ui { class DialogDimensionCustomNames; @@ -46,7 +42,7 @@ class DialogDimensionCustomNames : public QDialog Q_OBJECT // NOLINT public: - explicit DialogDimensionCustomNames(const QMap &dimensions, + explicit DialogDimensionCustomNames(const QMap &dimensions, QWidget *parent = nullptr); ~DialogDimensionCustomNames() override; diff --git a/src/app/tape/dialogs/dialogdimensionlabels.cpp b/src/app/tape/dialogs/dialogdimensionlabels.cpp index cb5d5ee9e..bfaa1f19c 100644 --- a/src/app/tape/dialogs/dialogdimensionlabels.cpp +++ b/src/app/tape/dialogs/dialogdimensionlabels.cpp @@ -27,17 +27,14 @@ *************************************************************************/ #include "dialogdimensionlabels.h" #include "ui_dialogdimensionlabels.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) //--------------------------------------------------------------------------------------------------------------------- DialogDimensionLabels::DialogDimensionLabels(const QMap &dimensions, bool fullCircumference, QWidget *parent) - : QDialog(parent), - ui(new Ui::DialogDimensionLabels), - m_dimensions(dimensions), - m_fullCircumference(fullCircumference) + : QDialog(parent), + ui(new Ui::DialogDimensionLabels), + m_dimensions(dimensions), + m_fullCircumference(fullCircumference) { ui->setupUi(this); @@ -119,7 +116,7 @@ void DialogDimensionLabels::InitLabels() const QList dimensions = m_dimensions.values(); - for(const auto &dimension : dimensions) + for (const auto &dimension : dimensions) { m_labels.insert(dimension->Type(), dimension->Labels()); } @@ -131,7 +128,7 @@ void DialogDimensionLabels::InitDimensions() ui->comboBoxDimensionLabels->blockSignals(true); ui->comboBoxDimensionLabels->clear(); - for(auto &dimension : m_dimensions) + for (auto &dimension : m_dimensions) { ui->comboBoxDimensionLabels->addItem(dimension->Name(), static_cast(dimension->Type())); } @@ -166,7 +163,7 @@ void DialogDimensionLabels::InitTable() const DimesionLabels labels = m_labels.value(type); - for(int row = 0; row < bases.size(); ++row) + for (int row = 0; row < bases.size(); ++row) { const qreal base = bases.at(row); @@ -208,16 +205,15 @@ auto DialogDimensionLabels::DimensionValue(const MeasurementDimension_p &dimensi { if (dimension->IsBodyMeasurement()) { - return QString::number(m_fullCircumference ? value*2 : value); + return QString::number(m_fullCircumference ? value * 2 : value); } return QString::number(value); - } if (dimension->Type() == MeasurementDimension::W || dimension->Type() == MeasurementDimension::Z) { - return QString::number(m_fullCircumference ? value*2 : value); + return QString::number(m_fullCircumference ? value * 2 : value); } return QString::number(value); diff --git a/src/app/tape/dialogs/dialogknownmeasurementscsvcolumns.cpp b/src/app/tape/dialogs/dialogknownmeasurementscsvcolumns.cpp index d5ffc9eec..1ad3e4099 100644 --- a/src/app/tape/dialogs/dialogknownmeasurementscsvcolumns.cpp +++ b/src/app/tape/dialogs/dialogknownmeasurementscsvcolumns.cpp @@ -29,9 +29,6 @@ #include "ui_dialogknownmeasurementscsvcolumns.h" #include "../vmisc/qxtcsvmodel.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../vtools/dialogs/dialogtoolbox.h" #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) diff --git a/src/app/tape/dialogs/dialogknownmeasurementscsvcolumns.h b/src/app/tape/dialogs/dialogknownmeasurementscsvcolumns.h index ca082b503..76a81a9f1 100644 --- a/src/app/tape/dialogs/dialogknownmeasurementscsvcolumns.h +++ b/src/app/tape/dialogs/dialogknownmeasurementscsvcolumns.h @@ -30,10 +30,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class QxtCsvModel; class QComboBox; diff --git a/src/app/tape/dialogs/dialogmdatabase.h b/src/app/tape/dialogs/dialogmdatabase.h index 45e6eb50e..7a6ec0e8a 100644 --- a/src/app/tape/dialogs/dialogmdatabase.h +++ b/src/app/tape/dialogs/dialogmdatabase.h @@ -32,10 +32,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace Ui { class DialogMDataBase; diff --git a/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp b/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp index b839a9cab..57776766b 100644 --- a/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp +++ b/src/app/tape/dialogs/dialogmeasurementscsvcolumns.cpp @@ -27,12 +27,8 @@ *************************************************************************/ #include "dialogmeasurementscsvcolumns.h" #include "../vmisc/qxtcsvmodel.h" -#include "ui_dialogmeasurementscsvcolumns.h" - -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../vtools/dialogs/dialogtoolbox.h" +#include "ui_dialogmeasurementscsvcolumns.h" #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #include "../vmisc/vtextcodec.h" diff --git a/src/app/tape/dialogs/dialogrestrictdimension.cpp b/src/app/tape/dialogs/dialogrestrictdimension.cpp index bb9a9ad90..3b182675d 100644 --- a/src/app/tape/dialogs/dialogrestrictdimension.cpp +++ b/src/app/tape/dialogs/dialogrestrictdimension.cpp @@ -33,9 +33,6 @@ #include "../vpatterndb/variables/vmeasurement.h" #include "../vwidgets/vdecorationaligningdelegate.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) #include "../vmisc/compatibility.h" diff --git a/src/app/tape/dialogs/dialogsetupmultisize.cpp b/src/app/tape/dialogs/dialogsetupmultisize.cpp index 811647df9..2ebf0e71a 100644 --- a/src/app/tape/dialogs/dialogsetupmultisize.cpp +++ b/src/app/tape/dialogs/dialogsetupmultisize.cpp @@ -31,11 +31,6 @@ #include #include -#include "../mapplication.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - namespace { void InitDimensionTitle(QGroupBox *group, const MeasurementDimension_p &dimension) @@ -43,11 +38,11 @@ void InitDimensionTitle(QGroupBox *group, const MeasurementDimension_p &dimensio SCASSERT(group != nullptr) group->setTitle(QStringLiteral("%1 (%2)").arg(dimension->Name(), dimension->Axis())); } -} +} // namespace //--------------------------------------------------------------------------------------------------------------------- -DialogSetupMultisize::DialogSetupMultisize(Unit unit, QWidget *parent) : - QDialog(parent), +DialogSetupMultisize::DialogSetupMultisize(Unit unit, QWidget *parent) + : QDialog(parent), ui(new Ui::DialogSetupMultisize), m_xDimension(QSharedPointer::create(unit)), m_yDimension(QSharedPointer::create(unit)), @@ -64,150 +59,133 @@ DialogSetupMultisize::DialogSetupMultisize(Unit unit, QWidget *parent) : InitZDimension(); // height - connect(ui->doubleSpinBoxXDimensionMinValue, QOverload::of(&QDoubleSpinBox::valueChanged), - this, [this](qreal value) + connect(ui->doubleSpinBoxXDimensionMinValue, QOverload::of(&QDoubleSpinBox::valueChanged), this, + [this](qreal value) { DimensionMinValueChanged(value, ui->doubleSpinBoxXDimensionMaxValue, ui->comboBoxXDimensionStep, ui->comboBoxXDimensionBase, m_xDimension); }); - connect(ui->doubleSpinBoxXDimensionMaxValue, QOverload::of(&QDoubleSpinBox::valueChanged), - this, [this](qreal value) + connect(ui->doubleSpinBoxXDimensionMaxValue, QOverload::of(&QDoubleSpinBox::valueChanged), this, + [this](qreal value) { DimensionMaxValueChanged(value, ui->doubleSpinBoxXDimensionMinValue, ui->comboBoxXDimensionStep, ui->comboBoxXDimensionBase, m_xDimension); }); - connect(ui->comboBoxXDimensionStep, QOverload::of(&QComboBox::currentIndexChanged), - this, [this](int index) - { - DimensionStepChanged(index, ui->comboBoxXDimensionStep, ui->comboBoxXDimensionBase, m_xDimension); - }); - connect(ui->comboBoxXDimensionBase, QOverload::of(&QComboBox::currentIndexChanged), - this, [this](int index) - { - DimensionBaseChanged(index, ui->comboBoxXDimensionBase, m_xDimension); - }); + connect(ui->comboBoxXDimensionStep, QOverload::of(&QComboBox::currentIndexChanged), this, + [this](int index) + { DimensionStepChanged(index, ui->comboBoxXDimensionStep, ui->comboBoxXDimensionBase, m_xDimension); }); + connect(ui->comboBoxXDimensionBase, QOverload::of(&QComboBox::currentIndexChanged), this, + [this](int index) { DimensionBaseChanged(index, ui->comboBoxXDimensionBase, m_xDimension); }); // size - connect(ui->doubleSpinBoxYDimensionMinValue, QOverload::of(&QDoubleSpinBox::valueChanged), - this, [this](qreal value) + connect(ui->doubleSpinBoxYDimensionMinValue, QOverload::of(&QDoubleSpinBox::valueChanged), this, + [this](qreal value) { DimensionMinValueChanged(value, ui->doubleSpinBoxYDimensionMaxValue, ui->comboBoxYDimensionStep, ui->comboBoxYDimensionBase, m_yDimension); }); - connect(ui->doubleSpinBoxYDimensionMaxValue, QOverload::of(&QDoubleSpinBox::valueChanged), - this, [this](qreal value) + connect(ui->doubleSpinBoxYDimensionMaxValue, QOverload::of(&QDoubleSpinBox::valueChanged), this, + [this](qreal value) { DimensionMaxValueChanged(value, ui->doubleSpinBoxYDimensionMinValue, ui->comboBoxYDimensionStep, ui->comboBoxYDimensionBase, m_yDimension); }); - connect(ui->comboBoxYDimensionStep, QOverload::of(&QComboBox::currentIndexChanged), - this, [this](int index) - { - DimensionStepChanged(index, ui->comboBoxYDimensionStep, ui->comboBoxYDimensionBase, m_yDimension); - }); - connect(ui->comboBoxYDimensionBase, QOverload::of(&QComboBox::currentIndexChanged), - this, [this](int index) - { - DimensionBaseChanged(index, ui->comboBoxYDimensionBase, m_yDimension); - }); + connect(ui->comboBoxYDimensionStep, QOverload::of(&QComboBox::currentIndexChanged), this, + [this](int index) + { DimensionStepChanged(index, ui->comboBoxYDimensionStep, ui->comboBoxYDimensionBase, m_yDimension); }); + connect(ui->comboBoxYDimensionBase, QOverload::of(&QComboBox::currentIndexChanged), this, + [this](int index) { DimensionBaseChanged(index, ui->comboBoxYDimensionBase, m_yDimension); }); // hip - connect(ui->doubleSpinBoxWDimensionMinValue, QOverload::of(&QDoubleSpinBox::valueChanged), - this, [this](qreal value) + connect(ui->doubleSpinBoxWDimensionMinValue, QOverload::of(&QDoubleSpinBox::valueChanged), this, + [this](qreal value) { DimensionMinValueChanged(value, ui->doubleSpinBoxWDimensionMaxValue, ui->comboBoxWDimensionStep, ui->comboBoxWDimensionBase, m_wDimension); }); - connect(ui->doubleSpinBoxWDimensionMaxValue, QOverload::of(&QDoubleSpinBox::valueChanged), - this, [this](qreal value) + connect(ui->doubleSpinBoxWDimensionMaxValue, QOverload::of(&QDoubleSpinBox::valueChanged), this, + [this](qreal value) { DimensionMaxValueChanged(value, ui->doubleSpinBoxWDimensionMinValue, ui->comboBoxWDimensionStep, ui->comboBoxWDimensionBase, m_wDimension); }); - connect(ui->comboBoxWDimensionStep, QOverload::of(&QComboBox::currentIndexChanged), - this, [this](int index) - { - DimensionStepChanged(index, ui->comboBoxWDimensionStep, ui->comboBoxWDimensionBase, m_wDimension); - }); - connect(ui->comboBoxWDimensionBase, QOverload::of(&QComboBox::currentIndexChanged), - this, [this](int index) - { - DimensionBaseChanged(index, ui->comboBoxWDimensionBase, m_wDimension); - }); + connect(ui->comboBoxWDimensionStep, QOverload::of(&QComboBox::currentIndexChanged), this, + [this](int index) + { DimensionStepChanged(index, ui->comboBoxWDimensionStep, ui->comboBoxWDimensionBase, m_wDimension); }); + connect(ui->comboBoxWDimensionBase, QOverload::of(&QComboBox::currentIndexChanged), this, + [this](int index) { DimensionBaseChanged(index, ui->comboBoxWDimensionBase, m_wDimension); }); // waist - connect(ui->doubleSpinBoxZDimensionMinValue, QOverload::of(&QDoubleSpinBox::valueChanged), - this, [this](qreal value) + connect(ui->doubleSpinBoxZDimensionMinValue, QOverload::of(&QDoubleSpinBox::valueChanged), this, + [this](qreal value) { DimensionMinValueChanged(value, ui->doubleSpinBoxZDimensionMaxValue, ui->comboBoxZDimensionStep, ui->comboBoxZDimensionBase, m_zDimension); }); - connect(ui->doubleSpinBoxZDimensionMaxValue, QOverload::of(&QDoubleSpinBox::valueChanged), - this, [this](qreal value) + connect(ui->doubleSpinBoxZDimensionMaxValue, QOverload::of(&QDoubleSpinBox::valueChanged), this, + [this](qreal value) { DimensionMaxValueChanged(value, ui->doubleSpinBoxZDimensionMinValue, ui->comboBoxZDimensionStep, ui->comboBoxZDimensionBase, m_zDimension); }); - connect(ui->comboBoxZDimensionStep, QOverload::of(&QComboBox::currentIndexChanged), - this, [this](int index) + connect(ui->comboBoxZDimensionStep, QOverload::of(&QComboBox::currentIndexChanged), this, + [this](int index) + { DimensionStepChanged(index, ui->comboBoxZDimensionStep, ui->comboBoxZDimensionBase, m_zDimension); }); + connect(ui->comboBoxZDimensionBase, QOverload::of(&QComboBox::currentIndexChanged), this, + [this](int index) { DimensionBaseChanged(index, ui->comboBoxZDimensionBase, m_zDimension); }); + + connect(ui->groupBoxXDimension, &QGroupBox::clicked, this, [this]() { CheckState(); }); + connect(ui->groupBoxYDimension, &QGroupBox::clicked, this, [this]() { CheckState(); }); + connect(ui->groupBoxWDimension, &QGroupBox::clicked, this, [this]() { CheckState(); }); + connect(ui->groupBoxZDimension, &QGroupBox::clicked, this, [this]() { CheckState(); }); + + connect(ui->checkBoxFullCircumference, &QCheckBox::stateChanged, this, + &DialogSetupMultisize::ShowFullCircumference); + + connect(ui->checkBoxXDimensionBodyMeasurement, &QCheckBox::stateChanged, this, + &DialogSetupMultisize::XDimensionBodyMeasurementChanged); + connect(ui->checkBoxYDimensionBodyMeasurement, &QCheckBox::stateChanged, this, + &DialogSetupMultisize::YDimensionBodyMeasurementChanged); + connect(ui->checkBoxWDimensionBodyMeasurement, &QCheckBox::stateChanged, this, + &DialogSetupMultisize::WDimensionBodyMeasurementChanged); + connect(ui->checkBoxZDimensionBodyMeasurement, &QCheckBox::stateChanged, this, + &DialogSetupMultisize::ZDimensionBodyMeasurementChanged); + + connect(ui->lineEditCustomXDimensionName, &QLineEdit::textChanged, this, + [this](const QString &text) { - DimensionStepChanged(index, ui->comboBoxZDimensionStep, ui->comboBoxZDimensionBase, m_zDimension); - }); - connect(ui->comboBoxZDimensionBase, QOverload::of(&QComboBox::currentIndexChanged), - this, [this](int index) - { - DimensionBaseChanged(index, ui->comboBoxZDimensionBase, m_zDimension); + m_xDimension->SetCustomName(text); + InitDimensionTitle(ui->groupBoxXDimension, m_xDimension); + + CheckState(); }); + connect(ui->lineEditCustomYDimensionName, &QLineEdit::textChanged, this, + [this](const QString &text) + { + m_yDimension->SetCustomName(text); + InitDimensionTitle(ui->groupBoxYDimension, m_yDimension); - connect(ui->groupBoxXDimension, &QGroupBox::clicked, this, [this](){CheckState();}); - connect(ui->groupBoxYDimension, &QGroupBox::clicked, this, [this](){CheckState();}); - connect(ui->groupBoxWDimension, &QGroupBox::clicked, this, [this](){CheckState();}); - connect(ui->groupBoxZDimension, &QGroupBox::clicked, this, [this](){CheckState();}); + CheckState(); + }); - connect(ui->checkBoxFullCircumference, &QCheckBox::stateChanged, - this, &DialogSetupMultisize::ShowFullCircumference); + connect(ui->lineEditCustomWDimensionName, &QLineEdit::textChanged, this, + [this](const QString &text) + { + m_wDimension->SetCustomName(text); + InitDimensionTitle(ui->groupBoxWDimension, m_wDimension); - connect(ui->checkBoxXDimensionBodyMeasurement, &QCheckBox::stateChanged, - this, &DialogSetupMultisize::XDimensionBodyMeasurementChanged); - connect(ui->checkBoxYDimensionBodyMeasurement, &QCheckBox::stateChanged, - this, &DialogSetupMultisize::YDimensionBodyMeasurementChanged); - connect(ui->checkBoxWDimensionBodyMeasurement, &QCheckBox::stateChanged, - this, &DialogSetupMultisize::WDimensionBodyMeasurementChanged); - connect(ui->checkBoxZDimensionBodyMeasurement, &QCheckBox::stateChanged, - this, &DialogSetupMultisize::ZDimensionBodyMeasurementChanged); + CheckState(); + }); - connect(ui->lineEditCustomXDimensionName, &QLineEdit::textChanged, this, [this](const QString &text) - { - m_xDimension->SetCustomName(text); - InitDimensionTitle(ui->groupBoxXDimension, m_xDimension); + connect(ui->lineEditCustomZDimensionName, &QLineEdit::textChanged, this, + [this](const QString &text) + { + m_zDimension->SetCustomName(text); + InitDimensionTitle(ui->groupBoxZDimension, m_zDimension); - CheckState(); - }); - - connect(ui->lineEditCustomYDimensionName, &QLineEdit::textChanged, this, [this](const QString &text) - { - m_yDimension->SetCustomName(text); - InitDimensionTitle(ui->groupBoxYDimension, m_yDimension); - - CheckState(); - }); - - connect(ui->lineEditCustomWDimensionName, &QLineEdit::textChanged, this, [this](const QString &text) - { - m_wDimension->SetCustomName(text); - InitDimensionTitle(ui->groupBoxWDimension, m_wDimension); - - CheckState(); - }); - - connect(ui->lineEditCustomZDimensionName, &QLineEdit::textChanged, this, [this](const QString &text) - { - m_zDimension->SetCustomName(text); - InitDimensionTitle(ui->groupBoxZDimension, m_zDimension); - - CheckState(); - }); + CheckState(); + }); CheckState(); } @@ -271,8 +249,8 @@ auto DialogSetupMultisize::FullCircumference() const -> bool //--------------------------------------------------------------------------------------------------------------------- void DialogSetupMultisize::showEvent(QShowEvent *event) { - QDialog::showEvent( event ); - if ( event->spontaneous() ) + QDialog::showEvent(event); + if (event->spontaneous()) { return; } @@ -286,15 +264,15 @@ void DialogSetupMultisize::showEvent(QShowEvent *event) setMaximumSize(size()); setMinimumSize(size()); - m_isInitialized = true;//first show windows are held + m_isInitialized = true; // first show windows are held } //--------------------------------------------------------------------------------------------------------------------- void DialogSetupMultisize::ShowFullCircumference() { auto ShowDimensionFullCircumference = [this](QDoubleSpinBox *doubleSpinBoxMinValue, - QDoubleSpinBox *doubleSpinBoxMaxValue, QComboBox *comboBoxStep, QComboBox *comboBoxBase, - const MeasurementDimension_p &dimension) + QDoubleSpinBox *doubleSpinBoxMaxValue, QComboBox *comboBoxStep, + QComboBox *comboBoxBase, const MeasurementDimension_p &dimension) { SCASSERT(doubleSpinBoxMinValue != nullptr) SCASSERT(doubleSpinBoxMaxValue != nullptr) @@ -498,24 +476,23 @@ void DialogSetupMultisize::InitDimensionMinMax(QDoubleSpinBox *doubleSpinBoxMinV doubleSpinBoxMinValue->blockSignals(true); doubleSpinBoxMinValue->setSuffix(unitStr); doubleSpinBoxMinValue->setDecimals(dimension->Units() == Unit::Mm ? 0 : 1); - doubleSpinBoxMinValue->setMinimum(m && fc ? dimension->RangeMin()*2 : dimension->RangeMin()); - doubleSpinBoxMinValue->setMaximum(m && fc ? dimension->MaxValue()*2 : dimension->MaxValue()); - doubleSpinBoxMinValue->setValue(m && fc ? dimension->MinValue()*2 : dimension->MinValue()); + doubleSpinBoxMinValue->setMinimum(m && fc ? dimension->RangeMin() * 2 : dimension->RangeMin()); + doubleSpinBoxMinValue->setMaximum(m && fc ? dimension->MaxValue() * 2 : dimension->MaxValue()); + doubleSpinBoxMinValue->setValue(m && fc ? dimension->MinValue() * 2 : dimension->MinValue()); doubleSpinBoxMinValue->blockSignals(false); doubleSpinBoxMaxValue->blockSignals(true); doubleSpinBoxMaxValue->setSuffix(unitStr); doubleSpinBoxMaxValue->setDecimals(dimension->Units() == Unit::Mm ? 0 : 1); - doubleSpinBoxMaxValue->setMinimum(m && fc ? dimension->MinValue()*2 : dimension->MinValue()); - doubleSpinBoxMaxValue->setMaximum(m && fc ? dimension->RangeMax()*2 : dimension->RangeMax()); - doubleSpinBoxMaxValue->setValue(m && fc ? dimension->RangeMax()*2 : dimension->RangeMax()); - doubleSpinBoxMaxValue->setValue(m && fc ? dimension->MaxValue()*2 : dimension->MaxValue()); + doubleSpinBoxMaxValue->setMinimum(m && fc ? dimension->MinValue() * 2 : dimension->MinValue()); + doubleSpinBoxMaxValue->setMaximum(m && fc ? dimension->RangeMax() * 2 : dimension->RangeMax()); + doubleSpinBoxMaxValue->setValue(m && fc ? dimension->RangeMax() * 2 : dimension->RangeMax()); + doubleSpinBoxMaxValue->setValue(m && fc ? dimension->MaxValue() * 2 : dimension->MaxValue()); doubleSpinBoxMaxValue->blockSignals(false); } //--------------------------------------------------------------------------------------------------------------------- -void DialogSetupMultisize::InitDimensionStep(QComboBox *comboBoxStep, - const MeasurementDimension_p &dimension) +void DialogSetupMultisize::InitDimensionStep(QComboBox *comboBoxStep, const MeasurementDimension_p &dimension) { SCASSERT(comboBoxStep != nullptr) @@ -528,9 +505,9 @@ void DialogSetupMultisize::InitDimensionStep(QComboBox *comboBoxStep, comboBoxStep->blockSignals(true); const QVector steps = dimension->ValidSteps(); comboBoxStep->clear(); - for(auto step : steps) + for (auto step : steps) { - comboBoxStep->addItem(QStringLiteral("%1%2").arg(m && fc ? step*2 : step).arg(unitStr), step); + comboBoxStep->addItem(QStringLiteral("%1%2").arg(m && fc ? step * 2 : step).arg(unitStr), step); } comboBoxStep->setCurrentIndex(-1); // force a user to select @@ -560,7 +537,7 @@ void DialogSetupMultisize::InitXDimension() //--------------------------------------------------------------------------------------------------------------------- void DialogSetupMultisize::InitYDimension() { - InitDimensionTitle(ui->groupBoxYDimension, m_yDimension); + InitDimensionTitle(ui->groupBoxYDimension, m_yDimension); InitDimension(ui->doubleSpinBoxYDimensionMinValue, ui->doubleSpinBoxYDimensionMaxValue, ui->comboBoxYDimensionStep, m_yDimension); } @@ -663,8 +640,7 @@ void DialogSetupMultisize::DimensionBaseChanged(int index, QComboBox *comboBoxBa } //--------------------------------------------------------------------------------------------------------------------- -void DialogSetupMultisize::UpdateSteps(QComboBox *comboBoxStep, - const MeasurementDimension_p &dimension) +void DialogSetupMultisize::UpdateSteps(QComboBox *comboBoxStep, const MeasurementDimension_p &dimension) { SCASSERT(comboBoxStep != nullptr) @@ -683,7 +659,7 @@ void DialogSetupMultisize::UpdateSteps(QComboBox *comboBoxStep, const bool m = dimension->IsBodyMeasurement(); const QString unitStr = m ? " " + UnitsToStr(dimension->Units()) : QString(); - for(auto step : steps) + for (auto step : steps) { comboBoxStep->addItem(QStringLiteral("%1%2").arg(m && fc ? step * 2 : step).arg(unitStr), step); } @@ -697,8 +673,7 @@ void DialogSetupMultisize::UpdateSteps(QComboBox *comboBoxStep, } //--------------------------------------------------------------------------------------------------------------------- -void DialogSetupMultisize::UpdateBase(QComboBox *comboBoxBase, - const MeasurementDimension_p &dimension) +void DialogSetupMultisize::UpdateBase(QComboBox *comboBoxBase, const MeasurementDimension_p &dimension) { SCASSERT(comboBoxBase != nullptr) @@ -716,7 +691,7 @@ void DialogSetupMultisize::UpdateBase(QComboBox *comboBoxBase, const bool m = dimension->IsBodyMeasurement(); const QString unitStr = m ? " " + UnitsToStr(dimension->Units()) : QString(); - for(auto base : bases) + for (auto base : bases) { comboBoxBase->addItem(QStringLiteral("%1%2").arg(m && fc ? base * 2 : base).arg(unitStr), base); } @@ -728,4 +703,3 @@ void DialogSetupMultisize::UpdateBase(QComboBox *comboBoxBase, const qreal base = comboBoxBase->currentData().toDouble(&ok); dimension->SetBaseValue(ok ? base : -1); } - diff --git a/src/app/tape/dialogs/dialogsetupmultisize.h b/src/app/tape/dialogs/dialogsetupmultisize.h index 908e9bdcf..8b156649b 100644 --- a/src/app/tape/dialogs/dialogsetupmultisize.h +++ b/src/app/tape/dialogs/dialogsetupmultisize.h @@ -33,10 +33,6 @@ #include "../vformat/vdimensions.h" #include "../vmisc/def.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - class QDoubleSpinBox; class QGroupBox; class QLineEdit; @@ -101,8 +97,7 @@ private: void DimensionStepChanged(int index, QComboBox *comboBoxStep, QComboBox *comboBoxBase, const MeasurementDimension_p &dimension); - void DimensionBaseChanged(int index, QComboBox *comboBoxBase, - const MeasurementDimension_p &dimension); + void DimensionBaseChanged(int index, QComboBox *comboBoxBase, const MeasurementDimension_p &dimension); void UpdateSteps(QComboBox *comboBoxStep, const MeasurementDimension_p &dimension); void UpdateBase(QComboBox *comboBoxBase, const MeasurementDimension_p &dimension); diff --git a/src/app/tape/dialogs/dialogtapepreferences.h b/src/app/tape/dialogs/dialogtapepreferences.h index 09521aa2e..72bfe9847 100644 --- a/src/app/tape/dialogs/dialogtapepreferences.h +++ b/src/app/tape/dialogs/dialogtapepreferences.h @@ -31,10 +31,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace Ui { class DialogTapePreferences; diff --git a/src/app/tape/main.cpp b/src/app/tape/main.cpp index f465e343f..522ae49df 100644 --- a/src/app/tape/main.cpp +++ b/src/app/tape/main.cpp @@ -32,12 +32,8 @@ #include #if defined(APPIMAGE) && defined(Q_OS_LINUX) -#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) -#include "../vmisc/backport/qscopeguard.h" -#else -#include -#endif #include "../vmisc/appimage.h" +#include #endif // defined(APPIMAGE) && defined(Q_OS_LINUX) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -119,11 +115,9 @@ auto main(int argc, char *argv[]) -> int MApplication app(argc, argv); app.InitOptions(); - QT_REQUIRE_VERSION(argc, argv, "5.6.0"); // clazy:exclude=qstring-arg,qstring-allocations NOLINT + QT_REQUIRE_VERSION(argc, argv, "5.15.0"); // clazy:exclude=qstring-arg,qstring-allocations NOLINT -#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) MApplication::setDesktopFileName(QStringLiteral("ua.com.smart-pattern.tape.desktop")); -#endif QTimer::singleShot(0, &app, &MApplication::ProcessCMD); diff --git a/src/app/tape/mapplication.cpp b/src/app/tape/mapplication.cpp index f4efe5ff9..fd50d48cd 100644 --- a/src/app/tape/mapplication.cpp +++ b/src/app/tape/mapplication.cpp @@ -155,26 +155,6 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con #endif // defined(V_NO_ASSERT) #if defined(Q_OS_MAC) -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - // Try hide very annoying, Qt related, warnings in Mac OS X - // QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton) - // https://bugreports.qt.io/browse/QTBUG-42846 - if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QNSView"))) - { - type = QtDebugMsg; - } -#endif - -#if QT_VERSION < QT_VERSION_CHECK(5, 9, 0) - // Hide Qt bug 'Assertion when reading an icns file' - // https://bugreports.qt.io/browse/QTBUG-45537 - // Remove after Qt fix will be released - if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QICNSHandler::read()"))) - { - type = QtDebugMsg; - } -#endif - // Hide anything that starts with QMacCGContext if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QMacCGContext::"))) { diff --git a/src/app/tape/tkmmainwindow.cpp b/src/app/tape/tkmmainwindow.cpp index 6eb37253a..761930843 100644 --- a/src/app/tape/tkmmainwindow.cpp +++ b/src/app/tape/tkmmainwindow.cpp @@ -69,20 +69,7 @@ #include #endif -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - -#if (defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) -// DO NOT WORK WITH GCC 4.8 -#else -#if __cplusplus >= 201402L using namespace std::chrono_literals; -#else -#include "../vmisc/bpstd/chrono.hpp" -using namespace bpstd::literals::chrono_literals; -#endif // __cplusplus >= 201402L -#endif //(defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wmissing-prototypes") @@ -145,7 +132,7 @@ TKMMainWindow::TKMMainWindow(QWidget *parent) if (MApplication::VApp()->IsAppInGUIMode()) { - QTimer::singleShot(V_SECONDS(1), this, &TKMMainWindow::AskDefaultSettings); + QTimer::singleShot(1s, this, &TKMMainWindow::AskDefaultSettings); } m_buttonShortcuts.insert(VShortcutAction::CaseSensitiveMatch, ui->toolButtonCaseSensitive); @@ -358,15 +345,6 @@ void TKMMainWindow::UpdateWindowTitle() //--------------------------------------------------------------------------------------------------------------------- void TKMMainWindow::closeEvent(QCloseEvent *event) { -#if defined(Q_OS_MAC) && QT_VERSION < QT_VERSION_CHECK(5, 11, 1) - // Workaround for Qt bug https://bugreports.qt.io/browse/QTBUG-43344 - static int numCalled = 0; - if (numCalled++ >= 1) - { - return; - } -#endif - if (MaybeSave()) { WriteSettings(); diff --git a/src/app/tape/tmainwindow.cpp b/src/app/tape/tmainwindow.cpp index ec63caa15..8e4eb2ebc 100644 --- a/src/app/tape/tmainwindow.cpp +++ b/src/app/tape/tmainwindow.cpp @@ -66,22 +66,12 @@ #include "vlitepattern.h" #include "vtapesettings.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #include "../vmisc/vtextcodec.h" #else #include #endif -#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) -#include "../vmisc/backport/qscopeguard.h" -#else -#include -#endif - #include #include #include @@ -91,21 +81,13 @@ #include #include #include +#include #include #include #include #include -#if (defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) -// DO NOT WORK WITH GCC 4.8 -#else -#if __cplusplus >= 201402L using namespace std::chrono_literals; -#else -#include "../vmisc/bpstd/chrono.hpp" -using namespace bpstd::literals::chrono_literals; -#endif // __cplusplus >= 201402L -#endif //(defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) #if defined(Q_OS_MAC) #include @@ -313,7 +295,7 @@ TMainWindow::TMainWindow(QWidget *parent) if (MApplication::VApp()->IsAppInGUIMode()) { - QTimer::singleShot(V_SECONDS(1), this, &TMainWindow::AskDefaultSettings); + QTimer::singleShot(1s, this, &TMainWindow::AskDefaultSettings); } m_buttonShortcuts.insert(VShortcutAction::CaseSensitiveMatch, ui->toolButtonCaseSensitive); @@ -732,15 +714,6 @@ void TMainWindow::ToolBarStyles() //--------------------------------------------------------------------------------------------------------------------- void TMainWindow::closeEvent(QCloseEvent *event) { -#if defined(Q_OS_MAC) && QT_VERSION < QT_VERSION_CHECK(5, 11, 1) - // Workaround for Qt bug https://bugreports.qt.io/browse/QTBUG-43344 - static int numCalled = 0; - if (numCalled++ >= 1) - { - return; - } -#endif - if (MaybeSave()) { WriteSettings(); @@ -3278,7 +3251,7 @@ void TMainWindow::InitDimensionGradation(int index, const MeasurementDimension_p int maxWidth = 0; for (int i = 0; i < control->count(); ++i) { - int itemWidth = TextWidth(fontMetrics, control->itemText(i)); + int itemWidth = fontMetrics.horizontalAdvance(control->itemText(i)); if (itemWidth > maxWidth) { maxWidth = itemWidth; diff --git a/src/app/tape/vtapeshortcutmanager.h b/src/app/tape/vtapeshortcutmanager.h index f0e14c651..5794edb9b 100644 --- a/src/app/tape/vtapeshortcutmanager.h +++ b/src/app/tape/vtapeshortcutmanager.h @@ -30,10 +30,6 @@ #include "../vmisc/vabstractshortcutmanager.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class VTapeShortcutManager : public VAbstractShortcutManager { Q_OBJECT // NOLINT diff --git a/src/app/valentina/core/vapplication.cpp b/src/app/valentina/core/vapplication.cpp index 32d46eaec..621473ade 100644 --- a/src/app/valentina/core/vapplication.cpp +++ b/src/app/valentina/core/vapplication.cpp @@ -45,13 +45,10 @@ #include "../vmisc/vvalentinasettings.h" #include "vvalentinashortcutmanager.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) -#include "../vmisc/backport/text.h" -#endif - #include "QtConcurrent/qtconcurrentrun.h" #include #include +#include #include #include #include @@ -60,6 +57,7 @@ #include #include #include +#include #include #include #include @@ -77,13 +75,6 @@ #define BUILD_REVISION VCS_REPO_STATE_REVISION #endif -#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) -#include "../vmisc/backport/qscopeguard.h" -#else -#include -#include -#endif - #if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) #include "../vmisc/compatibility.h" #endif @@ -181,26 +172,6 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con #endif // defined(V_NO_ASSERT) #if defined(Q_OS_MAC) -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - // Try hide very annoying, Qt related, warnings in Mac OS X - // QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton) - // https://bugreports.qt.io/browse/QTBUG-42846 - if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QNSView"))) - { - type = QtDebugMsg; - } -#endif - -#if QT_VERSION < QT_VERSION_CHECK(5, 9, 0) - // Hide Qt bug 'Assertion when reading an icns file' - // https://bugreports.qt.io/browse/QTBUG-45537 - // Remove after Qt fix will be released - if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QICNSHandler::read()"))) - { - type = QtDebugMsg; - } -#endif - // Hide anything that starts with QMacCGContext if ((type == QtWarningMsg) && msg.contains(QStringLiteral("QMacCGContext::"))) { @@ -645,11 +616,7 @@ void VApplication::ClearOldLogs() for (const auto &fn : allFiles) { QFileInfo info(fn); -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) const QDateTime created = info.birthTime(); -#else - const QDateTime created = info.created(); -#endif if (created.daysTo(QDateTime::currentDateTime()) >= DAYS_TO_KEEP_LOGS) { VLockGuard tmp(info.absoluteFilePath(), [&fn]() { return new QFile(fn); }); diff --git a/src/app/valentina/core/vformulapropertyeditor.h b/src/app/valentina/core/vformulapropertyeditor.h index 3dd949474..b445f496e 100644 --- a/src/app/valentina/core/vformulapropertyeditor.h +++ b/src/app/valentina/core/vformulapropertyeditor.h @@ -35,9 +35,6 @@ #include #include "../vpatterndb/vformula.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif class VFormulaPropertyEditor : public QWidget { diff --git a/src/app/valentina/core/vvalentinashortcutmanager.h b/src/app/valentina/core/vvalentinashortcutmanager.h index d099b96c4..a35494f05 100644 --- a/src/app/valentina/core/vvalentinashortcutmanager.h +++ b/src/app/valentina/core/vvalentinashortcutmanager.h @@ -30,10 +30,6 @@ #include "../vmisc/vabstractshortcutmanager.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class VValentinaShortcutManager : public VAbstractShortcutManager { Q_OBJECT // NOLINT diff --git a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp index 5eb780b16..2ec566c95 100644 --- a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.cpp @@ -35,16 +35,12 @@ #include "../vmisc/theme/vtheme.h" #include "../vmisc/vabstractshortcutmanager.h" #include "../vmisc/vvalentinasettings.h" -#include "qpushbutton.h" #include "ui_preferencesconfigurationpage.h" #include "vcommonsettings.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - #include #include +#include #include #include diff --git a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.h b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.h index 45c6d5dcb..1f52839a6 100644 --- a/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.h +++ b/src/app/valentina/dialogs/configpages/preferencesconfigurationpage.h @@ -31,10 +31,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace Ui { class PreferencesConfigurationPage; diff --git a/src/app/valentina/dialogs/configpages/preferencespathpage.h b/src/app/valentina/dialogs/configpages/preferencespathpage.h index 7d9067e81..0c2dede52 100644 --- a/src/app/valentina/dialogs/configpages/preferencespathpage.h +++ b/src/app/valentina/dialogs/configpages/preferencespathpage.h @@ -31,10 +31,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace Ui { class PreferencesPathPage; diff --git a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp index 922f26133..8b0fd0e54 100644 --- a/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp +++ b/src/app/valentina/dialogs/configpages/preferencespatternpage.cpp @@ -29,24 +29,21 @@ #include "preferencespatternpage.h" #include "../dialogdatetimeformats.h" #include "../dialogknownmaterials.h" +#include "../ifc/xml/vabstractpattern.h" +#include "../vformat/vsinglelineoutlinechar.h" #include "../vmisc/svgfont/vsvgfontdatabase.h" #include "../vmisc/vabstractvalapplication.h" #include "../vmisc/vvalentinasettings.h" +#include "../vwidgets/vmaingraphicsview.h" #include "svgfont/svgdef.h" #include "svgfont/vsvgfont.h" #include "svgfont/vsvgfontengine.h" #include "ui_preferencespatternpage.h" #include "vabstractapplication.h" -#include -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../ifc/xml/vabstractpattern.h" -#include "../vformat/vsinglelineoutlinechar.h" -#include "../vwidgets/vmaingraphicsview.h" #include #include +#include #include #include #include diff --git a/src/app/valentina/dialogs/dialogaboutapp.h b/src/app/valentina/dialogs/dialogaboutapp.h index 597c9e0f1..08c45812d 100644 --- a/src/app/valentina/dialogs/dialogaboutapp.h +++ b/src/app/valentina/dialogs/dialogaboutapp.h @@ -31,10 +31,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace Ui { class DialogAboutApp; diff --git a/src/app/valentina/dialogs/dialogaddbackgroundimage.h b/src/app/valentina/dialogs/dialogaddbackgroundimage.h index 6f77b99b6..91419af16 100644 --- a/src/app/valentina/dialogs/dialogaddbackgroundimage.h +++ b/src/app/valentina/dialogs/dialogaddbackgroundimage.h @@ -30,13 +30,9 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - namespace Ui { - class DialogAddBackgroundImage; +class DialogAddBackgroundImage; } class DialogAddBackgroundImage : public QDialog diff --git a/src/app/valentina/dialogs/dialogdatetimeformats.h b/src/app/valentina/dialogs/dialogdatetimeformats.h index 8b09fd60f..206d725f3 100644 --- a/src/app/valentina/dialogs/dialogdatetimeformats.h +++ b/src/app/valentina/dialogs/dialogdatetimeformats.h @@ -33,10 +33,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace Ui { class DialogDateTimeFormats; diff --git a/src/app/valentina/dialogs/dialogincrements.cpp b/src/app/valentina/dialogs/dialogincrements.cpp index 69c7deb21..ed081a0c2 100644 --- a/src/app/valentina/dialogs/dialogincrements.cpp +++ b/src/app/valentina/dialogs/dialogincrements.cpp @@ -27,14 +27,10 @@ *************************************************************************/ #include "dialogincrements.h" -#include "../vmisc/vvalentinasettings.h" -#include "ui_dialogincrements.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../qmuparser/qmudef.h" #include "../qmuparser/qmutokenparser.h" #include "../vmisc/theme/vtheme.h" +#include "../vmisc/vvalentinasettings.h" #include "../vpatterndb/calculator.h" #include "../vpatterndb/variables/varcradius.h" #include "../vpatterndb/variables/vcurveangle.h" @@ -45,6 +41,7 @@ #include "../vpatterndb/variables/vlinelength.h" #include "../vpatterndb/vtranslatevars.h" #include "../vtools/dialogs/support/dialogeditwrongformula.h" +#include "ui_dialogincrements.h" #include #include @@ -2106,9 +2103,6 @@ DialogIncrements::~DialogIncrements() //--------------------------------------------------------------------------------------------------------------------- void DialogIncrements::RestoreAfterClose() { - // Because of bug on Mac OS with Qt 5.11 closing this dialog causes a crash. Instead of closing we will keep - // dialog in memory and reuse it again. This function redo some moves made after close. - connect(this->m_doc, &VPattern::FullUpdateFromFile, this, &DialogIncrements::FullUpdateFromFile); ui->tabWidget->setCurrentIndex(0); diff --git a/src/app/valentina/dialogs/dialogknownmaterials.h b/src/app/valentina/dialogs/dialogknownmaterials.h index d7518ddef..db8eba2f0 100644 --- a/src/app/valentina/dialogs/dialogknownmaterials.h +++ b/src/app/valentina/dialogs/dialogknownmaterials.h @@ -31,10 +31,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace Ui { class DialogKnownMaterials; diff --git a/src/app/valentina/dialogs/dialoglayoutprogress.cpp b/src/app/valentina/dialogs/dialoglayoutprogress.cpp index 605e355dc..d399fcc4a 100644 --- a/src/app/valentina/dialogs/dialoglayoutprogress.cpp +++ b/src/app/valentina/dialogs/dialoglayoutprogress.cpp @@ -40,16 +40,7 @@ #include #include -#if (defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) -// DO NOT WORK WITH GCC 4.8 -#else -#if __cplusplus >= 201402L using namespace std::chrono_literals; -#else -#include "../vmisc/bpstd/chrono.hpp" -using namespace bpstd::literals::chrono_literals; -#endif // __cplusplus >= 201402L -#endif //(defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) //--------------------------------------------------------------------------------------------------------------------- DialogLayoutProgress::DialogLayoutProgress(QElapsedTimer timer, qint64 timeout, QWidget *parent) @@ -96,7 +87,7 @@ DialogLayoutProgress::DialogLayoutProgress(QElapsedTimer timer, qint64 timeout, m_progressTimer->stop(); } }); - m_progressTimer->start(V_SECONDS(1)); + m_progressTimer->start(1s); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/dialogs/dialoglayoutprogress.h b/src/app/valentina/dialogs/dialoglayoutprogress.h index 6aad786f2..cdb87f0ef 100644 --- a/src/app/valentina/dialogs/dialoglayoutprogress.h +++ b/src/app/valentina/dialogs/dialoglayoutprogress.h @@ -33,10 +33,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace Ui { class DialogLayoutProgress; diff --git a/src/app/valentina/dialogs/dialoglayoutsettings.cpp b/src/app/valentina/dialogs/dialoglayoutsettings.cpp index 6612af7fc..1c935dfdc 100644 --- a/src/app/valentina/dialogs/dialoglayoutsettings.cpp +++ b/src/app/valentina/dialogs/dialoglayoutsettings.cpp @@ -27,13 +27,10 @@ *************************************************************************/ #include "dialoglayoutsettings.h" +#include "../vlayout/vlayoutgenerator.h" #include "../vmisc/vabstractvalapplication.h" #include "../vmisc/vvalentinasettings.h" #include "ui_dialoglayoutsettings.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vlayout/vlayoutgenerator.h" #include #include diff --git a/src/app/valentina/dialogs/dialogpatternproperties.cpp b/src/app/valentina/dialogs/dialogpatternproperties.cpp index 1690adcb7..cc9a005e8 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.cpp +++ b/src/app/valentina/dialogs/dialogpatternproperties.cpp @@ -43,16 +43,13 @@ #include #include "../core/vapplication.h" +#include "../ifc/xml/utils.h" +#include "../ifc/xml/vpatternimage.h" +#include "../qmuparser/qmudef.h" #include "../vmisc/vabstractvalapplication.h" #include "../vmisc/vvalentinasettings.h" #include "../vpatterndb/vcontainer.h" #include "../xml/vpattern.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../ifc/xml/utils.h" -#include "../ifc/xml/vpatternimage.h" -#include "../qmuparser/qmudef.h" #if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) #include "../vmisc/compatibility.h" diff --git a/src/app/valentina/dialogs/dialogpatternproperties.h b/src/app/valentina/dialogs/dialogpatternproperties.h index 33a1b5245..63f105934 100644 --- a/src/app/valentina/dialogs/dialogpatternproperties.h +++ b/src/app/valentina/dialogs/dialogpatternproperties.h @@ -33,10 +33,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class VPattern; class VContainer; class QCheckBox; diff --git a/src/app/valentina/dialogs/dialogpreferences.h b/src/app/valentina/dialogs/dialogpreferences.h index 17f10a22c..27714cc75 100644 --- a/src/app/valentina/dialogs/dialogpreferences.h +++ b/src/app/valentina/dialogs/dialogpreferences.h @@ -31,10 +31,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace Ui { class DialogPreferences; diff --git a/src/app/valentina/dialogs/dialogsavelayout.cpp b/src/app/valentina/dialogs/dialogsavelayout.cpp index 29fb1dcb6..a2769981e 100644 --- a/src/app/valentina/dialogs/dialogsavelayout.cpp +++ b/src/app/valentina/dialogs/dialogsavelayout.cpp @@ -33,10 +33,6 @@ #include "../vmisc/vvalentinasettings.h" #include "ui_dialogsavelayout.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - #include #include #include diff --git a/src/app/valentina/dialogs/vwidgetbackgroundimages.cpp b/src/app/valentina/dialogs/vwidgetbackgroundimages.cpp index a42d8a38e..0fa76a88d 100644 --- a/src/app/valentina/dialogs/vwidgetbackgroundimages.cpp +++ b/src/app/valentina/dialogs/vwidgetbackgroundimages.cpp @@ -44,10 +44,6 @@ #include "../vtools/undocommands/image/zvaluemovebackgroundimage.h" #include "ui_vwidgetbackgroundimages.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - #include #include diff --git a/src/app/valentina/dialogs/vwidgetbackgroundimages.h b/src/app/valentina/dialogs/vwidgetbackgroundimages.h index 8954c355a..89673f582 100644 --- a/src/app/valentina/dialogs/vwidgetbackgroundimages.h +++ b/src/app/valentina/dialogs/vwidgetbackgroundimages.h @@ -30,10 +30,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - #include "../vmisc/def.h" class VAbstractPattern; @@ -41,10 +37,17 @@ class VBackgroundPatternImage; namespace Ui { - class VWidgetBackgroundImages; +class VWidgetBackgroundImages; } -enum class ScaleUnit {Percent, Mm, Cm, Inch, Px}; +enum class ScaleUnit +{ + Percent, + Mm, + Cm, + Inch, + Px +}; class VWidgetBackgroundImages : public QWidget { diff --git a/src/app/valentina/dialogs/vwidgetdetails.cpp b/src/app/valentina/dialogs/vwidgetdetails.cpp index 9bbd18b21..898776af6 100644 --- a/src/app/valentina/dialogs/vwidgetdetails.cpp +++ b/src/app/valentina/dialogs/vwidgetdetails.cpp @@ -40,16 +40,7 @@ #include #include -#if (defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) -// DO NOT WORK WITH GCC 4.8 -#else -#if __cplusplus >= 201402L using namespace std::chrono_literals; -#else -#include "../vmisc/bpstd/chrono.hpp" -using namespace bpstd::literals::chrono_literals; -#endif // __cplusplus >= 201402L -#endif //(defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) namespace { @@ -95,7 +86,7 @@ void VWidgetDetails::UpdateList() // The filling table is a very expensive operation. This optimization will postpone it. // Each time a new request happen we will wait 800 ms before calling it. If at this time a new request will arrive // we will wait 800 ms more. And so on, until nothing happens within 800ms. - m_updateListTimer->start(V_MSECONDS(800)); + m_updateListTimer->start(800ms); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/dialogs/vwidgetdetails.h b/src/app/valentina/dialogs/vwidgetdetails.h index 7de5cf531..a14ac6dfc 100644 --- a/src/app/valentina/dialogs/vwidgetdetails.h +++ b/src/app/valentina/dialogs/vwidgetdetails.h @@ -31,10 +31,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class VAbstractPattern; class VContainer; class VPiece; diff --git a/src/app/valentina/dialogs/vwidgetgroups.h b/src/app/valentina/dialogs/vwidgetgroups.h index b81a540d8..28e8a77f7 100644 --- a/src/app/valentina/dialogs/vwidgetgroups.h +++ b/src/app/valentina/dialogs/vwidgetgroups.h @@ -30,10 +30,8 @@ #define VWIDGETGROUPS_H #include "../vmisc/typedef.h" + #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif class QTableWidgetItem; class VAbstractPattern; diff --git a/src/app/valentina/main.cpp b/src/app/valentina/main.cpp index 1f969e96f..d824ac239 100644 --- a/src/app/valentina/main.cpp +++ b/src/app/valentina/main.cpp @@ -36,12 +36,8 @@ #include #if defined(APPIMAGE) && defined(Q_OS_LINUX) -#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) -#include "../vmisc/backport/qscopeguard.h" -#else -#include -#endif #include "../vmisc/appimage.h" +#include #endif // defined(APPIMAGE) && defined(Q_OS_LINUX) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -133,11 +129,9 @@ auto main(int argc, char *argv[]) -> int VApplication app(argc, argv); app.InitOptions(); - QT_REQUIRE_VERSION(argc, argv, "5.6.0") // clazy:exclude=qstring-arg,qstring-allocations NOLINT + QT_REQUIRE_VERSION(argc, argv, "5.15.0") // clazy:exclude=qstring-arg,qstring-allocations NOLINT -#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) VApplication::setDesktopFileName(QStringLiteral("ua.com.smart-pattern.valentina.desktop")); -#endif if (VApplication::IsGUIMode() && VAbstractApplication::VApp()->Settings()->IsAutomaticallyCheckUpdates()) { diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 94874bf5a..40b346749 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -202,21 +203,11 @@ #include #endif -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - -#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) -#include "../vmisc/backport/qscopeguard.h" -#else -#include -#endif - #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include #endif -#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include #include #endif @@ -226,16 +217,7 @@ #include #endif // defined(Q_OS_MAC) -#if (defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) -// DO NOT WORK WITH GCC 4.8 -#else -#if __cplusplus >= 201402L using namespace std::chrono_literals; -#else -#include "../vmisc/bpstd/chrono.hpp" -using namespace bpstd::literals::chrono_literals; -#endif // __cplusplus >= 201402L -#endif //(defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) #if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) #include "../vmisc/compatibility.h" @@ -403,7 +385,7 @@ MainWindow::MainWindow(QWidget *parent) connect(ui->actionExportFontCorrections, &QAction::triggered, this, &MainWindow::ActionExportFontCorrections); m_progressBar->setVisible(false); -#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) m_taskbarProgress->setVisible(false); #endif m_statusLabel->setText(tr("Create new pattern piece to start working.")); @@ -531,7 +513,7 @@ MainWindow::MainWindow(QWidget *parent) if (VApplication::IsGUIMode()) { - QTimer::singleShot(V_SECONDS(1), this, &MainWindow::AskDefaultSettings); + QTimer::singleShot(1s, this, &MainWindow::AskDefaultSettings); } ui->actionExportFontCorrections->setEnabled(settings->GetSingleStrokeOutlineFont()); @@ -1829,7 +1811,7 @@ void MainWindow::showEvent(QShowEvent *event) return; } -#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) m_taskbarButton->setWindow(windowHandle()); #endif @@ -1894,15 +1876,6 @@ void MainWindow::changeEvent(QEvent *event) */ void MainWindow::closeEvent(QCloseEvent *event) { -#if defined(Q_OS_MAC) && QT_VERSION < QT_VERSION_CHECK(5, 11, 1) - // Workaround for Qt bug https://bugreports.qt.io/browse/QTBUG-43344 - static int numCalled = 0; - if (numCalled++ >= 1) - { - return; - } -#endif - qCDebug(vMainWindow, "Closing main window"); if (MaybeSave()) { @@ -2235,7 +2208,7 @@ void MainWindow::MeasurementsChanged(const QString &path) { m_mChanges = true; m_mChangesAsked = false; - m_measurementsSyncTimer->start(V_MSECONDS(1500)); + m_measurementsSyncTimer->start(1500ms); } else { @@ -2245,7 +2218,7 @@ void MainWindow::MeasurementsChanged(const QString &path) { m_mChanges = true; m_mChangesAsked = false; - m_measurementsSyncTimer->start(V_MSECONDS(1500)); + m_measurementsSyncTimer->start(1500ms); break; } @@ -4498,7 +4471,7 @@ void MainWindow::Clear() m_toolOptions->ClearPropertyBrowser(); m_toolOptions->itemClicked(nullptr); m_progressBar->setVisible(false); -#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) m_taskbarProgress->setVisible(false); #endif m_statusLabel->setVisible(true); @@ -4914,7 +4887,7 @@ void MainWindow::ShowProgress() { const int newValue = m_progressBar->value() + 1; m_progressBar->setValue(newValue); -#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) m_taskbarProgress->setValue(newValue); #endif QCoreApplication::processEvents(); @@ -5393,7 +5366,7 @@ void MainWindow::InitDimensionGradation(int index, const MeasurementDimension_p int maxWidth = 0; for (int i = 0; i < control->count(); ++i) { - int itemWidth = TextWidth(fontMetrics, control->itemText(i)); + int itemWidth = fontMetrics.horizontalAdvance(control->itemText(i)); if (itemWidth > maxWidth) { maxWidth = itemWidth; @@ -6600,7 +6573,7 @@ auto MainWindow::LoadPattern(QString fileName, const QString &customMeasureFile) m_progressBar->setValue(0); const int elements = doc->ElementsToParse(); m_progressBar->setMaximum(elements); -#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) m_taskbarProgress->setVisible(true); m_taskbarProgress->setMaximum(elements); #endif @@ -6608,7 +6581,7 @@ auto MainWindow::LoadPattern(QString fileName, const QString &customMeasureFile) FullParseFile(); m_progressBar->setVisible(false); -#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) m_taskbarProgress->setVisible(false); #endif m_statusLabel->setVisible(true); @@ -6619,7 +6592,7 @@ auto MainWindow::LoadPattern(QString fileName, const QString &customMeasureFile) { /* Collect garbage only after successfully parse. This way wrongly accused items have one more time to * restore a reference. */ - QTimer::singleShot(V_MSECONDS(100), Qt::CoarseTimer, this, [this]() { doc->GarbageCollector(true); }); + QTimer::singleShot(100ms, Qt::CoarseTimer, this, [this]() { doc->GarbageCollector(true); }); } m_patternReadOnly = doc->IsReadOnly(); diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index efcc65412..9adc1981b 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -71,7 +71,7 @@ #include #include -#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include #include #endif @@ -134,14 +134,14 @@ MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent) : VAbstractMainWindow(parent), pattern(new VContainer(VAbstractApplication::VApp()->TrVars(), VAbstractValApplication::VApp()->patternUnitsP(), valentinaNamespace)) -#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) , m_taskbarButton(new QWinTaskbarButton(this)) #endif { InitTempLayoutScene(); -#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) m_taskbarButton->setWindow(this->windowHandle()); m_taskbarProgress = m_taskbarButton->progress(); m_taskbarProgress->setMinimum(0); @@ -193,14 +193,14 @@ auto MainWindowsNoGUI::GenerateLayout(VLayoutGenerator &lGenerator) -> bool QElapsedTimer timer; timer.start(); -#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QTimer *progressTimer = nullptr; #endif QSharedPointer progress; if (VApplication::IsGUIMode()) { -#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) m_taskbarProgress->setVisible(true); m_taskbarProgress->setValue(0); m_taskbarProgress->setMaximum(lGenerator.GetNestingTime() * 60); @@ -419,7 +419,7 @@ auto MainWindowsNoGUI::GenerateLayout(VLayoutGenerator &lGenerator) -> bool progress->Finished(); } -#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if defined(Q_OS_WIN32) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) if (VApplication::IsGUIMode()) { progressTimer->stop(); diff --git a/src/app/valentina/mainwindowsnogui.h b/src/app/valentina/mainwindowsnogui.h index b6a9883c6..fe93a1839 100644 --- a/src/app/valentina/mainwindowsnogui.h +++ b/src/app/valentina/mainwindowsnogui.h @@ -46,7 +46,7 @@ struct PosterData; class QGraphicsRectItem; class VMeasurements; -#if defined(Q_OS_WIN) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if defined(Q_OS_WIN) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) class QWinTaskbarButton; class QWinTaskbarProgress; #endif @@ -127,7 +127,7 @@ protected: QSharedPointer m_dialogSaveLayout{}; // NOLINT(misc-non-private-member-variables-in-classes) -#if defined(Q_OS_WIN) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) +#if defined(Q_OS_WIN) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QWinTaskbarButton *m_taskbarButton; // NOLINT(misc-non-private-member-variables-in-classes) QWinTaskbarProgress *m_taskbarProgress{nullptr}; // NOLINT(misc-non-private-member-variables-in-classes) #endif diff --git a/src/app/valentina/valentina.pro b/src/app/valentina/valentina.pro index 35f1e1e03..9804a59fa 100644 --- a/src/app/valentina/valentina.pro +++ b/src/app/valentina/valentina.pro @@ -377,45 +377,18 @@ win32:*g++* { package.files += $$[QT_INSTALL_BINS]/Qt5WinExtras.dll } - greaterThan(QT_MAJOR_VERSION, 4):greaterThan(QT_MINOR_VERSION, 10) { - versionAtLeast(QT_VERSION, 5.12.4){ - # Minimal supported OpenSSL version since Qt 5.12.4 is 1.1.1. - contains(QMAKE_HOST.arch, x86_64) { - package.files += \ - $$PWD/../../../dist/win/openssl/win64/libcrypto-1_1-x64.dll \ - $$PWD/../../../dist/win/openssl/win64/libssl-1_1-x64.dll - } else { - package.files += \ - $$PWD/../../../dist/win/openssl/win32/libcrypto-1_1.dll \ - $$PWD/../../../dist/win/openssl/win32/libssl-1_1.dll - } - } else { - package.files += \ - $$PWD/../../../dist/win/msvcr120.dll \ + package.files += \ + $$PWD/../../../dist/win/msvcr120.dll - contains(QMAKE_HOST.arch, x86_64) { - package.files += \ - $$PWD/../../../dist/win/openssl/win64/libeay32.dll \ - $$PWD/../../../dist/win/openssl/win64/ssleay32.dll - } else { - package.files += \ - $$PWD/../../../dist/win/openssl/win32/libeay32.dll \ - $$PWD/../../../dist/win/openssl/win32/ssleay32.dll - } - } + # Minimal supported OpenSSL version since Qt 5.12.4 is 1.1.1. + contains(QMAKE_HOST.arch, x86_64) { + package.files += \ + $$PWD/../../../dist/win/openssl/win64/libcrypto-1_1-x64.dll \ + $$PWD/../../../dist/win/openssl/win64/libssl-1_1-x64.dll } else { package.files += \ - $$PWD/../../../dist/win/msvcr120.dll \ - - contains(QMAKE_HOST.arch, x86_64) { - package.files += \ - $$PWD/../../../dist/win/openssl/win64/libeay32.dll \ - $$PWD/../../../dist/win/openssl/win64/ssleay32.dll - } else { - package.files += \ - $$PWD/../../../dist/win/openssl/win32/libeay32.dll \ - $$PWD/../../../dist/win/openssl/win32/ssleay32.dll - } + $$PWD/../../../dist/win/openssl/win32/libcrypto-1_1.dll \ + $$PWD/../../../dist/win/openssl/win32/libssl-1_1.dll } package.CONFIG = no_check_exist diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 5a1b900bf..a8a975aa0 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -103,16 +103,11 @@ #include "../vtools/tools/vtooluniondetails.h" #include "../vwidgets/vabstractmainwindow.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) -#include "../vmisc/backport/qscopeguard.h" -#else -#include -#endif - #include #include #include #include +#include #include #include #include @@ -121,16 +116,7 @@ #include #include -#if (defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) -// DO NOT WORK WITH GCC 4.8 -#else -#if __cplusplus >= 201402L using namespace std::chrono_literals; -#else -#include "../vmisc/bpstd/chrono.hpp" -using namespace bpstd::literals::chrono_literals; -#endif // __cplusplus >= 201402L -#endif //(defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) using namespace Qt::Literals::StringLiterals; @@ -291,7 +277,7 @@ void VPattern::Parse(const Document &parse) if (VApplication::IsGUIMode()) { - QTimer::singleShot(V_SECONDS(1), Qt::VeryCoarseTimer, this, &VPattern::RefreshPieceGeometry); + QTimer::singleShot(1s, Qt::VeryCoarseTimer, this, &VPattern::RefreshPieceGeometry); } else if (VApplication::CommandLine()->IsTestModeEnabled()) { diff --git a/src/libs/fervor/fvavailableupdate.h b/src/libs/fervor/fvavailableupdate.h index 1a89c26dc..f95d77042 100644 --- a/src/libs/fervor/fvavailableupdate.h +++ b/src/libs/fervor/fvavailableupdate.h @@ -28,10 +28,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class FvAvailableUpdate final : public QObject { Q_OBJECT // NOLINT diff --git a/src/libs/fervor/fvupdatewindow.h b/src/libs/fervor/fvupdatewindow.h index 80c9e9354..465bf8650 100644 --- a/src/libs/fervor/fvupdatewindow.h +++ b/src/libs/fervor/fvupdatewindow.h @@ -28,10 +28,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class QGraphicsScene; namespace Ui diff --git a/src/libs/qmuparser/qmudef.cpp b/src/libs/qmuparser/qmudef.cpp index 37dc2bb37..0c5da1ffe 100644 --- a/src/libs/qmuparser/qmudef.cpp +++ b/src/libs/qmuparser/qmudef.cpp @@ -457,11 +457,7 @@ auto LocaleSign0(const QLocale &locale) -> QChar const QString sign = locale.toString(0); if (sign.size() == 1) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return sign.front(); -#else - return sign.at(0); -#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -477,11 +473,7 @@ auto LocaleSign1(const QLocale &locale) -> QChar const QString sign = locale.toString(1); if (sign.size() == 1) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return sign.front(); -#else - return sign.at(0); -#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -497,11 +489,7 @@ auto LocaleSign2(const QLocale &locale) -> QChar const QString sign = locale.toString(2); if (sign.size() == 1) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return sign.front(); -#else - return sign.at(0); -#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -517,11 +505,7 @@ auto LocaleSign3(const QLocale &locale) -> QChar const QString sign = locale.toString(3); if (sign.size() == 1) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return sign.front(); -#else - return sign.at(0); -#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -537,11 +521,7 @@ auto LocaleSign4(const QLocale &locale) -> QChar const QString sign = locale.toString(4); if (sign.size() == 1) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return sign.front(); -#else - return sign.at(0); -#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -557,11 +537,7 @@ auto LocaleSign5(const QLocale &locale) -> QChar const QString sign = locale.toString(5); if (sign.size() == 1) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return sign.front(); -#else - return sign.at(0); -#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -577,11 +553,7 @@ auto LocaleSign6(const QLocale &locale) -> QChar const QString sign = locale.toString(6); if (sign.size() == 1) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return sign.front(); -#else - return sign.at(0); -#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -597,11 +569,7 @@ auto LocaleSign7(const QLocale &locale) -> QChar const QString sign = locale.toString(7); if (sign.size() == 1) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return sign.front(); -#else - return sign.at(0); -#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -617,11 +585,7 @@ auto LocaleSign8(const QLocale &locale) -> QChar const QString sign = locale.toString(8); if (sign.size() == 1) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return sign.front(); -#else - return sign.at(0); -#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -637,11 +601,7 @@ auto LocaleSign9(const QLocale &locale) -> QChar const QString sign = locale.toString(9); if (sign.size() == 1) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return sign.front(); -#else - return sign.at(0); -#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) diff --git a/src/libs/qmuparser/qmudef.h b/src/libs/qmuparser/qmudef.h index c8a773d02..dedea29eb 100644 --- a/src/libs/qmuparser/qmudef.h +++ b/src/libs/qmuparser/qmudef.h @@ -25,13 +25,6 @@ #include "qmuparser_global.h" #include "qmuparserdef.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#define Q_DISABLE_COPY_MOVE(Class) \ - Q_DISABLE_COPY(Class) \ - Class(Class &&) = delete; \ - Class &operator=(Class &&) = delete; -#endif - #ifndef Q_DISABLE_ASSIGN #define Q_DISABLE_ASSIGN(Class) Class &operator=(const Class &) = delete; #endif diff --git a/src/libs/qmuparser/qmuparser.cpp b/src/libs/qmuparser/qmuparser.cpp index 5159758f2..cc0290660 100644 --- a/src/libs/qmuparser/qmuparser.cpp +++ b/src/libs/qmuparser/qmuparser.cpp @@ -23,15 +23,15 @@ #include #include +#include #include +#include #include #include -#include -#include -#include "qmuparsererror.h" #include "../vmisc/defglobal.h" #include "qmudef.h" +#include "qmuparsererror.h" /** * @file @@ -64,13 +64,13 @@ auto CSR(qreal length, qreal split, qreal arcLength) -> qreal const QLineF line(QPointF(0, 0), QPointF(0, length)); QLineF tmp = line; - tmp.setAngle(tmp.angle()+90.0*sign); + tmp.setAngle(tmp.angle() + 90.0 * sign); tmp.setLength(split); QPointF p1 = tmp.p2(); tmp = QLineF(QPointF(0, length), QPointF(0, 0)); - tmp.setAngle(tmp.angle()-90.0*sign); + tmp.setAngle(tmp.angle() - 90.0 * sign); tmp.setLength(split); QPointF p2 = tmp.p2(); @@ -83,11 +83,11 @@ auto CSR(qreal length, qreal split, qreal arcLength) -> qreal { if (arcL > arcLength) { - angle = angle - angle/2.0; + angle = angle - angle / 2.0; } else if (arcL < arcLength) { - angle = angle + angle/2.0; + angle = angle + angle / 2.0; } else { @@ -100,28 +100,23 @@ auto CSR(qreal length, qreal split, qreal arcLength) -> qreal } tmp = line2; - tmp.setAngle(tmp.angle()+angle*sign); + tmp.setAngle(tmp.angle() + angle * sign); QPointF crosPoint; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) const auto type = line.intersects(tmp, &crosPoint); -#else - const auto type = line.intersect(tmp, &crosPoint); -#endif if (type == QLineF::NoIntersection) { return 0; } QLineF radius(crosPoint, tmp.p2()); - const qreal arcAngle = sign > 0 ? line.angleTo(radius): radius.angleTo(line); - arcL = (M_PI*radius.length())/180.0 * arcAngle; - } - while(qAbs(arcL - arcLength) > (0.5/*mm*/ / 25.4) * PrintDPI); + const qreal arcAngle = sign > 0 ? line.angleTo(radius) : radius.angleTo(line); + arcL = (M_PI * radius.length()) / 180.0 * arcAngle; + } while (qAbs(arcL - arcLength) > (0.5 /*mm*/ / 25.4) * PrintDPI); return angle; } -} +} // namespace /** * @brief Namespace for mathematical applications. @@ -132,13 +127,13 @@ namespace qmu // Trigonometric function auto QmuParser::DegreeToRadian(qreal deg) -> qreal { - return qDegreesToRadians(deg); + return qDegreesToRadians(deg); } //--------------------------------------------------------------------------------------------------------------------- auto QmuParser::RadianToDegree(qreal rad) -> qreal { - return qRadiansToDegrees(rad); + return qRadiansToDegrees(rad); } //--------------------------------------------------------------------------------------------------------------------- @@ -221,12 +216,12 @@ auto QmuParser::ATanD(qreal v) -> qreal auto QmuParser::Log2(qreal v) -> qreal { #ifdef MUP_MATH_EXCEPTIONS - if (v<=0) + if (v <= 0) { throw QmuParserError(ecDOMAIN_ERROR, "Log2"); } #endif - return log(v)/log(2.0); + return log(v) / log(2.0); } //--------------------------------------------------------------------------------------------------------------------- @@ -234,7 +229,7 @@ auto QmuParser::Log2(qreal v) -> qreal auto QmuParser::Log10(qreal v) -> qreal { #ifdef MUP_MATH_EXCEPTIONS - if (v<=0) + if (v <= 0) { throw QmuParserError(ecDOMAIN_ERROR, "Log10"); } @@ -258,7 +253,7 @@ auto QmuParser::Rint(qreal v) -> qreal //--------------------------------------------------------------------------------------------------------------------- auto QmuParser::R2CM(qreal v) -> qreal { - return Rint(v*10.0)/10.0; + return Rint(v * 10.0) / 10.0; } //--------------------------------------------------------------------------------------------------------------------- @@ -284,7 +279,7 @@ auto QmuParser::CSRInch(qreal length, qreal split, qreal arcLength) -> qreal //--------------------------------------------------------------------------------------------------------------------- auto QmuParser::Sign(qreal v) -> qreal { - return ((v<0) ? -1 : (v>0) ? 1 : 0); + return ((v < 0) ? -1 : (v > 0) ? 1 : 0); } //--------------------------------------------------------------------------------------------------------------------- @@ -303,11 +298,11 @@ auto QmuParser::Sum(const qreal *a_afArg, qmusizetype a_iArgc) -> qreal { if (a_iArgc == 0) { - throw QmuParserError(QCoreApplication::translate("QmuParser", "too few arguments for function sum.", - "parser error message")); + throw QmuParserError( + QCoreApplication::translate("QmuParser", "too few arguments for function sum.", "parser error message")); } - qreal fRes=0; - for (int i=0; i qreal { if (a_iArgc == 0) { - throw QmuParserError(QCoreApplication::translate("QmuParser", "too few arguments for function sum.", - "parser error message")); + throw QmuParserError( + QCoreApplication::translate("QmuParser", "too few arguments for function sum.", "parser error message")); } - qreal fRes=0; - for (int i=0; i(a_iArgc); + return fRes / static_cast(a_iArgc); } //--------------------------------------------------------------------------------------------------------------------- @@ -345,11 +340,11 @@ auto QmuParser::Min(const qreal *a_afArg, qmusizetype a_iArgc) -> qreal { if (a_iArgc == 0) { - throw QmuParserError(QCoreApplication::translate("QmuParser", "too few arguments for function min.", - "parser error message")); + throw QmuParserError( + QCoreApplication::translate("QmuParser", "too few arguments for function min.", "parser error message")); } - qreal fRes=a_afArg[0]; - for (int i=0; i qreal { if (a_iArgc == 0) { - throw QmuParserError(QCoreApplication::translate("QmuParser", "too few arguments for function min.", - "parser error message")); + throw QmuParserError( + QCoreApplication::translate("QmuParser", "too few arguments for function min.", "parser error message")); } - qreal fRes=a_afArg[0]; - for (int i=0; i qreal //--------------------------------------------------------------------------------------------------------------------- /** -* @brief Default value recognition callback. -* @param [in] a_szExpr Pointer to the expression -* @param [in, out] a_iPos Pointer to an index storing the current position within the expression -* @param [out] a_fVal Pointer where the value should be stored in case one is found. -* @return 1 if a value was found 0 otherwise. -*/ + * @brief Default value recognition callback. + * @param [in] a_szExpr Pointer to the expression + * @param [in, out] a_iPos Pointer to an index storing the current position within the expression + * @param [out] a_fVal Pointer where the value should be stored in case one is found. + * @return 1 if a value was found 0 otherwise. + */ auto QmuParser::IsVal(const QString &a_szExpr, qmusizetype *a_iPos, qreal *a_fVal, const QLocale &locale, bool cNumbers, const QChar &decimal, const QChar &thousand) -> int { qreal fVal(0); - qmusizetype pos = ReadVal(a_szExpr, fVal, locale != QLocale::c() && cNumbers ? QLocale::c() : locale, decimal, - thousand); + qmusizetype pos = + ReadVal(a_szExpr, fVal, locale != QLocale::c() && cNumbers ? QLocale::c() : locale, decimal, thousand); if (pos == -1) { @@ -409,7 +404,8 @@ auto QmuParser::IsVal(const QString &a_szExpr, qmusizetype *a_iPos, qreal *a_fVa * * Call QmuParserBase class constructor and trigger Function, Operator and Constant initialization. */ -QmuParser::QmuParser():QmuParserBase() +QmuParser::QmuParser() + : QmuParserBase() { AddValIdent(IsVal); @@ -426,9 +422,9 @@ QmuParser::QmuParser():QmuParserBase() */ void QmuParser::InitCharSets() { - DefineNameChars( QStringLiteral("0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") ); - DefineOprtChars( QStringLiteral("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-*^/?<>=#!$%&|~'_{}") ); - DefineInfixOprtChars( QStringLiteral("/+-*^?<>=#!$%&|~'_") ); + DefineNameChars(QStringLiteral("0123456789_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")); + DefineOprtChars(QStringLiteral("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+-*^/?<>=#!$%&|~'_{}")); + DefineInfixOprtChars(QStringLiteral("/+-*^?<>=#!$%&|~'_")); } //--------------------------------------------------------------------------------------------------------------------- @@ -438,76 +434,76 @@ void QmuParser::InitCharSets() void QmuParser::InitFun() { // trigonometric helper functions - DefineFun(QStringLiteral("degTorad"), DegreeToRadian); - DefineFun(QStringLiteral("radTodeg"), RadianToDegree); + DefineFun(QStringLiteral("degTorad"), DegreeToRadian); + DefineFun(QStringLiteral("radTodeg"), RadianToDegree); #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - #define QSIN_FUN qSin - #define QCOS_FUN qCos - #define QTAN_FUN qTan - #define QASIN_FUN qAsin - #define QACOS_FUN qAcos - #define QATAN_FUN qAtan - #define QATAN2_FUN qAtan2 - #define QLN_FUN qLn - #define QEXP_FUN qExp - #define QSQRT_FUN qSqrt +#define QSIN_FUN qSin +#define QCOS_FUN qCos +#define QTAN_FUN qTan +#define QASIN_FUN qAsin +#define QACOS_FUN qAcos +#define QATAN_FUN qAtan +#define QATAN2_FUN qAtan2 +#define QLN_FUN qLn +#define QEXP_FUN qExp +#define QSQRT_FUN qSqrt #else - #define QSIN_FUN qSin - #define QCOS_FUN qCos - #define QTAN_FUN qTan - #define QASIN_FUN qAsin - #define QACOS_FUN qAcos - #define QATAN_FUN qAtan - #define QATAN2_FUN qAtan2 - #define QLN_FUN qLn - #define QEXP_FUN qExp - #define QSQRT_FUN qSqrt +#define QSIN_FUN qSin +#define QCOS_FUN qCos +#define QTAN_FUN qTan +#define QASIN_FUN qAsin +#define QACOS_FUN qAcos +#define QATAN_FUN qAtan +#define QATAN2_FUN qAtan2 +#define QLN_FUN qLn +#define QEXP_FUN qExp +#define QSQRT_FUN qSqrt #endif // trigonometric functions - DefineFun(QStringLiteral("sin"), QSIN_FUN); - DefineFun(QStringLiteral("cos"), QCOS_FUN); - DefineFun(QStringLiteral("tan"), QTAN_FUN); + DefineFun(QStringLiteral("sin"), QSIN_FUN); + DefineFun(QStringLiteral("cos"), QCOS_FUN); + DefineFun(QStringLiteral("tan"), QTAN_FUN); DefineFun(QStringLiteral("sinD"), SinD); DefineFun(QStringLiteral("cosD"), CosD); DefineFun(QStringLiteral("tanD"), TanD); // arcus functions - DefineFun(QStringLiteral("asin"), QASIN_FUN); - DefineFun(QStringLiteral("acos"), QACOS_FUN); - DefineFun(QStringLiteral("atan"), QATAN_FUN); + DefineFun(QStringLiteral("asin"), QASIN_FUN); + DefineFun(QStringLiteral("acos"), QACOS_FUN); + DefineFun(QStringLiteral("atan"), QATAN_FUN); DefineFun(QStringLiteral("atan2"), QATAN2_FUN); DefineFun(QStringLiteral("asinD"), ASinD); DefineFun(QStringLiteral("acosD"), ACosD); DefineFun(QStringLiteral("atanD"), ATanD); // hyperbolic functions - DefineFun(QStringLiteral("sinh"), Sinh); - DefineFun(QStringLiteral("cosh"), Cosh); - DefineFun(QStringLiteral("tanh"), Tanh); + DefineFun(QStringLiteral("sinh"), Sinh); + DefineFun(QStringLiteral("cosh"), Cosh); + DefineFun(QStringLiteral("tanh"), Tanh); // arcus hyperbolic functions DefineFun(QStringLiteral("asinh"), ASinh); DefineFun(QStringLiteral("acosh"), ACosh); DefineFun(QStringLiteral("atanh"), ATanh); // Logarithm functions - DefineFun(QStringLiteral("log2"), Log2); + DefineFun(QStringLiteral("log2"), Log2); DefineFun(QStringLiteral("log10"), Log10); - DefineFun(QStringLiteral("log"), Log10); - DefineFun(QStringLiteral("ln"), QLN_FUN); + DefineFun(QStringLiteral("log"), Log10); + DefineFun(QStringLiteral("ln"), QLN_FUN); // misc - DefineFun(QStringLiteral("exp"), QEXP_FUN); - DefineFun(QStringLiteral("sqrt"), QSQRT_FUN); - DefineFun(QStringLiteral("sign"), Sign); - DefineFun(QStringLiteral("rint"), Rint); - DefineFun(QStringLiteral("r2cm"), R2CM); + DefineFun(QStringLiteral("exp"), QEXP_FUN); + DefineFun(QStringLiteral("sqrt"), QSQRT_FUN); + DefineFun(QStringLiteral("sign"), Sign); + DefineFun(QStringLiteral("rint"), Rint); + DefineFun(QStringLiteral("r2cm"), R2CM); DefineFun(QStringLiteral("csrCm"), CSRCm); DefineFun(QStringLiteral("csrInch"), CSRInch); - DefineFun(QStringLiteral("abs"), Abs); - DefineFun(QStringLiteral("fmod"), FMod); + DefineFun(QStringLiteral("abs"), Abs); + DefineFun(QStringLiteral("fmod"), FMod); // Functions with variable number of arguments - DefineFun(QStringLiteral("sum"), Sum); - DefineFun(QStringLiteral("avg"), Avg); - DefineFun(QStringLiteral("min"), Min); - DefineFun(QStringLiteral("max"), Max); + DefineFun(QStringLiteral("sum"), Sum); + DefineFun(QStringLiteral("avg"), Avg); + DefineFun(QStringLiteral("min"), Min); + DefineFun(QStringLiteral("max"), Max); } //--------------------------------------------------------------------------------------------------------------------- @@ -579,10 +575,7 @@ void QmuParser::OnDetectVar(const QString &pExpr, qmusizetype &nStart, qmusizety // cppcheck-suppress unusedFunction auto QmuParser::Diff(qreal *a_Var, qreal a_fPos, qreal a_fEpsilon) const -> qreal { - qreal fRes(0), - fBuf(*a_Var), - f[4] = {0, 0, 0, 0}, - fEpsilon(a_fEpsilon); + qreal fRes(0), fBuf(*a_Var), f[4] = {0, 0, 0, 0}, fEpsilon(a_fEpsilon); // Backwards compatible calculation of epsilon inc case the user doesnt provide // his own epsilon @@ -591,13 +584,17 @@ auto QmuParser::Diff(qreal *a_Var, qreal a_fPos, qreal a_fEpsilon) const -> qrea fEpsilon = qFuzzyIsNull(a_fPos) ? static_cast(1e-10) : static_cast(1e-7) * a_fPos; } - *a_Var = a_fPos+2 * fEpsilon; f[0] = Eval(); - *a_Var = a_fPos+1 * fEpsilon; f[1] = Eval(); - *a_Var = a_fPos-1 * fEpsilon; f[2] = Eval(); - *a_Var = a_fPos-2 * fEpsilon; f[3] = Eval(); + *a_Var = a_fPos + 2 * fEpsilon; + f[0] = Eval(); + *a_Var = a_fPos + 1 * fEpsilon; + f[1] = Eval(); + *a_Var = a_fPos - 1 * fEpsilon; + f[2] = Eval(); + *a_Var = a_fPos - 2 * fEpsilon; + f[3] = Eval(); *a_Var = fBuf; // restore variable - fRes = (-f[0] + 8*f[1] - 8*f[2] + f[3]) / (12*fEpsilon); + fRes = (-f[0] + 8 * f[1] - 8 * f[2] + f[3]) / (12 * fEpsilon); return fRes; } } // namespace qmu diff --git a/src/libs/qmuparser/qmuparser.pri b/src/libs/qmuparser/qmuparser.pri index e052ee11c..8c1c35787 100644 --- a/src/libs/qmuparser/qmuparser.pri +++ b/src/libs/qmuparser/qmuparser.pri @@ -34,5 +34,5 @@ HEADERS += \ $$PWD/qmuformulabase.h \ $$PWD/qmutokenparser.h \ $$PWD/qmuparsercallback_p.h \ - $$PWD/make_unique.h \ - $$PWD/text.h + $$PWD/make_unique.h + diff --git a/src/libs/qmuparser/qmuparser.qbs b/src/libs/qmuparser/qmuparser.qbs index b25547abd..18ae99468 100644 --- a/src/libs/qmuparser/qmuparser.qbs +++ b/src/libs/qmuparser/qmuparser.qbs @@ -32,7 +32,6 @@ VDynamicLib { "qmutokenparser.h", "qmuparsercallback_p.h", "make_unique.h", - "text.h" ] cpp.defines: ["QMUPARSER_LIBRARY", 'QMUP_VERSION="' + product.version + '"'] diff --git a/src/libs/qmuparser/qmuparserbase.cpp b/src/libs/qmuparser/qmuparserbase.cpp index 99097b619..32337498a 100644 --- a/src/libs/qmuparser/qmuparserbase.cpp +++ b/src/libs/qmuparser/qmuparserbase.cpp @@ -36,10 +36,6 @@ #include "qmudef.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) -#include "text.h" -#endif - /** * @file * @brief This file contains the basic implementation of the muparser engine. diff --git a/src/libs/qmuparser/qmuparserdef.h b/src/libs/qmuparser/qmuparserdef.h index 030cd8fbc..8609e9de2 100644 --- a/src/libs/qmuparser/qmuparserdef.h +++ b/src/libs/qmuparser/qmuparserdef.h @@ -64,34 +64,6 @@ #define __has_cpp_attribute(x) 0 #endif -#if QT_VERSION < QT_VERSION_CHECK(5, 8, 0) - -#ifndef QT_HAS_CPP_ATTRIBUTE -#ifdef __has_cpp_attribute -#define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) -#else -#define QT_HAS_CPP_ATTRIBUTE(x) 0 -#endif -#endif // QT_HAS_CPP_ATTRIBUTE - -#if defined(__cplusplus) -#if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough) -#define Q_FALLTHROUGH() [[clang::fallthrough]] -#elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough) -#define Q_FALLTHROUGH() [[gnu::fallthrough]] -#elif QT_HAS_CPP_ATTRIBUTE(fallthrough) -#define Q_FALLTHROUGH() [[fallthrough]] -#endif -#endif -#ifndef Q_FALLTHROUGH -#if (defined(Q_CC_GNU) && Q_CC_GNU >= 700) && !defined(Q_CC_INTEL) -#define Q_FALLTHROUGH() __attribute__((fallthrough)) -#else -#define Q_FALLTHROUGH() (void)0 -#endif -#endif // defined(__cplusplus) -#endif // QT_VERSION < QT_VERSION_CHECK(5, 8, 0) - /** @brief If this macro is defined mathematical exceptions (div by zero) will be thrown as exceptions. */ // #define QMUP_MATH_EXCEPTIONS diff --git a/src/libs/qmuparser/qmuparsererror.h b/src/libs/qmuparser/qmuparsererror.h index ee3a0ee3d..9c895a72d 100644 --- a/src/libs/qmuparser/qmuparsererror.h +++ b/src/libs/qmuparser/qmuparsererror.h @@ -34,10 +34,6 @@ #include "qmuparserdef.h" #include "qmutranslation.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - /** @file @brief This file defines the error class used by the parser. */ diff --git a/src/libs/qmuparser/qmuparsertest.h b/src/libs/qmuparser/qmuparsertest.h index 283f2cdf5..58d5ae452 100644 --- a/src/libs/qmuparser/qmuparsertest.h +++ b/src/libs/qmuparser/qmuparsertest.h @@ -22,17 +22,14 @@ #ifndef QMUPARSERTEST_H #define QMUPARSERTEST_H -#include #include #include +#include #include #include #include #include - -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) -# include -#endif +#include #include "qmuparser.h" #include "qmuparser_global.h" @@ -60,8 +57,9 @@ namespace Test class QMUPARSERSHARED_EXPORT QmuParserTester : public QObject // final { Q_OBJECT // NOLINT + public: - typedef int ( QmuParserTester::*testfun_type ) (); + typedef int (QmuParserTester::*testfun_type)(); explicit QmuParserTester(QObject *parent = nullptr); @@ -73,7 +71,7 @@ private: QVector m_vTestFun; static int c_iCount; - void AddTest ( testfun_type a_pFun ); + void AddTest(testfun_type a_pFun); // Test Double Parser static auto EqnTest(const QString &a_str, double a_fRes, bool a_fPass) -> int; @@ -133,9 +131,9 @@ private: static auto FirstArg(const qreal *a_afArg, qmusizetype a_iArgc) -> qreal { - if ( a_iArgc == 0) + if (a_iArgc == 0) { - throw QmuParserError ( "too few arguments for function FirstArg." ); + throw QmuParserError("too few arguments for function FirstArg."); } return a_afArg[0]; @@ -143,9 +141,9 @@ private: static auto LastArg(const qreal *a_afArg, qmusizetype a_iArgc) -> qreal { - if ( a_iArgc == 0) + if (a_iArgc == 0) { - throw QmuParserError ( "too few arguments for function LastArg." ); + throw QmuParserError("too few arguments for function LastArg."); } return a_afArg[a_iArgc - 1]; @@ -153,13 +151,13 @@ private: static auto Sum(const qreal *a_afArg, qmusizetype a_iArgc) -> qreal { - if ( a_iArgc == 0) + if (a_iArgc == 0) { - throw QmuParserError ( "too few arguments for function sum." ); + throw QmuParserError("too few arguments for function sum."); } qreal fRes = 0; - for ( int i = 0; i < a_iArgc; ++i ) + for (int i = 0; i < a_iArgc; ++i) { fRes += a_afArg[i]; } @@ -168,22 +166,14 @@ private: static auto Rnd(qreal v) -> qreal { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) - return static_cast( ( 1 + ( v * QRandomGenerator().bounded(static_cast(RAND_MAX)) / - ( RAND_MAX + 1.0 ) ) ) ); -#else - return static_cast( ( 1 + ( v * qrand() / ( RAND_MAX + 1.0 ) ) ) ); -#endif + return static_cast( + (1 + (v * QRandomGenerator().bounded(static_cast(RAND_MAX)) / (RAND_MAX + 1.0)))); } static auto RndWithString(const char_type *) -> qreal { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) - return static_cast( ( 1 + ( 1000.0f * QRandomGenerator().bounded(static_cast(RAND_MAX)) / - ( RAND_MAX + 1.0 ) ) ) ); -#else - return static_cast( ( 1 + ( 1000.0f * static_cast(qrand()) / ( RAND_MAX + 1.0 ) ) ) ); -#endif + return static_cast( + (1 + (1000.0f * QRandomGenerator().bounded(static_cast(RAND_MAX)) / (RAND_MAX + 1.0)))); } static auto Ping() -> qreal { return 10; } @@ -199,7 +189,7 @@ private: static auto StrFun2(const QString &v1, qreal v2) -> qreal { int val = v1.toInt(); - return static_cast( val + v2 ); + return static_cast(val + v2); } static auto StrFun3(const QString &v1, qreal v2, qreal v3) -> qreal diff --git a/src/libs/qmuparser/text.h b/src/libs/qmuparser/text.h deleted file mode 100644 index 61fb23e12..000000000 --- a/src/libs/qmuparser/text.h +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************ - ** - ** @file text.h - ** @author Roman Telezhynskyi - ** @date 21 2, 2023 - ** - ** @brief - ** @copyright - ** This source code is part of the Valentina project, a pattern making - ** program, whose allow create and modeling patterns of clothing. - ** Copyright (C) 2023 Valentina project - ** All Rights Reserved. - ** - ** Valentina is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** Valentina is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with Valentina. If not, see . - ** - *************************************************************************/ -#ifndef TEXT_H -#define TEXT_H - -#include - -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) -#include - -namespace Qt -{ -QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Wunused-variable") -QT_WARNING_DISABLE_CLANG("-Wunused-variable") - -// static auto endl Q_DECL_UNUSED = ::endl; // NOLINT -// static auto flush Q_DECL_UNUSED = ::flush; // NOLINT -static auto dec Q_DECL_UNUSED = ::dec; // NOLINT -// static auto SkipEmptyParts Q_DECL_UNUSED = QString::SkipEmptyParts; // NOLINT - -QT_WARNING_POP -} // namespace Qt - -#endif - -#endif // TEXT_H diff --git a/src/libs/vdxf/libdxfrw/drw_base.h b/src/libs/vdxf/libdxfrw/drw_base.h index 16503a869..b1626a3bb 100644 --- a/src/libs/vdxf/libdxfrw/drw_base.h +++ b/src/libs/vdxf/libdxfrw/drw_base.h @@ -58,41 +58,6 @@ #define __has_cpp_attribute(x) 0 #endif -#if QT_VERSION < QT_VERSION_CHECK(5, 8, 0) - -#ifndef QT_HAS_CPP_ATTRIBUTE -#ifdef __has_cpp_attribute -#define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) -#else -#define QT_HAS_CPP_ATTRIBUTE(x) 0 -#endif -#endif // QT_HAS_CPP_ATTRIBUTE - -#if defined(__cplusplus) -#if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough) -#define Q_FALLTHROUGH() [[clang::fallthrough]] -#elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough) -#define Q_FALLTHROUGH() [[gnu::fallthrough]] -#elif QT_HAS_CPP_ATTRIBUTE(fallthrough) -#define Q_FALLTHROUGH() [[fallthrough]] -#endif -#endif -#ifndef Q_FALLTHROUGH -#if (defined(Q_CC_GNU) && Q_CC_GNU >= 700) && !defined(Q_CC_INTEL) -#define Q_FALLTHROUGH() __attribute__((fallthrough)) -#else -#define Q_FALLTHROUGH() (void)0 -#endif -#endif // defined(__cplusplus) -#endif // QT_VERSION < QT_VERSION_CHECK(5, 8, 0) - -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#define Q_DISABLE_COPY_MOVE(Class) \ - Q_DISABLE_COPY(Class) \ - Class(Class &&) = delete; \ - Class &operator=(Class &&) = delete; -#endif - #ifndef Q_DISABLE_ASSIGN_MOVE #define Q_DISABLE_ASSIGN_MOVE(Class) \ Q_DISABLE_ASSIGN(Class) \ diff --git a/src/libs/vdxf/libdxfrw/intern/dxfreader.h b/src/libs/vdxf/libdxfrw/intern/dxfreader.h index b0c97b222..aa8ba6d81 100644 --- a/src/libs/vdxf/libdxfrw/intern/dxfreader.h +++ b/src/libs/vdxf/libdxfrw/intern/dxfreader.h @@ -14,9 +14,6 @@ #define DXFREADER_H #include "drw_textcodec.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif class dxfReader { diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index 895bbf498..b56b50727 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -129,7 +129,7 @@ inline auto LineFont(const TextLine &tl, const QFont &base) -> QFont //--------------------------------------------------------------------------------------------------------------------- inline auto LineAlign(const TextLine &tl, const QString &text, const QFontMetrics &fm, qreal width) -> qreal { - const int lineWidth = TextWidth(fm, text); + const int lineWidth = fm.horizontalAdvance(text); qreal dX = 0; if ((tl.m_eAlign & Qt::AlignHCenter) > 0) @@ -1190,7 +1190,7 @@ void VDxfEngine::ExportAnnotationText(const QSharedPointer &detai QFontMetrics const fm(labelData.font); QPointF pos = labelData.pos; qreal const height = fm.height() * qMin(detail.GetXScale(), detail.GetYScale()); - qreal const width = TextWidth(fm, labelData.label); + qreal const width = fm.horizontalAdvance(labelData.label); QLineF base(pos, QPointF(pos.x() + 100, pos.y())); base.setAngle(base.angle() - 90); diff --git a/src/libs/vformat/knownmeasurements/vknownmeasurementsdocument.h b/src/libs/vformat/knownmeasurements/vknownmeasurementsdocument.h index fef41f7a4..e62a473e0 100644 --- a/src/libs/vformat/knownmeasurements/vknownmeasurementsdocument.h +++ b/src/libs/vformat/knownmeasurements/vknownmeasurementsdocument.h @@ -30,10 +30,6 @@ #include "../ifc/xml/vdomdocument.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class VKnownMeasurements; class VPatternImage; class QUuid; diff --git a/src/libs/vformat/vdimensions.h b/src/libs/vformat/vdimensions.h index 06764e46d..583bd02c0 100644 --- a/src/libs/vformat/vdimensions.h +++ b/src/libs/vformat/vdimensions.h @@ -34,10 +34,6 @@ #include "../vmisc/def.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - enum class MeasurementDimension : qint8 { X = 0, // height diff --git a/src/libs/vformat/vmeasurements.h b/src/libs/vformat/vmeasurements.h index d3f5e3474..df48bbdc7 100644 --- a/src/libs/vformat/vmeasurements.h +++ b/src/libs/vformat/vmeasurements.h @@ -39,10 +39,6 @@ #include "../vmisc/def.h" #include "vdimensions.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class VContainer; class VPatternImage; class VMeasurement; diff --git a/src/libs/vformat/vsinglelineoutlinechar.cpp b/src/libs/vformat/vsinglelineoutlinechar.cpp index 974ac22b4..a6b4da6b3 100644 --- a/src/libs/vformat/vsinglelineoutlinechar.cpp +++ b/src/libs/vformat/vsinglelineoutlinechar.cpp @@ -75,7 +75,7 @@ Q_REQUIRED_RESULT auto ParseCorrectiosn(const QJsonObject &correctionsObject) -> if (!segments.isEmpty()) { - corrections->insert(Front(glyph), segments); + corrections->insert(glyph.front(), segments); } } diff --git a/src/libs/vganalytics/vganalytics.cpp b/src/libs/vganalytics/vganalytics.cpp index be5189648..b910f4f70 100644 --- a/src/libs/vganalytics/vganalytics.cpp +++ b/src/libs/vganalytics/vganalytics.cpp @@ -57,16 +57,7 @@ #include #endif -#if (defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) -// DO NOT WORK WITH GCC 4.8 -#else -#if __cplusplus >= 201402L using namespace std::chrono_literals; -#else -#include "../vmisc/bpstd/chrono.hpp" -using namespace bpstd::literals::chrono_literals; -#endif // __cplusplus >= 201402L -#endif //(defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) #if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) #include "../vmisc/compatibility.h" @@ -454,7 +445,7 @@ auto VGAnalytics::CountryCode() -> QString QTimer timer; timer.setSingleShot(true); - timer.start(V_SECONDS(5)); // Set the timeout to 5 seconds + timer.start(5s); // Set the timeout to 5 seconds QEventLoop eventLoop; diff --git a/src/libs/vganalytics/vganalytics.h b/src/libs/vganalytics/vganalytics.h index 3def025c2..ecd888c7b 100644 --- a/src/libs/vganalytics/vganalytics.h +++ b/src/libs/vganalytics/vganalytics.h @@ -34,10 +34,6 @@ #include #endif -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class QNetworkAccessManager; class VGAnalyticsWorker; diff --git a/src/libs/vganalytics/vganalyticsworker.h b/src/libs/vganalytics/vganalyticsworker.h index a6dbc205f..19b844ec2 100644 --- a/src/libs/vganalytics/vganalyticsworker.h +++ b/src/libs/vganalytics/vganalyticsworker.h @@ -40,10 +40,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class QNetworkReply; struct QueryBuffer diff --git a/src/libs/vgeometry/vabstractcurve.cpp b/src/libs/vgeometry/vabstractcurve.cpp index 4acf89abd..721820132 100644 --- a/src/libs/vgeometry/vabstractcurve.cpp +++ b/src/libs/vgeometry/vabstractcurve.cpp @@ -468,7 +468,7 @@ auto VAbstractCurve::CurveIntersectLine(const QVector &points, const QL for (auto i = 0; i < points.count() - 1; ++i) { QPointF crosPoint; - auto type = Intersects(line, QLineF(points.at(i), points.at(i + 1)), &crosPoint); + auto type = line.intersects(QLineF(points.at(i), points.at(i + 1)), &crosPoint); // QLineF::intersects not always accurate on edge cases if (type == QLineF::BoundedIntersection || diff --git a/src/libs/vgeometry/vellipticalarc.cpp b/src/libs/vgeometry/vellipticalarc.cpp index 47676853a..2d5552779 100644 --- a/src/libs/vgeometry/vellipticalarc.cpp +++ b/src/libs/vgeometry/vellipticalarc.cpp @@ -769,7 +769,7 @@ auto VEllipticalArc::ArcPoints(QVector points) const -> QVector points) const -> QVector points) const -> QVector diff --git a/src/libs/vgeometry/vgobject.cpp b/src/libs/vgeometry/vgobject.cpp index 9eb567158..b88508e7f 100644 --- a/src/libs/vgeometry/vgobject.cpp +++ b/src/libs/vgeometry/vgobject.cpp @@ -377,28 +377,28 @@ auto VGObject::LineIntersectRect(const QRectF &rec, const QLineF &line) -> QPoin qreal x1, y1, x2, y2; rec.getCoords(&x1, &y1, &x2, &y2); QPointF point; - QLineF::IntersectType type = Intersects(line, QLineF(QPointF(x1, y1), QPointF(x1, y2)), &point); + QLineF::IntersectType type = line.intersects(QLineF(QPointF(x1, y1), QPointF(x1, y2)), &point); if (type == QLineF::BoundedIntersection) { return point; } - type = Intersects(line, QLineF(QPointF(x1, y1), QPointF(x2, y1)), &point); + type = line.intersects(QLineF(QPointF(x1, y1), QPointF(x2, y1)), &point); if (type == QLineF::BoundedIntersection) { return point; } - type = Intersects(line, QLineF(QPointF(x1, y2), QPointF(x2, y2)), &point); + type = line.intersects(QLineF(QPointF(x1, y2), QPointF(x2, y2)), &point); if (type == QLineF::BoundedIntersection) { return point; } - type = Intersects(line, QLineF(QPointF(x2, y1), QPointF(x2, y2)), &point); + type = line.intersects(QLineF(QPointF(x2, y1), QPointF(x2, y2)), &point); if (type == QLineF::BoundedIntersection) { @@ -512,7 +512,7 @@ auto VGObject::ClosestPoint(const QLineF &line, const QPointF &point) -> QPointF qreal y = b + point.y(); QLineF lin(point, QPointF(x, y)); QPointF p; - QLineF::IntersectType intersect = Intersects(line, lin, &p); + QLineF::IntersectType intersect = line.intersects(lin, &p); if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) { diff --git a/src/libs/vgeometry/vlayoutplacelabel.cpp b/src/libs/vgeometry/vlayoutplacelabel.cpp index bad8d7cc9..ff3dc6639 100644 --- a/src/libs/vgeometry/vlayoutplacelabel.cpp +++ b/src/libs/vgeometry/vlayoutplacelabel.cpp @@ -27,10 +27,6 @@ *************************************************************************/ #include "vlayoutplacelabel.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) -#include "../vmisc/vdatastreamenum.h" -#endif - #include "../ifc/exception/vexception.h" #if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) @@ -39,12 +35,6 @@ using namespace Qt::Literals::StringLiterals; -// See https://stackoverflow.com/a/46719572/3045403 -#if __cplusplus < 201703L // C++17 -constexpr quint32 VLayoutPlaceLabel::streamHeader; // NOLINT(readability-redundant-declaration) -constexpr quint16 VLayoutPlaceLabel::classVersion; // NOLINT(readability-redundant-declaration) -#endif - //--------------------------------------------------------------------------------------------------------------------- VLayoutPlaceLabel::VLayoutPlaceLabel(const VPlaceLabelItem &item) : m_center(item.toQPointF()), diff --git a/src/libs/vhpgl/vhpglengine.cpp b/src/libs/vhpgl/vhpglengine.cpp index a4a4e46b7..cfe211bdf 100644 --- a/src/libs/vhpgl/vhpglengine.cpp +++ b/src/libs/vhpgl/vhpglengine.cpp @@ -42,10 +42,6 @@ #include "../vmisc/svgfont/vsvgfontengine.h" #include "../vmisc/vabstractapplication.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) -#include "../vmisc/backport/text.h" -#endif - #include #include #include @@ -143,7 +139,7 @@ auto LineAlign(const TextLine &tl, const QString &text, const VSvgFontEngine &en //--------------------------------------------------------------------------------------------------------------------- inline auto LineAlign(const TextLine &tl, const QString &text, const QFontMetrics &fm, qreal width) -> qreal { - const int lineWidth = TextWidth(fm, text); + const int lineWidth = fm.horizontalAdvance(text); qreal dX = 0; if (tl.m_eAlign == 0 || (tl.m_eAlign & Qt::AlignLeft) > 0) @@ -837,7 +833,7 @@ void VHPGLEngine::PlotLabelOutlineFont(QTextStream &out, const VLayoutPiece &det for (auto c : qAsConst(qsText)) { path.addPath(corrector.DrawChar(w, static_cast(fm.ascent()), c)); - w += TextWidth(fm, c); + w += fm.horizontalAdvance(c); } } else diff --git a/src/libs/vhpgl/vhpglengine.h b/src/libs/vhpgl/vhpglengine.h index 48de82558..711e97984 100644 --- a/src/libs/vhpgl/vhpglengine.h +++ b/src/libs/vhpgl/vhpglengine.h @@ -38,10 +38,6 @@ #include // and, not, or #endif -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class VLayoutPiece; class VLayoutPoint; class QTextStream; diff --git a/src/libs/vhpgl/vhpglpaintdevice.h b/src/libs/vhpgl/vhpglpaintdevice.h index 2883f4a33..40337cc69 100644 --- a/src/libs/vhpgl/vhpglpaintdevice.h +++ b/src/libs/vhpgl/vhpglpaintdevice.h @@ -30,10 +30,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class VHPGLEngine; class QSize; class VLayoutPiece; diff --git a/src/libs/vlayout/dialogs/dialoglayoutscale.cpp b/src/libs/vlayout/dialogs/dialoglayoutscale.cpp index 394b797be..08cdcd137 100644 --- a/src/libs/vlayout/dialogs/dialoglayoutscale.cpp +++ b/src/libs/vlayout/dialogs/dialoglayoutscale.cpp @@ -27,20 +27,16 @@ *************************************************************************/ #include "dialoglayoutscale.h" -#include "ui_dialoglayoutscale.h" #include "../vmisc/vabstractvalapplication.h" #include "../vmisc/vcommonsettings.h" +#include "ui_dialoglayoutscale.h" #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - //--------------------------------------------------------------------------------------------------------------------- DialogLayoutScale::DialogLayoutScale(bool printTiled, QWidget *parent) - :QDialog(parent), + : QDialog(parent), ui(new Ui::DialogLayoutScale) { ui->setupUi(this); @@ -59,10 +55,10 @@ DialogLayoutScale::DialogLayoutScale(bool printTiled, QWidget *parent) connect(ui->toolButtonScaleConnected, &QToolButton::clicked, this, &DialogLayoutScale::ToggleScaleConnection); - connect(ui->doubleSpinBoxHorizontalScale, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &DialogLayoutScale::HorizontalScaleChanged); - connect(ui->doubleSpinBoxVerticalScale, QOverload::of(&QDoubleSpinBox::valueChanged), - this, &DialogLayoutScale::VerticalScaleChanged); + connect(ui->doubleSpinBoxHorizontalScale, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &DialogLayoutScale::HorizontalScaleChanged); + connect(ui->doubleSpinBoxVerticalScale, QOverload::of(&QDoubleSpinBox::valueChanged), this, + &DialogLayoutScale::VerticalScaleChanged); ReadSettings(); } @@ -88,12 +84,8 @@ void DialogLayoutScale::SetTiledMargins(QMarginsF margins) //--------------------------------------------------------------------------------------------------------------------- auto DialogLayoutScale::GetTiledMargins() const -> QMarginsF { - QMarginsF margins = QMarginsF( - ui->doubleSpinBoxLeftField->value(), - ui->doubleSpinBoxTopField->value(), - ui->doubleSpinBoxRightField->value(), - ui->doubleSpinBoxBottomField->value() - ); + QMarginsF margins = QMarginsF(ui->doubleSpinBoxLeftField->value(), ui->doubleSpinBoxTopField->value(), + ui->doubleSpinBoxRightField->value(), ui->doubleSpinBoxBottomField->value()); return UnitConvertor(margins, VAbstractValApplication::VApp()->patternUnits(), Unit::Mm); } @@ -125,8 +117,8 @@ auto DialogLayoutScale::GetYScale() const -> qreal //--------------------------------------------------------------------------------------------------------------------- void DialogLayoutScale::showEvent(QShowEvent *event) { - QDialog::showEvent( event ); - if ( event->spontaneous() ) + QDialog::showEvent(event); + if (event->spontaneous()) { return; } @@ -139,7 +131,7 @@ void DialogLayoutScale::showEvent(QShowEvent *event) setFixedSize(size()); - isInitialized = true;//first show windows are held + isInitialized = true; // first show windows are held } //--------------------------------------------------------------------------------------------------------------------- @@ -210,11 +202,7 @@ void DialogLayoutScale::WriteSettings() const const Unit unit = VAbstractValApplication::VApp()->patternUnits(); // write Margins top, right, bottom, left - QMarginsF margins = QMarginsF( - ui->doubleSpinBoxLeftField->value(), - ui->doubleSpinBoxTopField->value(), - ui->doubleSpinBoxRightField->value(), - ui->doubleSpinBoxBottomField->value() - ); - settings->SetTiledPDFMargins(margins,unit); + QMarginsF margins = QMarginsF(ui->doubleSpinBoxLeftField->value(), ui->doubleSpinBoxTopField->value(), + ui->doubleSpinBoxRightField->value(), ui->doubleSpinBoxBottomField->value()); + settings->SetTiledPDFMargins(margins, unit); } diff --git a/src/libs/vlayout/dialogs/dialoglayoutscale.h b/src/libs/vlayout/dialogs/dialoglayoutscale.h index ef277af18..1705125b7 100644 --- a/src/libs/vlayout/dialogs/dialoglayoutscale.h +++ b/src/libs/vlayout/dialogs/dialoglayoutscale.h @@ -30,10 +30,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace Ui { class DialogLayoutScale; diff --git a/src/libs/vlayout/dialogs/vabstractlayoutdialog.h b/src/libs/vlayout/dialogs/vabstractlayoutdialog.h index 2a16cadee..13483425a 100644 --- a/src/libs/vlayout/dialogs/vabstractlayoutdialog.h +++ b/src/libs/vlayout/dialogs/vabstractlayoutdialog.h @@ -32,10 +32,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - enum class Unit : qint8; class VAbstractLayoutDialog : public QDialog diff --git a/src/libs/vlayout/dialogs/watermarkwindow.cpp b/src/libs/vlayout/dialogs/watermarkwindow.cpp index 9ccfff7a3..c535cd00a 100644 --- a/src/libs/vlayout/dialogs/watermarkwindow.cpp +++ b/src/libs/vlayout/dialogs/watermarkwindow.cpp @@ -38,10 +38,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - #include "../ifc/exception/vexception.h" #include "../ifc/xml/vwatermarkconverter.h" #include "../vformat/vwatermark.h" @@ -231,15 +227,6 @@ auto WatermarkWindow::Open(QString path) -> bool //--------------------------------------------------------------------------------------------------------------------- void WatermarkWindow::closeEvent(QCloseEvent *event) { -#if defined(Q_OS_MAC) && QT_VERSION < QT_VERSION_CHECK(5, 11, 1) - // Workaround for Qt bug https://bugreports.qt.io/browse/QTBUG-43344 - static int numCalled = 0; - if (numCalled++ >= 1) - { - return; - } -#endif - if (MaybeSave()) { event->accept(); diff --git a/src/libs/vlayout/vabstractpiece.cpp b/src/libs/vlayout/vabstractpiece.cpp index 968c35bbe..8c1ca6826 100644 --- a/src/libs/vlayout/vabstractpiece.cpp +++ b/src/libs/vlayout/vabstractpiece.cpp @@ -108,7 +108,7 @@ auto AngleByLength(QVector points, QPointF p1, QPointF p2, QPointF // We do not check intersection type because intersection must alwayse exist QPointF px; cutLine.setAngle(cutLine.angle() + 90); - QLineF::IntersectType type = Intersects(QLineF(sp1, sp2), cutLine, &px); + QLineF::IntersectType type = QLineF(sp1, sp2).intersects(cutLine, &px); if (type == QLineF::NoIntersection) { @@ -119,7 +119,7 @@ auto AngleByLength(QVector points, QPointF p1, QPointF p2, QPointF points.append(sp); cutLine.setAngle(cutLine.angle() - 180); - type = Intersects(QLineF(sp2, sp3), cutLine, &px); + type = QLineF(sp2, sp3).intersects(cutLine, &px); if (type == QLineF::NoIntersection) { @@ -247,7 +247,7 @@ auto AngleByIntersection(const QVector &points, QPointF p1, QPointF QLineF edge2(p2, p3); QPointF px; - QLineF::IntersectType type = Intersects(edge2, bigLine1, &px); + QLineF::IntersectType type = edge2.intersects(bigLine1, &px); if (type == QLineF::NoIntersection) { @@ -282,7 +282,7 @@ auto AngleByIntersection(const QVector &points, QPointF p1, QPointF // Second point QLineF edge1(p1, p2); - type = Intersects(edge1, bigLine2, &px); + type = edge1.intersects(bigLine2, &px); if (type == QLineF::NoIntersection) { @@ -332,7 +332,7 @@ auto AngleByFirstSymmetry(const QVector &points, QPointF p1, QPoint QLineF sEdge(VPointF::FlipPF(axis, bigLine2.p1()), VPointF::FlipPF(axis, bigLine2.p2())); QPointF px1; - QLineF::IntersectType type = Intersects(sEdge, bigLine1, &px1); + QLineF::IntersectType type = sEdge.intersects(bigLine1, &px1); if (type == QLineF::NoIntersection) { @@ -340,7 +340,7 @@ auto AngleByFirstSymmetry(const QVector &points, QPointF p1, QPoint } QPointF px2; - type = Intersects(sEdge, bigLine2, &px2); + type = sEdge.intersects(bigLine2, &px2); if (type == QLineF::NoIntersection) { @@ -413,7 +413,7 @@ auto AngleBySecondSymmetry(const QVector &points, QPointF p1, QPoin QLineF sEdge(VPointF::FlipPF(axis, bigLine1.p1()), VPointF::FlipPF(axis, bigLine1.p2())); QPointF px1; - QLineF::IntersectType type = Intersects(sEdge, bigLine1, &px1); + QLineF::IntersectType type = sEdge.intersects(bigLine1, &px1); if (type == QLineF::NoIntersection) { @@ -421,7 +421,7 @@ auto AngleBySecondSymmetry(const QVector &points, QPointF p1, QPoin } QPointF px2; - type = Intersects(sEdge, bigLine2, &px2); + type = sEdge.intersects(bigLine2, &px2); if (type == QLineF::NoIntersection) { @@ -491,7 +491,7 @@ auto AngleByFirstRightAngle(const QVector &points, QPointF p1, QPoi QLineF edge(p1, p2); QPointF px; - QLineF::IntersectType type = Intersects(edge, bigLine2, &px); + QLineF::IntersectType type = edge.intersects(bigLine2, &px); if (type == QLineF::NoIntersection) { @@ -563,7 +563,7 @@ auto AngleBySecondRightAngle(QVector points, QPointF p1, QPointF p2 QLineF edge(p2, p3); QPointF px; - QLineF::IntersectType type = Intersects(edge, bigLine1, &px); + QLineF::IntersectType type = edge.intersects(bigLine1, &px); if (type == QLineF::NoIntersection) { @@ -819,7 +819,7 @@ void RollbackBySecondEdgeRightAngle(QVector &ekvPoints, const QVect const QLineF bigLine1 = VAbstractPiece::ParallelLine(points.at(points.size() - 2), points.at(0), width); QPointF px; - Intersects(edge, bigLine1, &px); + edge.intersects(bigLine1, &px); ekvPoints.removeLast(); @@ -831,7 +831,7 @@ void RollbackBySecondEdgeRightAngle(QVector &ekvPoints, const QVect const QLineF edge2(ekvPoints.at(0), ekvPoints.at(1)); QPointF crosPoint; - const QLineF::IntersectType type = Intersects(edge1, edge2, &crosPoint); + const QLineF::IntersectType type = edge1.intersects(edge2, &crosPoint); if (type == QLineF::BoundedIntersection) { @@ -1247,13 +1247,13 @@ auto VAbstractPiece::EkvPoint(QVector points, const VSAPoint &p1Lin ray.setLength(width * 2); QPointF crosPoint; - QLineF::IntersectType type = Intersects(ray, bigLine1, &crosPoint); + QLineF::IntersectType type = ray.intersects(bigLine1, &crosPoint); if (type != QLineF::NoIntersection) { points.append(VRawSAPoint(crosPoint, p2Line1.CurvePoint(), p2Line1.TurnPoint())); } - type = Intersects(ray, bigLine2, &crosPoint); + type = ray.intersects(bigLine2, &crosPoint); if (type != QLineF::NoIntersection) { points.append(VRawSAPoint(crosPoint, p2Line1.CurvePoint(), p2Line1.TurnPoint())); @@ -1262,7 +1262,7 @@ auto VAbstractPiece::EkvPoint(QVector points, const VSAPoint &p1Lin } QPointF crosPoint; - const QLineF::IntersectType type = Intersects(bigLine1, bigLine2, &crosPoint); + const QLineF::IntersectType type = bigLine1.intersects(bigLine2, &crosPoint); switch (type) { // There are at least three big cases @@ -1363,7 +1363,7 @@ auto VAbstractPiece::EkvPoint(QVector points, const VSAPoint &p1Lin const QLineF bigEdge = ParallelLine(p1Line1, p1Line2, localWidth); QPointF px; - const QLineF::IntersectType type = Intersects(bigEdge, line, &px); + const QLineF::IntersectType type = bigEdge.intersects(line, &px); if (type != QLineF::BoundedIntersection && line.length() < QLineF(p2Line1, px).length()) { points.append(VRawSAPoint(crosPoint, p2Line1.CurvePoint(), p2Line1.TurnPoint())); @@ -1678,7 +1678,7 @@ auto VAbstractPiece::RollbackSeamAllowance(QVector points, const QL { QLineF segment(points.at(i), points.at(i - 1)); QPointF crosPoint; - const QLineF::IntersectType type = Intersects(cuttingEdge, segment, &crosPoint); + const QLineF::IntersectType type = cuttingEdge.intersects(segment, &crosPoint); if (type != QLineF::NoIntersection && VGObject::IsPointOnLineSegment(crosPoint, segment.p1(), segment.p2()) && IsSameDirection(cuttingEdge.p2(), cuttingEdge.p1(), crosPoint)) @@ -1698,7 +1698,7 @@ auto VAbstractPiece::RollbackSeamAllowance(QVector points, const QL { QPointF crosPoint; QLineF secondLast(points.at(points.size() - 2), points.at(points.size() - 1)); - QLineF::IntersectType type = Intersects(secondLast, cuttingEdge, &crosPoint); + QLineF::IntersectType type = secondLast.intersects(cuttingEdge, &crosPoint); if (type != QLineF::NoIntersection && IsOutsidePoint(secondLast.p1(), secondLast.p2(), crosPoint)) { diff --git a/src/libs/vlayout/vabstractpiece.h b/src/libs/vlayout/vabstractpiece.h index 7da6fac78..f5d5d04c6 100644 --- a/src/libs/vlayout/vabstractpiece.h +++ b/src/libs/vlayout/vabstractpiece.h @@ -583,7 +583,7 @@ inline auto VAbstractPiece::IsInsidePolygon(const QVector &path, const QVecto } QPointF crosPoint; - const auto type = Intersects(baseSegment, allowanceSegment, &crosPoint); + const auto type = baseSegment.intersects(allowanceSegment, &crosPoint); if (type == QLineF::BoundedIntersection && not VFuzzyComparePoints(baseSegment.p1(), crosPoint, accuracy) && not VFuzzyComparePoints(baseSegment.p2(), crosPoint, accuracy) && @@ -674,7 +674,7 @@ template inline auto VAbstractPiece::CheckLoop(const QVector &point { QLineF line2(points.at(j), points.at(j + 1)); - const QLineF::IntersectType intersect = Intersects(line1, line2, &crosPoint); + const QLineF::IntersectType intersect = line1.intersects(line2, &crosPoint); if (intersect == QLineF::NoIntersection) { // According to the documentation QLineF::NoIntersection indicates that the lines do not intersect; // i.e. they are parallel. But parallel also mean they can be on the same line. diff --git a/src/libs/vlayout/vabstractpiece_p.h b/src/libs/vlayout/vabstractpiece_p.h index aebf38360..b596e8160 100644 --- a/src/libs/vlayout/vabstractpiece_p.h +++ b/src/libs/vlayout/vabstractpiece_p.h @@ -34,10 +34,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) -#include "../vmisc/vdatastreamenum.h" -#endif - #include "../ifc/exception/vexception.h" #include "../vmisc/defglobal.h" @@ -90,12 +86,6 @@ private: QT_WARNING_POP -// See https://stackoverflow.com/a/46719572/3045403 -#if __cplusplus < 201703L // C++17 -constexpr quint32 VAbstractPieceData::streamHeader; // NOLINT(readability-redundant-declaration) -constexpr quint16 VAbstractPieceData::classVersion; // NOLINT(readability-redundant-declaration) -#endif - // Friend functions //--------------------------------------------------------------------------------------------------------------------- inline auto operator<<(QDataStream &dataStream, const VAbstractPieceData &piece) -> QDataStream & diff --git a/src/libs/vlayout/vfoldline.cpp b/src/libs/vlayout/vfoldline.cpp index 5c4232cd5..809aeb380 100644 --- a/src/libs/vlayout/vfoldline.cpp +++ b/src/libs/vlayout/vfoldline.cpp @@ -262,12 +262,12 @@ auto VFoldLine::LabelPosition(bool &ok) const -> FoldLabelPosData if (m_alignment & Qt::AlignHCenter) // NOLINT(readability-implicit-bool-conversion) { - qreal const shift = (data.labelWidth - TextWidth(fm, posData.label)) / 2; + qreal const shift = (data.labelWidth - fm.horizontalAdvance(posData.label)) / 2; baseLine.setLength(baseLine.length() - shift); } else if (m_alignment & Qt::AlignRight) // NOLINT(readability-implicit-bool-conversion) { - qreal const shift = data.labelWidth - TextWidth(fm, posData.label); + qreal const shift = data.labelWidth - fm.horizontalAdvance(posData.label); baseLine.setLength(baseLine.length() - shift); } @@ -507,7 +507,7 @@ auto VFoldLine::TrueCenter(const QLineF &base, qreal width) const -> QPointF if (VFuzzyComparePossibleNulls(base.length(), width) || qFuzzyIsNull(width)) { - return LineCenter(base); + return base.center(); } QLineF seg1 = base; @@ -574,12 +574,12 @@ auto VFoldLine::OutlineFontLabel(const QLineF &base, qreal width, qreal textHeig if (m_alignment & Qt::AlignHCenter) // NOLINT(readability-implicit-bool-conversion) { - qreal const shift = (width - TextWidth(fm, label)) / 2; + qreal const shift = (width - fm.horizontalAdvance(label)) / 2; baseLine.setLength(baseLine.length() - shift); } else if (m_alignment & Qt::AlignRight) // NOLINT(readability-implicit-bool-conversion) { - qreal const shift = width - TextWidth(fm, label); + qreal const shift = width - fm.horizontalAdvance(label); baseLine.setLength(baseLine.length() - shift); } @@ -598,7 +598,7 @@ auto VFoldLine::OutlineFontLabel(const QLineF &base, qreal width, qreal textHeig for (auto c : qAsConst(label)) { labelPath.addPath(corrector.DrawChar(w, static_cast(fm.ascent()), c)); - w += TextWidth(fm, c); + w += fm.horizontalAdvance(c); } QTransform matrix; diff --git a/src/libs/vlayout/vgraphicsfillitem.h b/src/libs/vlayout/vgraphicsfillitem.h index 273ba3fe0..e4fe22ff2 100644 --- a/src/libs/vlayout/vgraphicsfillitem.h +++ b/src/libs/vlayout/vgraphicsfillitem.h @@ -34,10 +34,6 @@ #include "../vmisc/def.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class VGraphicsFillItem : public QGraphicsPathItem { public: diff --git a/src/libs/vlayout/vlayout.pri b/src/libs/vlayout/vlayout.pri index 094e98e39..f295318b8 100644 --- a/src/libs/vlayout/vlayout.pri +++ b/src/libs/vlayout/vlayout.pri @@ -44,7 +44,6 @@ SOURCES += \ $$PWD/vlayoutpoint.cpp \ $$PWD/vposition.cpp \ $$PWD/vrawlayout.cpp \ - $$PWD/vsapoint.cpp \ $$PWD/vprintlayout.cpp \ $$PWD/vtextmanager.cpp \ $$PWD/vposter.cpp \ diff --git a/src/libs/vlayout/vlayout.qbs b/src/libs/vlayout/vlayout.qbs index 02e3434dd..e995bee59 100644 --- a/src/libs/vlayout/vlayout.qbs +++ b/src/libs/vlayout/vlayout.qbs @@ -62,10 +62,6 @@ VLib { "vfoldline.cpp" ]; - if (Qt.core.versionMajor >= 5 && Qt.core.versionMinor < 12) { - files.push("vsapoint.cpp"); // need only before C++17 - } - return files; } diff --git a/src/libs/vlayout/vlayoutpiece.cpp b/src/libs/vlayout/vlayoutpiece.cpp index 52c35b2b6..abce97c5d 100644 --- a/src/libs/vlayout/vlayoutpiece.cpp +++ b/src/libs/vlayout/vlayoutpiece.cpp @@ -2027,11 +2027,11 @@ void VLayoutPiece::LabelStringsOutlineFont(QGraphicsItem *parent, const QVector< } else if ((tl.m_eAlign & Qt::AlignHCenter) > 0) { - dX = (dW - TextWidth(fm, tl.m_qsText)) / 2; + dX = (dW - fm.horizontalAdvance(tl.m_qsText)) / 2; } else if ((tl.m_eAlign & Qt::AlignRight) > 0) { - dX = dW - TextWidth(fm, tl.m_qsText); + dX = dW - fm.horizontalAdvance(tl.m_qsText); } // set up the rotation around top-left corner matrix @@ -2061,7 +2061,7 @@ void VLayoutPiece::LabelStringsOutlineFont(QGraphicsItem *parent, const QVector< for (auto c : qAsConst(tl.m_qsText)) { path.addPath(corrector.DrawChar(w, static_cast(fm.ascent()), c)); - w += TextWidth(fm, c); + w += fm.horizontalAdvance(c); } } else diff --git a/src/libs/vlayout/vlayoutpiece.h b/src/libs/vlayout/vlayoutpiece.h index 2b2958dcd..a07640a32 100644 --- a/src/libs/vlayout/vlayoutpiece.h +++ b/src/libs/vlayout/vlayoutpiece.h @@ -45,13 +45,8 @@ #include "qpainterpath.h" #include "vabstractpiece.h" -#if __cplusplus >= 201703L // C++17 #include using EdgeIndex = std::optional; -#else -#include "../vmisc/bpstd/optional.hpp" -using EdgeIndex = bpstd::optional; -#endif class VLayoutPieceData; class VLayoutPiecePath; diff --git a/src/libs/vlayout/vlayoutpiece_p.h b/src/libs/vlayout/vlayoutpiece_p.h index fa826b0d6..a35f71c17 100644 --- a/src/libs/vlayout/vlayoutpiece_p.h +++ b/src/libs/vlayout/vlayoutpiece_p.h @@ -34,16 +34,11 @@ #include #include -#include "../vpatterndb/floatItemData/floatitemdef.h" -#include "../vwidgets/vpiecegrainline.h" - -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) -#include "../vmisc/vdatastreamenum.h" -#endif - #include "../ifc/exception/vexception.h" #include "../vgeometry/vgeometrydef.h" #include "../vgeometry/vlayoutplacelabel.h" +#include "../vpatterndb/floatItemData/floatitemdef.h" +#include "../vwidgets/vpiecegrainline.h" #include "vlayoutpiecepath.h" #include "vlayoutpoint.h" #include "vtextmanager.h" @@ -134,12 +129,6 @@ private: QT_WARNING_POP -// See https://stackoverflow.com/a/46719572/3045403 -#if __cplusplus < 201703L // C++17 -constexpr quint32 VLayoutPieceData::streamHeader; // NOLINT(readability-redundant-declaration) -constexpr quint16 VLayoutPieceData::classVersion; // NOLINT(readability-redundant-declaration) -#endif - // Friend functions //--------------------------------------------------------------------------------------------------------------------- inline auto operator<<(QDataStream &dataStream, const VLayoutPieceData &piece) -> QDataStream & diff --git a/src/libs/vlayout/vlayoutpiecepath_p.h b/src/libs/vlayout/vlayoutpiecepath_p.h index a740a319e..457bc2407 100644 --- a/src/libs/vlayout/vlayoutpiecepath_p.h +++ b/src/libs/vlayout/vlayoutpiecepath_p.h @@ -34,10 +34,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) -#include "../vmisc/vdatastreamenum.h" -#endif - #include "../ifc/exception/vexception.h" #include "vlayoutpoint.h" @@ -74,12 +70,6 @@ private: QT_WARNING_POP -// See https://stackoverflow.com/a/46719572/3045403 -#if __cplusplus < 201703L // C++17 -constexpr quint32 VLayoutPiecePathData::streamHeader; // NOLINT(readability-redundant-declaration) -constexpr quint16 VLayoutPiecePathData::classVersion; // NOLINT(readability-redundant-declaration) -#endif - //--------------------------------------------------------------------------------------------------------------------- inline VLayoutPiecePathData::VLayoutPiecePathData(const QVector &points) : m_points(points) diff --git a/src/libs/vlayout/vposter.cpp b/src/libs/vlayout/vposter.cpp index ba002489f..b8a6324a8 100644 --- a/src/libs/vlayout/vposter.cpp +++ b/src/libs/vlayout/vposter.cpp @@ -497,7 +497,7 @@ void VPoster::Ruler(QVector &data, QGraphicsItem *parent, QRect qreal unitsWidth = 0; QFontMetrics fm(fnt); - unitsWidth = TextWidth(fm, units->toPlainText()); + unitsWidth = fm.horizontalAdvance(units->toPlainText()); units->setPos(rec.x() + step * 0.5 - unitsWidth * 0.7, rec.y() + rec.height() - static_cast(allowance) - shortNotchHeight); units->setFont(fnt); diff --git a/src/libs/vlayout/vrawlayout.cpp b/src/libs/vlayout/vrawlayout.cpp index 0e00c94f7..61febeebc 100644 --- a/src/libs/vlayout/vrawlayout.cpp +++ b/src/libs/vlayout/vrawlayout.cpp @@ -31,12 +31,7 @@ #include #include #include - -#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) -#include "../vmisc/backport/qscopeguard.h" -#else #include -#endif #include "../ifc/exception/vexception.h" #include "../vmisc/def.h" @@ -114,7 +109,7 @@ auto VRawLayout::WriteFile(QIODevice *ioDevice, const VRawLayoutData &data) -> b if (wasOpen || ioDevice->open(QIODevice::WriteOnly)) { QDataStream dataStream(ioDevice); - dataStream.setVersion(QDataStream::Qt_5_6); + dataStream.setVersion(QDataStream::Qt_5_15); // Don't use the << operator for QByteArray. See the note in ReadFile() below. dataStream.writeRawData(fileHeaderByteArray.constData(), static_cast(fileHeaderByteArray.size())); @@ -154,7 +149,7 @@ auto VRawLayout::ReadFile(QIODevice *ioDevice, VRawLayoutData &data) -> bool }); QDataStream dataStream(ioDevice); - dataStream.setVersion(QDataStream::Qt_5_6); + dataStream.setVersion(QDataStream::Qt_5_15); // Note: we could have used the QDataStream << and >> operators on QByteArray but since the first // bytes of the stream will be the size of the array, we might end up attempting to allocate diff --git a/src/libs/vlayout/vsapoint.cpp b/src/libs/vlayout/vsapoint.cpp deleted file mode 100644 index 72c00f4f4..000000000 --- a/src/libs/vlayout/vsapoint.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/************************************************************************ - ** - ** @file vsapoint.cpp - ** @author Roman Telezhynskyi - ** @date 22 11, 2022 - ** - ** @brief - ** @copyright - ** This source code is part of the Valentina project, a pattern making - ** program, whose allow create and modeling patterns of clothing. - ** Copyright (C) 2022 Valentina project - ** All Rights Reserved. - ** - ** Valentina is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** Valentina is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with Valentina. If not, see . - ** - *************************************************************************/ - -// See https://stackoverflow.com/a/46719572/3045403 -#if __cplusplus < 201703L -#include "vsapoint.h" - -constexpr qreal VSAPoint::passmarkFactor; // NOLINT(readability-redundant-declaration) -constexpr qreal VSAPoint::maxPassmarkLength; // NOLINT(readability-redundant-declaration) -constexpr qreal VSAPoint::minSAWidth; // NOLINT(readability-redundant-declaration) -#endif diff --git a/src/libs/vlayout/vtextmanager.cpp b/src/libs/vlayout/vtextmanager.cpp index e1431929c..a0f3fd98b 100644 --- a/src/libs/vlayout/vtextmanager.cpp +++ b/src/libs/vlayout/vtextmanager.cpp @@ -51,10 +51,6 @@ #include "../vpatterndb/vcontainer.h" #include "vtextmanager.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 9, 0) -#include "../vmisc/vdatastreamenum.h" -#endif - using namespace Qt::Literals::StringLiterals; namespace @@ -94,7 +90,7 @@ auto FileBaseName(const QString &filePath) -> QString auto SplitTextByWidth(const QString &text, const QFont &font, int maxWidth) -> QStringList { QFontMetrics fontMetrics(font); - if (TextWidth(fontMetrics, text) <= maxWidth) + if (fontMetrics.horizontalAdvance(text) <= maxWidth) { return {text}; } @@ -108,7 +104,7 @@ auto SplitTextByWidth(const QString &text, const QFont &font, int maxWidth) -> Q for (int endIndex = 0; endIndex < textLength; ++endIndex) { QChar currentChar = text.at(endIndex); - const int charWidth = TextWidth(fontMetrics, currentChar); + const int charWidth = fontMetrics.horizontalAdvance(currentChar); if (lineWidth + charWidth > maxWidth) { @@ -723,7 +719,7 @@ auto VTextManager::GetLabelSourceLines(int width, const QFont &font) const -> QV QString qsText = tl.m_qsText; QFontMetrics fm(fnt); - if (TextWidth(fm, qsText) > width) + if (fm.horizontalAdvance(qsText) > width) { const QStringList brokeLines = BreakTextIntoLines(qsText, fnt, width); for (const auto &lineText : brokeLines) @@ -806,12 +802,12 @@ auto VTextManager::MaxLineWidthOutlineFont(int width) const -> int QString qsText = tl.m_qsText; - if (TextWidth(fm, qsText) > width) + if (fm.horizontalAdvance(qsText) > width) { qsText = fm.elidedText(qsText, Qt::ElideMiddle, width); } - maxWidth = qMax(TextWidth(fm, qsText), maxWidth); + maxWidth = qMax(fm.horizontalAdvance(qsText), maxWidth); } return maxWidth; @@ -913,7 +909,7 @@ auto VTextManager::BreakTextIntoLines(const QString &text, const QFont &font, in QString currentLine; int currentLineWidth = 0; - const int spaceWidth = TextWidth(fontMetrics, QChar(' ')); + const int spaceWidth = fontMetrics.horizontalAdvance(QChar(' ')); const float tolerance = 0.3F; QStringList lines; @@ -933,7 +929,7 @@ auto VTextManager::BreakTextIntoLines(const QString &text, const QFont &font, in while (iterator.hasNext()) { const QString &word = iterator.next(); - int wordWidth = TextWidth(fontMetrics, word); + int wordWidth = fontMetrics.horizontalAdvance(word); int totalWidth = !currentLine.isEmpty() ? currentLineWidth + spaceWidth + wordWidth : wordWidth; if (totalWidth <= maxWidth) @@ -952,7 +948,7 @@ auto VTextManager::BreakTextIntoLines(const QString &text, const QFont &font, in else { // Word is too long, force line break - if (currentLineWidth + spaceWidth + TextWidth(fontMetrics, word.at(0)) > maxWidth) + if (currentLineWidth + spaceWidth + fontMetrics.horizontalAdvance(word.at(0)) > maxWidth) { lines.append(currentLine); currentLine.clear(); @@ -968,7 +964,7 @@ auto VTextManager::BreakTextIntoLines(const QString &text, const QFont &font, in } else { - const int width = TextWidth(fontMetrics, subWords.constFirst()); + const int width = fontMetrics.horizontalAdvance(subWords.constFirst()); const int tWidth = !currentLine.isEmpty() ? currentLineWidth + spaceWidth + width : width; AppendWord(subWords.constFirst(), tWidth); lines.append(currentLine); diff --git a/src/libs/vmisc/backport/qoverload.h b/src/libs/vmisc/backport/qoverload.h deleted file mode 100644 index 508cc926e..000000000 --- a/src/libs/vmisc/backport/qoverload.h +++ /dev/null @@ -1,94 +0,0 @@ -/************************************************************************ - ** - ** @file qoverload.h - ** @author Roman Telezhynskyi - ** @date 12 1, 2018 - ** - ** @brief - ** @copyright - ** This source code is part of the Valentina project, a pattern making - ** program, whose allow create and modeling patterns of clothing. - ** Copyright (C) 2018 Valentina project - ** All Rights Reserved. - ** - ** Valentina is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** Valentina is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with Valentina. If not, see . - ** - *************************************************************************/ -#ifndef QOVERLOAD_H -#define QOVERLOAD_H - -#include - -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#if defined(Q_COMPILER_VARIADIC_TEMPLATES) - -QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Weffc++") - -template struct QNonConstOverload -{ - template - Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const noexcept -> decltype(ptr) - { - return ptr; - } - - template static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...)) noexcept -> decltype(ptr) - { - return ptr; - } -}; - -template struct QConstOverload -{ - template - Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const noexcept -> decltype(ptr) - { - return ptr; - } - - template - static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...) const) noexcept -> decltype(ptr) - { - return ptr; - } -}; - -template struct QOverload : QConstOverload, QNonConstOverload -{ - using QConstOverload::of; - using QConstOverload::operator(); - using QNonConstOverload::of; - using QNonConstOverload::operator(); - - template Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const noexcept -> decltype(ptr) - { - return ptr; - } - - template static Q_DECL_CONSTEXPR auto of(R (*ptr)(Args...)) noexcept -> decltype(ptr) { return ptr; } -}; - -#if defined(__cpp_variable_templates) && __cpp_variable_templates >= 201304 // C++14 -template Q_CONSTEXPR Q_DECL_UNUSED QOverload qOverload = {}; -template Q_CONSTEXPR Q_DECL_UNUSED QConstOverload qConstOverload = {}; -template Q_CONSTEXPR Q_DECL_UNUSED QNonConstOverload qNonConstOverload = {}; -#endif - -QT_WARNING_POP - -#endif // Q_COMPILER_VARIADIC_TEMPLATES -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - -#endif // QOVERLOAD_H diff --git a/src/libs/vmisc/backport/qscopeguard.h b/src/libs/vmisc/backport/qscopeguard.h deleted file mode 100644 index dce508974..000000000 --- a/src/libs/vmisc/backport/qscopeguard.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Sérgio Martins -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QSCOPEGUARD_H -#define QSCOPEGUARD_H -#include - -#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) -QT_BEGIN_NAMESPACE -template class QScopeGuard; -template QScopeGuard qScopeGuard(F f); -template -class QScopeGuard -{ -public: - QScopeGuard(QScopeGuard &&other) Q_DECL_NOEXCEPT - : m_func(std::move(other.m_func)) - , m_invoke(other.m_invoke) - { - other.dismiss(); - } - ~QScopeGuard() - { - if (m_invoke) - m_func(); - } - void dismiss() Q_DECL_NOEXCEPT - { - m_invoke = false; - } -private: - explicit QScopeGuard(F f) Q_DECL_NOEXCEPT - : m_func(std::move(f)) - { - } - Q_DISABLE_COPY(QScopeGuard) // NOLINT - F m_func; - bool m_invoke = true; - friend QScopeGuard qScopeGuard(F); -}; -template -QScopeGuard qScopeGuard(F f) -{ - return QScopeGuard(std::move(f)); -} -QT_END_NAMESPACE -#endif // QT_VERSION < QT_VERSION_CHECK(5, 12, 0) -#endif // QSCOPEGUARD_H diff --git a/src/libs/vmisc/backport/text.h b/src/libs/vmisc/backport/text.h deleted file mode 100644 index 7cf107266..000000000 --- a/src/libs/vmisc/backport/text.h +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************ - ** - ** @file text.h - ** @author Roman Telezhynskyi - ** @date 1 2, 2023 - ** - ** @brief - ** @copyright - ** This source code is part of the Valentina project, a pattern making - ** program, whose allow create and modeling patterns of clothing. - ** Copyright (C) 2023 Valentina project - ** All Rights Reserved. - ** - ** Valentina is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** Valentina is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with Valentina. If not, see . - ** - *************************************************************************/ -#ifndef TEXT_H -#define TEXT_H - -#include - -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) -#include - -namespace Qt -{ -QT_WARNING_PUSH -QT_WARNING_DISABLE_GCC("-Wunused-variable") -QT_WARNING_DISABLE_CLANG("-Wunused-variable") - -static auto endl Q_DECL_UNUSED = ::endl; // NOLINT -static auto flush Q_DECL_UNUSED = ::flush; // NOLINT -static auto dec Q_DECL_UNUSED = ::dec; // NOLINT -static auto SkipEmptyParts Q_DECL_UNUSED = QString::SkipEmptyParts; // NOLINT - -QT_WARNING_POP -} // namespace Qt - -#endif - -#endif // TEXT_H diff --git a/src/libs/vmisc/bpstd/LICENSE b/src/libs/vmisc/bpstd/LICENSE deleted file mode 100644 index d412ec7ac..000000000 --- a/src/libs/vmisc/bpstd/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 Matthew Rodusek - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/src/libs/vmisc/bpstd/any.hpp b/src/libs/vmisc/bpstd/any.hpp deleted file mode 100644 index e947985c8..000000000 --- a/src/libs/vmisc/bpstd/any.hpp +++ /dev/null @@ -1,887 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file any.hpp -/// -/// \brief This header provides definitions from the C++ header -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_ANY_HPP -#define BPSTD_ANY_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "detail/config.hpp" -#include "type_traits.hpp" // enable_if_t, is_* -#include "utility.hpp" // in_place_type_t, move, forward - -#include // std::bad_cast, std::type_info -#include // std::initializer_list -#include // placement-new -#include // assert - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -namespace bpstd { - - class any; - - //============================================================================ - // class : bad_any_cast - //============================================================================ - - class bad_any_cast : public std::bad_cast - { - auto what() const noexcept -> const char * override; - }; - - //============================================================================ - // class : any - //============================================================================ - - ////////////////////////////////////////////////////////////////////////////// - /// \brief An object that can hold values of any type via type-erasure - /// - /// The class any describes a type-safe container for single values of any - /// type. - /// - /// 1) An object of class any stores an instance of any type that satisfies - /// the constructor requirements or is empty, and this is referred to as the - /// state of the class any object. The stored instance is called the - /// contained object. Two states are equivalent if they are either both - /// empty or if both are not empty and if the contained objects are - /// equivalent. - /// - /// 2) The non-member any_cast functions provide type-safe access to the - /// contained object. - /// - /// This implementation uses small-buffer optimization to avoid dynamic - /// memory if the object is below a (4 * sizeof(void*)) - ////////////////////////////////////////////////////////////////////////////// - class any - { - //-------------------------------------------------------------------------- - // Constructors / Destructor / Assignment - //-------------------------------------------------------------------------- - public: - - /// \brief Constructs an any instance that does not contain any value - any() noexcept; - - /// \brief Moves an any instance by moving the stored underlying value - /// - /// \post \p other is left valueless - /// - /// \param other the other instance to move - any(any&& other) noexcept; - - /// \brief Copies an any instance by copying the stored underlying value - /// - /// \param other the other instance to copy - any(const any& other); - - /// \brief Constructs this any using \p value for the underlying instance - /// - /// \param value the value to construct this any out of - template,any>::value && - is_copy_constructible>::value>> - // cppcheck-suppress noExplicitConstructor - any(ValueType&& value); - - /// \brief Constructs an 'any' of type ValueType by forwarding \p args to - /// its constructor - /// - /// \note This constructor only participates in overload resolution if - /// ValueType is constructible from \p args - /// - /// \param args the arguments to forward to ValueType's constructor - template,Args...>::value && - is_copy_constructible>::value>> - explicit any(in_place_type_t, Args&&...args); - - /// \brief Constructs an 'any' of type ValueType by forwarding \p args to - /// its constructor - /// - /// \note This constructor only participates in overload resolution if - /// ValueType is constructible from \p args - /// - /// \param il an initializer_list of arguments - /// \param args the arguments to forward to ValueType's constructor - template,std::initializer_list,Args...>::value && - is_copy_constructible>::value>> - explicit any(in_place_type_t, - std::initializer_list il, - Args&&...args); - - //-------------------------------------------------------------------------- - - ~any(); - - //-------------------------------------------------------------------------- - - /// \brief Assigns the contents of \p other to this any - /// - /// \param other the other any to move - /// \return reference to \c (*this) - auto operator=(any &&other) noexcept -> any &; - - /// \brief Assigns the contents of \p other to this any - /// - /// \param other the other any to copy - /// \return reference to \c (*this) - auto operator=(const any &other) -> any &; - - /// \brief Assigns \p value to this any - /// - /// \param value the value to assign - /// \return reference to \c (*this) - template , any>::value && - is_copy_constructible>::value>> - auto operator=(ValueType &&value) -> any &; - - //-------------------------------------------------------------------------- - // Modifiers - //-------------------------------------------------------------------------- - public: - - /// \{ - /// \brief Emplaces a \c ValueType into this any, destroying the previous - /// value if it contained one - /// - /// \tparam ValueType the type to construct - /// \param args the arguments to forward to \c ValueType's constructor - /// \return reference to the constructed value - template , Args...>::value && - is_copy_constructible>::value>> - auto emplace(Args &&...args) -> decay_t &; - template , std::initializer_list, Args...>::value && - is_copy_constructible>::value>> - auto emplace(std::initializer_list il, Args &&...args) -> decay_t &; - /// \} - - /// \brief Destroys the underlying stored value, leaving this any - /// empty. - void reset() noexcept; - - /// \brief Swaps the contents of \c this with \p other - /// - /// \post \p other contains the old contents of \c this, and \c this - /// contains the old contents of \p other - /// - /// \param other the other any to swap contents with - void swap(any &other) noexcept; - - //-------------------------------------------------------------------------- - // Observers - //-------------------------------------------------------------------------- - public: - - /// \brief Checks whether this any contains a value - /// - /// \return \c true if this contains a value - auto has_value() const noexcept -> bool; - - /// \brief Gets the type_info for the underlying stored type, or - /// \c typeid(void) if \ref has_value() returns \c false - /// - /// \return the typeid of the stored type - auto type() const noexcept -> const std::type_info &; - - //-------------------------------------------------------------------------- - // Private Static Members / Types - //-------------------------------------------------------------------------- - private: - - // Internal buffer size + alignment - static constexpr auto buffer_size = 4u * sizeof(void*); - static constexpr auto buffer_align = alignof(void*); - - // buffer (for internal storage) - using internal_buffer = typename aligned_storage::type; - - union storage - { - internal_buffer internal; - void* external; - }; - - //-------------------------------------------------------------------------- - - // trait to determine if internal storage is required - template - using requires_internal_storage = bool_constant< - (sizeof(T) <= buffer_size) && - ((buffer_align % alignof(T)) == 0) && - is_nothrow_move_constructible::value - >; - - //----------------------------------------------------------------------- - - template - struct internal_storage_handler; - - template - struct external_storage_handler; - - template - using storage_handler = conditional_t< - requires_internal_storage::value, - internal_storage_handler, - external_storage_handler - >; - - //----------------------------------------------------------------------- - - enum class operation - { - destroy, ///< Operation for calling the underlying's destructor - copy, ///< Operation for copying the underlying value - move, ///< Operation for moving the underlying value - value, ///< Operation for accessing the underlying value - type, ///< Operation for accessing the underlying type - }; - - //----------------------------------------------------------------------- - - using storage_handler_ptr = const void*(*)(operation, const storage*,const storage*); - - template friend auto any_cast(any *) noexcept -> T *; - template friend auto any_cast(const any *) noexcept -> const T *; - - //----------------------------------------------------------------------- - // Private Members - //----------------------------------------------------------------------- - private: - - storage m_storage; - storage_handler_ptr m_storage_handler; - }; - - //========================================================================= - // non-member functions : class : any - //========================================================================= - - //------------------------------------------------------------------------- - // utilities - //------------------------------------------------------------------------- - - /// \brief Swaps the contents of \p lhs and \p rhs - void swap(any& lhs, any& rhs) noexcept; - - //------------------------------------------------------------------------- - // casts - //------------------------------------------------------------------------- - - /// \{ - /// \brief Attempts to cast an any back to the underlying type T - /// - /// \throw bad_any_cast if \p any is not exactly of type \p T - /// \tparam T the type to cast to - /// \return the object - template auto any_cast(any &operand) -> T; - template auto any_cast(any &&operand) -> T; - template auto any_cast(const any &operand) -> T; - /// \} - - /// \{ - /// \brief Attempts to cast an any back to the underlying type T - /// - /// \tparam T the type to cast to - /// \return pointer to the object if successfull, nullptr otherwise - template - T* any_cast(any* operand) noexcept; - template - const T* any_cast(const any* operand) noexcept; - /// \} - -} // namespace bpstd - -//============================================================================= -// definitions : class : bad_any_cast -//============================================================================= - -inline auto bpstd::bad_any_cast::what() const noexcept -> const char * -{ - return "bad_any_cast"; -} - -//============================================================================= -// class : any::internal_storage_handler -//============================================================================= - -template -struct bpstd::any::internal_storage_handler -{ - template static auto construct(storage &s, Args &&...args) -> T *; - - template - static auto construct(storage &s, std::initializer_list il, Args &&...args) -> T *; - - static void destroy(storage& s); - - static auto handle(operation op, const storage *self, const storage *other) -> const void *; -}; - -//============================================================================= -// definition : class : any::internal_storage_handler -//============================================================================= - -template -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::any::internal_storage_handler::construct(storage &s, Args &&...args) - -> T * -{ - return ::new(&s.internal) T(bpstd::forward(args)...); -} - -template -template -inline BPSTD_INLINE_VISIBILITY auto -bpstd::any::internal_storage_handler::construct(storage &s, std::initializer_list il, Args &&...args) -> T * -{ - return ::new(&s.internal) T(il, bpstd::forward(args)...); -} - -template -inline BPSTD_INLINE_VISIBILITY -void bpstd::any::internal_storage_handler - ::destroy(storage& s) -{ - auto* t = static_cast(static_cast(&s.internal)); - t->~T(); -} - -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::any::internal_storage_handler::handle(operation op, const storage *self, - const storage *other) -> const - void * -{ - switch (op) - { - case operation::destroy: - { - assert(self != nullptr); - BPSTD_UNUSED(other); - - destroy(const_cast(*self)); - break; - } - - case operation::copy: - { - assert(self != nullptr); - assert(other != nullptr); - - // Copy construct from the internal storage - const auto* p = reinterpret_cast(&other->internal); - construct( const_cast(*self), *p); - break; - } - - case operation::move: - { - assert(self != nullptr); - assert(other != nullptr); - - // Move construct from the internal storage. ' - const auto* p = reinterpret_cast(&other->internal); - construct(const_cast(*self), bpstd::move(*const_cast(p))); - break; - } - - case operation::value: - { - assert(self != nullptr); - BPSTD_UNUSED(other); - - // NOTE(bitwize): This seemingly arbitrary conversion is for proper - // type-safety/correctness. Otherwise, converting an aligned_storage_t* - // to void* and then to T* would violate strict-aliasing -- which - // would be undefined-behavior. Behavior is only well-defined for - // casts from void* to T* if the the void* originated from a T*. - const auto* p = reinterpret_cast(&self->internal); - return static_cast(p); - } - - case operation::type: - { - BPSTD_UNUSED(self); - BPSTD_UNUSED(other); - - return static_cast(&typeid(T)); - } - } - return nullptr; -} - -//============================================================================= -// class : any::external_storage_handler -//============================================================================= - -template -struct bpstd::any::external_storage_handler -{ - template static auto construct(storage &s, Args &&...args) -> T *; - - template - static auto construct(storage &s, std::initializer_list il, Args &&...args) -> T *; - - static void destroy(storage& s); - - static auto handle(operation op, const storage *self, const storage *other) -> const void *; -}; - - -//============================================================================= -// definition : class : any::external_storage_handler -//============================================================================= - -template -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::any::external_storage_handler::construct(storage &s, Args &&...args) - -> T * -{ - s.external = new T(bpstd::forward(args)...); - return static_cast(s.external); -} - -template -template -inline BPSTD_INLINE_VISIBILITY auto -bpstd::any::external_storage_handler::construct(storage &s, std::initializer_list il, Args &&...args) -> T * -{ - s.external = new T(il, bpstd::forward(args)...); - return static_cast(s.external); -} - -template -inline BPSTD_INLINE_VISIBILITY -void bpstd::any::external_storage_handler - ::destroy(storage& s) -{ - delete static_cast(s.external); -} - -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::any::external_storage_handler::handle(operation op, const storage *self, - const storage *other) -> const - void * -{ - switch (op) - { - case operation::destroy: - { - assert(self != nullptr); - BPSTD_UNUSED(other); - - destroy(const_cast(*self)); - break; - } - - case operation::copy: - { - assert(self != nullptr); - assert(other != nullptr); - - // Copy construct from the internal storage - construct( const_cast(*self), - *static_cast(other->external)); - break; - } - - case operation::move: - { - BPSTD_UNUSED(self != nullptr); - assert(other != nullptr); - - const auto p = static_cast(other->external); - // Move construct from the internal storage. ' - construct(const_cast(*self), bpstd::move(*const_cast(p))); - break; - } - - case operation::value: - { - assert(self != nullptr); - BPSTD_UNUSED(other); - - // self->external was already created as a T*; no need to cast like in - // internal. - return self->external; - } - - case operation::type: - { - BPSTD_UNUSED(self); - BPSTD_UNUSED(other); - - return &typeid(T); - } - } - return nullptr; -} - -//============================================================================= -// definitions : class : any -//============================================================================= - -//----------------------------------------------------------------------------- -// Constructors / Destructor / Assignment -//----------------------------------------------------------------------------- - -inline BPSTD_INLINE_VISIBILITY -bpstd::any::any() - noexcept - : m_storage{}, - m_storage_handler{nullptr} -{ - -} - -inline BPSTD_INLINE_VISIBILITY -bpstd::any::any(any&& other) - noexcept - : m_storage{}, - m_storage_handler{other.m_storage_handler} -{ - if (m_storage_handler != nullptr) { - m_storage_handler(operation::move, &m_storage, &other.m_storage); - } -} - -inline BPSTD_INLINE_VISIBILITY -bpstd::any::any(const any& other) - : m_storage{}, - m_storage_handler{nullptr} -{ - - if (other.m_storage_handler != nullptr) { - // Set handler after constructing, in case of exception - const auto handler = other.m_storage_handler; - - handler(operation::copy, &m_storage, &other.m_storage); - m_storage_handler = handler; - } -} - -template -inline BPSTD_INLINE_VISIBILITY -bpstd::any::any(ValueType&& value) - : m_storage{}, - m_storage_handler{nullptr} -{ - // Set handler after constructing, in case of exception - using handler_type = storage_handler>; - - handler_type::construct(m_storage, bpstd::forward(value)); - m_storage_handler = &handler_type::handle; -} - -template -inline BPSTD_INLINE_VISIBILITY -bpstd::any::any(in_place_type_t, Args&&...args) - : m_storage{}, - m_storage_handler{nullptr} -{ - // Set handler after constructing, in case of exception - using handler_type = storage_handler>; - - handler_type::construct(m_storage, bpstd::forward(args)...); - m_storage_handler = &handler_type::handle; -} - -template -inline BPSTD_INLINE_VISIBILITY -bpstd::any::any(in_place_type_t, - std::initializer_list il, - Args&&...args) - : m_storage{}, - m_storage_handler{nullptr} -{ - // Set handler after constructing, in case of exception - using handler_type = storage_handler>; - - handler_type::construct(m_storage, il, bpstd::forward(args)...); - m_storage_handler = &handler_type::handle; -} - -//----------------------------------------------------------------------------- - -inline BPSTD_INLINE_VISIBILITY -bpstd::any::~any() -{ - reset(); -} - -//----------------------------------------------------------------------------- - -inline BPSTD_INLINE_VISIBILITY auto bpstd::any::operator=(any &&other) noexcept -> bpstd::any & -{ - reset(); - - if (other.m_storage_handler != nullptr) { - m_storage_handler = other.m_storage_handler; - m_storage_handler(operation::move, &m_storage, &other.m_storage); - } - - return (*this); -} - -inline BPSTD_INLINE_VISIBILITY auto bpstd::any::operator=(const any &other) -> bpstd::any & -{ - reset(); - - if (other.m_storage_handler != nullptr) { - // Set handler after constructing, in case of exception - const auto handler = other.m_storage_handler; - - handler(operation::copy, &m_storage, &other.m_storage); - m_storage_handler = handler; - } - - return (*this); -} - -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::any::operator=(ValueType &&value) -> bpstd::any & -{ - using handler_type = storage_handler>; - - reset(); - - handler_type::construct(m_storage, bpstd::forward(value)); - m_storage_handler = &handler_type::handle; - - return (*this); -} - -//----------------------------------------------------------------------------- -// Modifiers -//----------------------------------------------------------------------------- - -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::any::emplace(Args &&...args) -> bpstd::decay_t & -{ - using handler_type = storage_handler>; - - reset(); - - auto& result = *handler_type::construct(m_storage, - bpstd::forward(args)...); - m_storage_handler = &handler_type::handle; - - return result; -} - -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::any::emplace(std::initializer_list il, Args &&...args) - -> bpstd::decay_t & -{ - using handler_type = storage_handler>; - - reset(); - - auto& result = *handler_type::construct(m_storage, - il, - bpstd::forward(args)...); - m_storage_handler = &handler_type::handle; - - return result; -} - -inline BPSTD_INLINE_VISIBILITY -void bpstd::any::reset() - noexcept -{ - if (m_storage_handler != nullptr) { - m_storage_handler(operation::destroy, &m_storage, nullptr); - m_storage_handler = nullptr; - } -} - -inline BPSTD_INLINE_VISIBILITY -void bpstd::any::swap(any& other) - noexcept -{ - using std::swap; - - if (m_storage_handler != nullptr && other.m_storage_handler != nullptr) - { - auto tmp = any{}; - - // tmp := self - tmp.m_storage_handler = m_storage_handler; - m_storage_handler(operation::move, &tmp.m_storage, &m_storage); - m_storage_handler(operation::destroy, &m_storage, nullptr); - - // self := other - m_storage_handler = other.m_storage_handler; - m_storage_handler(operation::move, &m_storage, &other.m_storage); - m_storage_handler(operation::destroy, &other.m_storage, nullptr); - - // other := tmp - other.m_storage_handler = tmp.m_storage_handler; - other.m_storage_handler(operation::move, &other.m_storage, &tmp.m_storage); - } - else if (other.m_storage_handler != nullptr) - { - swap(m_storage_handler, other.m_storage_handler); - - // self := other - m_storage_handler(operation::move, &m_storage, &other.m_storage); - m_storage_handler(operation::destroy, &other.m_storage, nullptr); - } - else if (m_storage_handler != nullptr) - { - swap(m_storage_handler, other.m_storage_handler); - - // other := self - other.m_storage_handler(operation::move, &other.m_storage, &m_storage); - other.m_storage_handler(operation::destroy, &m_storage, nullptr); - } -} - -//----------------------------------------------------------------------------- -// Observers -//----------------------------------------------------------------------------- - -inline BPSTD_INLINE_VISIBILITY auto bpstd::any::has_value() const noexcept -> bool -{ - return m_storage_handler != nullptr; -} - -const inline BPSTD_INLINE_VISIBILITY auto bpstd::any::type() const noexcept -> const std::type_info & -{ - if (has_value()) { - auto* p = m_storage_handler(operation::type, nullptr, nullptr); - return (*static_cast(p)); - } - return typeid(void); -} - -//============================================================================= -// definition : non-member functions : class : any -//============================================================================= - -//----------------------------------------------------------------------------- -// utilities -//----------------------------------------------------------------------------- - -inline BPSTD_INLINE_VISIBILITY -void bpstd::swap(any& lhs, any& rhs) - noexcept -{ - lhs.swap(rhs); -} - -//----------------------------------------------------------------------------- -// casts -//----------------------------------------------------------------------------- - -template inline BPSTD_INLINE_VISIBILITY auto bpstd::any_cast(any &operand) -> T -{ - using underlying_type = remove_cvref_t; - - static_assert( - is_constructible::value, - "A program is ill-formed if T is not constructible from U&" - ); - - auto* p = any_cast(&operand); - if (p == nullptr) { - throw bad_any_cast{}; - } - return static_cast(*p); -} - -template inline BPSTD_INLINE_VISIBILITY auto bpstd::any_cast(any &&operand) -> T -{ - using underlying_type = remove_cvref_t; - - static_assert( - is_constructible::value, - "A program is ill-formed if T is not constructible from U" - ); - - auto* p = any_cast(&operand); - if (p == nullptr) { - throw bad_any_cast{}; - } - return static_cast(bpstd::move(*p)); -} - -template inline BPSTD_INLINE_VISIBILITY auto bpstd::any_cast(const any &operand) -> T -{ - using underlying_type = remove_cvref_t; - - static_assert( - is_constructible::value, - "A program is ill-formed if T is not constructible from const U&" - ); - - const auto* p = any_cast(&operand); - if (p == nullptr) { - throw bad_any_cast{}; - } - return static_cast(*p); -} - -template inline BPSTD_INLINE_VISIBILITY auto bpstd::any_cast(any *operand) const auto * cept->T * -{ - if (!operand) { - return nullptr; - } - if (operand->type() != typeid(T)) { - return nullptr; - } - - auto p = operand->m_storage_handler(any::operation::value, - &operand->m_storage, - nullptr); - return const_cast(static_cast(p)); -} - -template inline BPSTD_INLINE_VISIBILITY auto bpstd::any_cast(const any *operand) noexcept -> const T * -{ - if (!operand) { - return nullptr; - } - if (operand->type() != typeid(T)) { - return nullptr; - } - - const auto *p = operand->m_storage_handler(any::operation::value, &operand->m_storage, nullptr); - return static_cast(p); -} - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_ANY_HPP */ diff --git a/src/libs/vmisc/bpstd/chrono.hpp b/src/libs/vmisc/bpstd/chrono.hpp deleted file mode 100644 index ec22c1b3f..000000000 --- a/src/libs/vmisc/bpstd/chrono.hpp +++ /dev/null @@ -1,181 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file chrono.hpp -/// -/// \brief This header provides definitions from the C++ header -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_CHRONO_HPP -#define BPSTD_CHRONO_HPP - -#include "detail/config.hpp" - -#include // std::chrono::duration, std::chrono::system_clock, etc -#include // std::int32_t - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -namespace bpstd { - namespace chrono { - - template > - using duration = std::chrono::duration; - - template - using time_point = std::chrono::time_point; - - using nanoseconds = std::chrono::nanoseconds; - using microseconds = std::chrono::microseconds; - using milliseconds = std::chrono::milliseconds; - using seconds = std::chrono::seconds; - using minutes = std::chrono::minutes; - using hours = std::chrono::hours; - using days = std::chrono::duration>; - using weeks = std::chrono::duration>; - using months = std::chrono::duration>; - using years = std::chrono::duration>; - - using steady_clock = std::chrono::steady_clock; - using system_clock = std::chrono::system_clock; - - template - using sys_time = time_point; - using sys_seconds = sys_time; - using sys_days = sys_time; - - - } // namespace chrono - - //============================================================================ - // non-member functions - //============================================================================ - - //---------------------------------------------------------------------------- - // Literals - //---------------------------------------------------------------------------- - - inline namespace literals { - inline namespace chrono_literals { - - constexpr auto operator"" _h(unsigned long long x) -> std::chrono::hours; - constexpr auto operator"" _h(long double x) -> std::chrono::duration>; - - constexpr auto operator"" _min(unsigned long long x) -> chrono::minutes; - constexpr auto operator"" _min(long double x) -> chrono::duration>; - - constexpr auto operator"" _s(unsigned long long x) -> chrono::seconds; - constexpr auto operator"" _s(long double x) -> chrono::duration; - - constexpr auto operator"" _ms(unsigned long long x) -> chrono::milliseconds; - constexpr auto operator"" _ms(long double x) -> chrono::duration; - - constexpr auto operator"" _us(unsigned long long x) -> chrono::microseconds; - constexpr auto operator"" _us(long double x) -> chrono::duration; - - constexpr auto operator"" _ns(unsigned long long x) -> chrono::nanoseconds; - constexpr auto operator"" _ns(long double x) -> chrono::duration; - - } // namespace chrono_literals - } // namespace literals -} // namespace bpstd - -inline BPSTD_INLINE_VISIBILITY constexpr -auto - bpstd::literals::chrono_literals::operator"" _h(unsigned long long x) -> std::chrono::hours -{ - return chrono::hours{x}; -} - -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator"" _h(long double x) - -> std::chrono::duration> -{ - return chrono::duration>{x}; -} - -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator"" _min(unsigned long long x) -> bpstd::chrono::minutes -{ - return chrono::minutes{x}; -} - -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator"" _min(long double x) - -> bpstd::chrono::duration> -{ - return chrono::duration>{x}; -} - -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator"" _s(unsigned long long x) -> bpstd::chrono::seconds -{ - return chrono::seconds{x}; -} - -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator"" _s(long double x) -> bpstd::chrono::duration -{ - return chrono::duration{x}; -} - -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator"" _ms(unsigned long long x) -> bpstd::chrono::milliseconds -{ - return chrono::milliseconds{x}; -} - -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator"" _ms(long double x) -> bpstd::chrono::duration -{ - return chrono::duration{x}; -} - -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator"" _us(unsigned long long x) -> bpstd::chrono::microseconds -{ - return chrono::microseconds{x}; -} - -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator"" _us(long double x) -> bpstd::chrono::duration -{ - return chrono::duration{x}; -} - -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator"" _ns(unsigned long long x) -> bpstd::chrono::nanoseconds -{ - return chrono::nanoseconds{x}; -} - -inline BPSTD_INLINE_VISIBILITY constexpr -auto bpstd::literals::chrono_literals::operator"" _ns(long double x) -> bpstd::chrono::duration -{ - return chrono::duration{x}; -} - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_CHRONO_HPP */ diff --git a/src/libs/vmisc/bpstd/complex.hpp b/src/libs/vmisc/bpstd/complex.hpp deleted file mode 100644 index d7c5216c0..000000000 --- a/src/libs/vmisc/bpstd/complex.hpp +++ /dev/null @@ -1,110 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file complex.hpp -/// -/// \brief This header provides definitions from the C++ header -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_COMPLEX_HPP -#define BPSTD_COMPLEX_HPP - -#include "detail/config.hpp" - -#include - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -namespace bpstd { - - //============================================================================ - // class : complex - //============================================================================ - - template - using complex = std::complex; - - //============================================================================ - // literals : class : complex - //============================================================================ - - inline namespace literals { - inline namespace complex_literals { - - constexpr auto operator""_il(long double i) noexcept -> complex; - constexpr auto operator""_il(unsigned long long i) noexcept -> complex; - - constexpr auto operator""_i(long double i) noexcept -> complex; - constexpr auto operator""_i(unsigned long long i) noexcept -> complex; - - constexpr auto operator""_if(long double i) noexcept -> complex; - constexpr auto operator""_if(unsigned long long i) noexcept -> complex; - - } // namespace complex_literals - } // namespace literals -} // namespace bpstd - -//============================================================================== -// literals : class : complex -//============================================================================== - -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::literals::complex_literals::operator""_il(long double i) noexcept - -> bpstd::complex -{ - return complex{0, i}; -} - -inline BPSTD_INLINE_VISIBILITY constexpr auto -bpstd::literals::complex_literals::operator""_il(unsigned long long i) noexcept -> bpstd::complex -{ - return complex{0, static_cast(i)}; -} - -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::literals::complex_literals::operator""_i(long double i) noexcept - -> bpstd::complex -{ - return complex{0, static_cast(i)}; -} - -inline BPSTD_INLINE_VISIBILITY constexpr auto -bpstd::literals::complex_literals::operator""_i(unsigned long long i) noexcept -> bpstd::complex -{ - return complex{0, static_cast(i)}; -} - -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::literals::complex_literals::operator""_if(long double i) noexcept - -> bpstd::complex -{ - return complex{0, static_cast(i)}; -} - -inline BPSTD_INLINE_VISIBILITY constexpr auto -bpstd::literals::complex_literals::operator""_if(unsigned long long i) noexcept -> bpstd::complex -{ - return complex{0, static_cast(i)}; -} - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_COMPLEX_HPP */ diff --git a/src/libs/vmisc/bpstd/cstddef.hpp b/src/libs/vmisc/bpstd/cstddef.hpp deleted file mode 100644 index 6aa057dfa..000000000 --- a/src/libs/vmisc/bpstd/cstddef.hpp +++ /dev/null @@ -1,255 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file cstddef.hpp -/// -/// \brief This header provides definitions from the C++ header -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_CSTDDEF_HPP -#define BPSTD_CSTDDEF_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "detail/config.hpp" -#include "type_traits.hpp" - -#include // std::is_integral -#include // __cpp_lib_byte, and to proxy API - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -// The below implementation is based on GSL's implementation of 'gsl::byte' - -// VS2017 15.8 added support for the __cpp_lib_byte definition -// To do: drop _HAS_STD_BYTE when support for pre 15.8 expires -#if defined(_MSC_VER) - -// Turn MSVC /analyze rules that generate too much noise. -# pragma warning(push) -# pragma warning(disable : 26493) // don't use c-style cast - -# if !defined(BPSTD_USE_STD_BYTE) -// this tests if we are under MSVC and the standard lib has std::byte and it is -// enabled -# if defined(_HAS_STD_BYTE) && _HAS_STD_BYTE -# define BPSTD_USE_STD_BYTE 1 -# elif defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603 -# define BPSTD_USE_STD_BYTE 1 -# else -# define BPSTD_USE_STD_BYTE 0 -# endif -# endif // BPSTD_USE_STD_BYTE -#endif // _MSC_VER - -#if !defined(BPSTD_USE_STD_BYTE) - -// this tests if we are under GCC or Clang with enough -std:c++1z power to get us std::byte -// also check if libc++ version is sufficient (> 5.0) or libstc++ actually contains std::byte -# if defined(__cplusplus) && (__cplusplus >= 201703L) && \ - (defined(__cpp_lib_byte) && (__cpp_lib_byte >= 201603) || \ - defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION >= 5000)) -# define BPSTD_USE_STD_BYTE 1 -# else -# define BPSTD_USE_STD_BYTE 0 -# endif -#endif // BPSTD_USE_STD_BYTE - -namespace bpstd { - -#if BPSTD_USE_STD_BYTE - using std::byte; -#else - enum class BPSTD_MAY_ALIAS byte : unsigned char {}; - - //============================================================================ - // non-member functions : enum lass : byte - //============================================================================ - - //---------------------------------------------------------------------------- - // Bitwise operators - //---------------------------------------------------------------------------- - - template ::value>> - constexpr byte operator<<(byte b, Integer shift) noexcept; - template ::value>> - constexpr byte operator>>(byte b, Integer shift) noexcept; - - constexpr byte operator|(byte lhs, byte rhs) noexcept; - constexpr byte operator&(byte lhs, byte rhs) noexcept; - constexpr byte operator^(byte lhs, byte rhs) noexcept; - constexpr byte operator~(byte b) noexcept; - - //---------------------------------------------------------------------------- - // Compound Bitwise Operators - //---------------------------------------------------------------------------- - - template ::value>> - BPSTD_CPP14_CONSTEXPR byte& operator<<=(byte& b, Integer shift) noexcept; - template ::value>> - BPSTD_CPP14_CONSTEXPR byte& operator>>=(byte& b, Integer shift) noexcept; - BPSTD_CPP14_CONSTEXPR byte& operator|=(byte& lhs, byte rhs) noexcept; - BPSTD_CPP14_CONSTEXPR byte& operator&=(byte& lhs, byte rhs) noexcept; - - BPSTD_CPP14_CONSTEXPR byte& operator^=(byte& lhs, byte rhs) noexcept; - -#endif - - //---------------------------------------------------------------------------- - // Utilities - //---------------------------------------------------------------------------- - - template ::value>> - constexpr auto to_integer(byte b) noexcept -> Integer; - -} // namespace bpstd - -//============================================================================== -// definitions : non-member functions : enum class : byte -//============================================================================== - -#if !BPSTD_USE_STD_BYTE - -//------------------------------------------------------------------------------ -// Bitwise Operators -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::byte bpstd::operator<<(byte b, Integer shift) - noexcept -{ - return static_cast(static_cast(b) << shift); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::byte bpstd::operator>>(byte b, Integer shift) - noexcept -{ - return static_cast(static_cast(b) >> shift); -} - -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::byte bpstd::operator|(byte lhs, byte rhs) - noexcept -{ - return static_cast( - static_cast(lhs) | static_cast(rhs) - ); -} - -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::byte bpstd::operator&(byte lhs, byte rhs) - noexcept -{ - return static_cast( - static_cast(lhs) & static_cast(rhs) - ); -} - -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::byte bpstd::operator^(byte lhs, byte rhs) - noexcept -{ - return static_cast( - static_cast(lhs) ^ static_cast(rhs) - ); -} - -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::byte bpstd::operator~(byte b) - noexcept -{ - return static_cast(~static_cast(b)); -} - -//------------------------------------------------------------------------------ -// Compound Bitwise Operators -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR -bpstd::byte& bpstd::operator<<=(byte& b, Integer shift) - noexcept -{ - return b = static_cast(static_cast(b) << shift); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR -bpstd::byte& bpstd::operator>>=(byte& b, Integer shift) - noexcept -{ - return b = static_cast(static_cast(b) >> shift); -} - -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR -bpstd::byte& bpstd::operator|=(byte& lhs, byte rhs) - noexcept -{ - return lhs = static_cast( - static_cast(lhs) | static_cast(rhs) - ); -} - -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR -bpstd::byte& bpstd::operator&=(byte& lhs, byte rhs) - noexcept -{ - return lhs = static_cast( - static_cast(lhs) & static_cast(rhs) - ); -} - -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR -bpstd::byte& bpstd::operator^=(byte& lhs, byte rhs) - noexcept -{ - return lhs = static_cast( - static_cast(lhs) ^ static_cast(rhs) - ); -} - -#endif // BPSTD_USE_STD_BYTE - -//------------------------------------------------------------------------------ -// Utilities -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::to_integer(byte b) noexcept -> Integer -{ - return static_cast(b); -} - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_CSTDDEF_HPP */ diff --git a/src/libs/vmisc/bpstd/detail/config.hpp b/src/libs/vmisc/bpstd/detail/config.hpp deleted file mode 100644 index 751e4dba8..000000000 --- a/src/libs/vmisc/bpstd/detail/config.hpp +++ /dev/null @@ -1,103 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file config.hpp -/// -/// \brief This header provides configuration data for the bpstd library -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_DETAIL_CONFIG_HPP -#define BPSTD_DETAIL_CONFIG_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#if !defined(__cplusplus) -# error This library requires a C++ compiler -#endif - -// _MSC_VER check is due to MSVC not defining __cplusplus to be 201103L -#if !defined(_MSC_VER) && __cplusplus < 201103L -# error This library must be compiled with C++11 support -#endif - -#if defined(__cplusplus) && __cplusplus >= 201402L -# define BPSTD_CPP14_CONSTEXPR constexpr -# define BPSTD_HAS_TEMPLATE_VARIABLES 1 -#else -# define BPSTD_CPP14_CONSTEXPR -# define BPSTD_HAS_TEMPLATE_VARIABLES 0 -#endif - -#if defined(__cplusplus) && __cplusplus >= 201703L -# define BPSTD_CPP17_CONSTEXPR constexpr -# define BPSTD_CPP17_INLINE inline -# define BPSTD_HAS_INLINE_VARIABLES 1 -#else -# define BPSTD_CPP17_CONSTEXPR -# define BPSTD_CPP17_INLINE -# define BPSTD_HAS_INLINE_VARIABLES 0 -#endif - -#define BPSTD_UNUSED(x) static_cast(x) - -// Use __may_alias__ attribute on gcc and clang -#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ > 5) -# define BPSTD_MAY_ALIAS __attribute__((__may_alias__)) -#else // defined(__clang__) || defined __GNUC__ -# define BPSTD_MAY_ALIAS -#endif // defined __clang__ || defined __GNUC__ - -#if !defined(BPSTD_INLINE_VISIBILITY) -// When using 'clang-cl', don't forceinline -- since it results in code generation -// failures in 'variant' -# if defined(__clang__) && defined(_MSC_VER) -# define BPSTD_INLINE_VISIBILITY __attribute__((visibility("hidden"), no_instrument_function)) -# elif defined(__clang__) || defined(__GNUC__) -# define BPSTD_INLINE_VISIBILITY __attribute__((visibility("hidden"), always_inline, no_instrument_function)) -# elif defined(_MSC_VER) -# define BPSTD_INLINE_VISIBILITY __forceinline -# else -# define BPSTD_INLINE_VISIBILITY -# endif -#endif // !defined(BPSTD_INLINE_VISIBILITY) - -#if defined(_MSC_VER) -# define BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE \ - __pragma(warning(push)) \ - __pragma(warning(disable:4714)) \ - __pragma(warning(disable:4100)) -#else -# define BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE -#endif - -#if defined(_MSC_VER) -# define BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE \ - __pragma(warning(pop)) -#else -# define BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE -#endif - -#endif /* BPSTD_DETAIL_CONFIG_HPP */ diff --git a/src/libs/vmisc/bpstd/detail/enable_overload.hpp b/src/libs/vmisc/bpstd/detail/enable_overload.hpp deleted file mode 100644 index f7a7e27a2..000000000 --- a/src/libs/vmisc/bpstd/detail/enable_overload.hpp +++ /dev/null @@ -1,78 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file enable_overload.hpp -/// -/// \brief This internal header provides the definition of a SFINAE utility -/// for conditionally enabling overloads -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_DETAIL_ENABLE_OVERLOAD_HPP -#define BPSTD_DETAIL_ENABLE_OVERLOAD_HPP - -#if !defined(_MSC_VER) -#pragma GCC system_header -#pragma clang system_header -#endif - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -namespace bpstd { - namespace detail { - - /// \brief Similar to enable_if, but doesn't sfinae-away a type; instead - /// produces an uninstantiable unique type when true - /// - /// This is used to selectively disable constructors, since sfinae doesn't - /// work for copy/move constructors - template - struct enable_overload_if - { - using type = T; - }; - - template - struct enable_overload_if - { - class type{ type() = delete; ~type() = delete; }; - }; - - template - using enable_overload_if_t = typename enable_overload_if::type; - - /// \brief Inverse of enable_overload_if - template - using disable_overload_if = enable_overload_if; - - /// \brief Convenience alias to retrieve the ::type member of - /// disable_overload_if - template - using disable_overload_if_t = typename disable_overload_if::type; - - } // namespace detail -} // namespace bpstd - -#endif /* BPSTD_DETAIL_ENABLE_OVERLOAD_HPP */ diff --git a/src/libs/vmisc/bpstd/detail/invoke.hpp b/src/libs/vmisc/bpstd/detail/invoke.hpp deleted file mode 100644 index 4e02c6638..000000000 --- a/src/libs/vmisc/bpstd/detail/invoke.hpp +++ /dev/null @@ -1,188 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file invoke.hpp -/// -/// \brief This internal header provides the definition of the INVOKE overload -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_DETAIL_INVOKE_HPP -#define BPSTD_DETAIL_INVOKE_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "config.hpp" // BPSTD_INLINE_VISIBILITY -#include "move.hpp" // forward -#include // std::true_type, std::false_type, etc -#include // std::reference_wrapper - -#include - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -namespace bpstd { - namespace detail { - - template - struct is_reference_wrapper : std::false_type {}; - - template - struct is_reference_wrapper> : std::true_type {}; - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto INVOKE(T Base::*pmf, Derived&& ref, Args&&... args) - noexcept(noexcept((::bpstd::forward(ref).*pmf)(::bpstd::forward(args)...))) - -> typename std::enable_if::value && - std::is_base_of::type>::value, - decltype((::bpstd::forward(ref).*pmf)(::bpstd::forward(args)...))>::type - { - return (bpstd::forward(ref).*pmf)(bpstd::forward(args)...); - } - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto INVOKE(T Base::*pmf, RefWrap&& ref, Args&&... args) - noexcept(noexcept((ref.get().*pmf)(std::forward(args)...))) - -> typename std::enable_if::value && - is_reference_wrapper::type>::value, - decltype((ref.get().*pmf)(::bpstd::forward(args)...))>::type - { - return (ref.get().*pmf)(bpstd::forward(args)...); - } - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto INVOKE(T Base::*pmf, Pointer&& ptr, Args&&... args) - noexcept(noexcept(((*std::forward(ptr)).*pmf)(std::forward(args)...))) - -> typename std::enable_if::value && - !is_reference_wrapper::type>::value && - !std::is_base_of::type>::value, - decltype(((*::bpstd::forward(ptr)).*pmf)(::bpstd::forward(args)...))>::type - { - return ((*bpstd::forward(ptr)).*pmf)(bpstd::forward(args)...); - } - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto INVOKE(T Base::*pmd, Derived&& ref) - noexcept(noexcept(std::forward(ref).*pmd)) - -> typename std::enable_if::value && - std::is_base_of::type>::value, - decltype(::bpstd::forward(ref).*pmd)>::type - { - return bpstd::forward(ref).*pmd; - } - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto INVOKE(T Base::*pmd, RefWrap&& ref) - noexcept(noexcept(ref.get().*pmd)) - -> typename std::enable_if::value && - is_reference_wrapper::type>::value, - decltype(ref.get().*pmd)>::type - { - return ref.get().*pmd; - } - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto INVOKE(T Base::*pmd, Pointer&& ptr) - noexcept(noexcept((*std::forward(ptr)).*pmd)) - -> typename std::enable_if::value && - !is_reference_wrapper::type>::value && - !std::is_base_of::type>::value, - decltype((*::bpstd::forward(ptr)).*pmd)>::type - { - return (*bpstd::forward(ptr)).*pmd; - } - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto INVOKE(F&& f, Args&&... args) - noexcept(noexcept(std::forward(f)(std::forward(args)...))) - -> typename std::enable_if::type>::value, - decltype(::bpstd::forward(f)(::bpstd::forward(args)...))>::type - { - return bpstd::forward(f)(bpstd::forward(args)...); - } - - //========================================================================== - // is_nothrow_invocable - //========================================================================== - - template - struct is_nothrow_invocable - { - template - static auto test( Fn2&&, Args2&&... ) - -> decltype(INVOKE(std::declval(), std::declval()...), - std::integral_constant(), std::declval()...))>{}); - - static auto test(...) - -> std::false_type; - - using type = decltype(test(std::declval(), std::declval()...)); - static constexpr bool value = type::value; - }; - - //========================================================================== - // is_invocable - //========================================================================== - - template - struct is_invocable - { - template - static auto test( Fn2&&, Args2&&... ) - -> decltype(INVOKE(std::declval(), std::declval()...), std::true_type{}); - - static auto test(...) - -> std::false_type; - - using type = decltype(test(std::declval(), std::declval()...)); - static constexpr bool value = type::value; - }; - - // Used to SFINAE away non-invocable types - template - struct invoke_result_impl{}; - - template - struct invoke_result_impl{ - using type = decltype(INVOKE(std::declval(), std::declval()...)); - }; - - template - struct invoke_result - : invoke_result_impl::value, Fn, Args...>{}; - - } // namespace detail -} // namespace bpstd - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_DETAIL_INVOKE_HPP */ diff --git a/src/libs/vmisc/bpstd/detail/move.hpp b/src/libs/vmisc/bpstd/detail/move.hpp deleted file mode 100644 index 793b912cd..000000000 --- a/src/libs/vmisc/bpstd/detail/move.hpp +++ /dev/null @@ -1,104 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file move.hpp -/// -/// \brief This internal header provides the definition of the move and forward -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_DETAIL_MOVE_HPP -#define BPSTD_DETAIL_MOVE_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "config.hpp" - -#include - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -namespace bpstd { - - //---------------------------------------------------------------------------- - // Utilities - //---------------------------------------------------------------------------- - - /// \{ - /// \brief Forwards a reference \p t - /// - /// \tparam T the type to forward - /// \param t the reference - /// \return the forwarded reference -template constexpr auto forward(typename std::remove_reference::type &t) noexcept -> T &&; -template constexpr auto forward(typename std::remove_reference::type &&t) noexcept -> T &&; -/// \} - -/// \brief Casts \p x to an rvalue -/// -/// \param x the parameter to move -/// \return rvalue reference to \p x -template constexpr auto move(T &x) noexcept -> T &&; - -/// \brief Casts \p x to an rvalue -/// -/// \param x the parameter to move -/// \return rvalue reference to \p x -template constexpr auto move(T &&x) noexcept -> typename std::remove_reference::type &&; - -} // namespace bpstd - -//------------------------------------------------------------------------------ -// Utilities -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::forward(typename std::remove_reference::type &t) noexcept - -> T && -{ - return static_cast(t); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::forward(typename std::remove_reference::type &&t) noexcept - -> T && -{ - return static_cast(t); -} - -template inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::move(T &x) noexcept -> T && -{ - return static_cast(x); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::move(T &&x) noexcept -> typename std::remove_reference::type && -{ - return static_cast(x); -} - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_DETAIL_MOVE_HPP */ diff --git a/src/libs/vmisc/bpstd/detail/nth_type.hpp b/src/libs/vmisc/bpstd/detail/nth_type.hpp deleted file mode 100644 index 2d3edb925..000000000 --- a/src/libs/vmisc/bpstd/detail/nth_type.hpp +++ /dev/null @@ -1,64 +0,0 @@ -/***************************************************************************** - * \file nth_type.hpp - * - * \brief This internal header provides the definition of the INVOKE overload - *****************************************************************************/ - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_DETAIL_NTH_TYPE_HPP -#define BPSTD_DETAIL_NTH_TYPE_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include // std::size_t - -namespace bpstd { - namespace detail { - - /// \brief Gets the nth type from a variadic pack of arguments - /// - /// \tparam N the argument to retrieve - /// \tparam Args the arguments to extract from - template - struct nth_type; - - template - struct nth_type : nth_type{}; - - template - struct nth_type<0,Arg0,Args...> - { - using type = Arg0; - }; - - template - using nth_type_t = typename nth_type::type; - - } // namespace detail -} // namespace bpstd - -#endif /* BPSTD_DETAIL_NTH_TYPE_HPP */ diff --git a/src/libs/vmisc/bpstd/detail/proxy_iterator.hpp b/src/libs/vmisc/bpstd/detail/proxy_iterator.hpp deleted file mode 100644 index a1d162ab2..000000000 --- a/src/libs/vmisc/bpstd/detail/proxy_iterator.hpp +++ /dev/null @@ -1,428 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file proxy_iterator.hpp -/// -/// \brief This internal header provides the definition of an iterator wrapper -/// type used for uniqueness -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_DETAIL_PROXY_ITERATOR_HPP -#define BPSTD_DETAIL_PROXY_ITERATOR_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "config.hpp" -#include - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -namespace bpstd { - namespace detail { - - //========================================================================== - // class : proxy_iterator - //========================================================================== - - /////////////////////////////////////////////////////////////////////////// - /// \brief A thin wrapper around a different iterator type to add - /// uniqueness - /// - /// This makes any regular Iterator type such as a pointer to be unique, - /// and incomparable to other pointers. - /// - /// \tparam Iterator the pointer type to wrap - /// \tparam U a type to make this iterator unique, and not comparable with - /// other proxy_iterators - /////////////////////////////////////////////////////////////////////////// - template - class proxy_iterator -#if __cplusplus < 201703L - : public std::iterator< - typename std::iterator_traits::iterator_category, - typename std::iterator_traits::value_type, - typename std::iterator_traits::difference_type, - typename std::iterator_traits::pointer, - typename std::iterator_traits::reference - > -#endif - { -#if __cplusplus < 201703L - using base_type = std::iterator< - typename std::iterator_traits::iterator_category, - typename std::iterator_traits::value_type, - typename std::iterator_traits::difference_type, - typename std::iterator_traits::pointer, - typename std::iterator_traits::reference - >; -#endif - //------------------------------------------------------------------------ - // Public Member Types - //------------------------------------------------------------------------ - public: - -#if __cplusplus >= 201703L - using iterator_category = typename std::iterator_traits::iterator_category; - using value_type = typename std::iterator_traits::value_type; - using pointer = typename std::iterator_traits::pointer; - using reference = typename std::iterator_traits::reference; - using difference_type = typename std::iterator_traits::difference_type; -#else - using iterator_category = typename base_type::iterator_category; - using value_type = typename base_type::value_type; - using pointer = typename base_type::pointer; - using reference = typename base_type::reference; - using difference_type = typename base_type::difference_type; -#endif - - //------------------------------------------------------------------------ - // Constructor - //------------------------------------------------------------------------ - public: - - /// \brief Default constructs this proxy_iterator by default-constructing - /// the underlying iterator - constexpr proxy_iterator() = default; - - /// \brief Constructs a proxy_iterator from a given pointer - /// - /// \param it the iterator to construct this proxy_iterator - constexpr explicit proxy_iterator(const Iterator& it) noexcept; - - /// \brief Convert-constructs a proxy_iterator from a proxy iterator with - /// the same tag - /// - /// \param it the iterator - template - constexpr proxy_iterator(const proxy_iterator& it) noexcept; - - /// \brief Copy-constructs a proxy_iterator - /// - /// \param other the iterator to copy - constexpr proxy_iterator(const proxy_iterator& other) noexcept = default; - - /// \brief Move-constructs a proxy_iterator - /// - /// \param other the iterator to move - constexpr proxy_iterator(proxy_iterator&& other) noexcept = default; - - /// \brief Copy-assigns a proxy_iterator - /// - /// \param it the iterator to copy - template auto operator=(const proxy_iterator &it) noexcept -> proxy_iterator &; - - /// \brief Copy-assigns a proxy_iterator - /// - /// \param other the iterator to copy - auto operator=(const proxy_iterator &other) noexcept -> proxy_iterator & = default; - - /// \brief Move-assigns a proxy_iterator - /// - /// \param other the iterator to move - auto operator=(proxy_iterator &&other) noexcept -> proxy_iterator & = default; - - //------------------------------------------------------------------------ - // Iteration - //------------------------------------------------------------------------ - public: - BPSTD_CPP14_CONSTEXPR auto operator++() noexcept -> proxy_iterator &; - BPSTD_CPP14_CONSTEXPR auto operator++(int) noexcept -> proxy_iterator; - BPSTD_CPP14_CONSTEXPR auto operator--() noexcept -> proxy_iterator &; - BPSTD_CPP14_CONSTEXPR auto operator--(int) noexcept -> proxy_iterator; - - //------------------------------------------------------------------------ - // Random Access - //------------------------------------------------------------------------ - public: - BPSTD_CPP14_CONSTEXPR auto operator+=(difference_type n) noexcept -> proxy_iterator &; - BPSTD_CPP14_CONSTEXPR auto operator-=(difference_type n) noexcept -> proxy_iterator &; - - constexpr auto operator-(const proxy_iterator &rhs) const noexcept -> difference_type; - constexpr auto operator[](difference_type index) const noexcept -> reference; - - //------------------------------------------------------------------------ - // Observers - //------------------------------------------------------------------------ - public: - constexpr auto operator->() const noexcept -> pointer; - constexpr auto operator*() const noexcept -> reference; - - //------------------------------------------------------------------------ - // Comparison - //------------------------------------------------------------------------ - public: - constexpr auto operator==(const proxy_iterator &rhs) const noexcept -> bool; - constexpr auto operator!=(const proxy_iterator &rhs) const noexcept -> bool; - constexpr auto operator<(const proxy_iterator &rhs) const noexcept -> bool; - constexpr auto operator<=(const proxy_iterator &rhs) const noexcept -> bool; - constexpr auto operator>(const proxy_iterator &rhs) const noexcept -> bool; - constexpr auto operator>=(const proxy_iterator &rhs) const noexcept -> bool; - - //------------------------------------------------------------------------ - // Private Members - //------------------------------------------------------------------------ - private: - - Iterator m_iter; ///< The iterator used for iteration - - template friend class proxy_iterator; - }; - - //========================================================================== - // non-member functions : class : proxy_iterator - //========================================================================== - - //-------------------------------------------------------------------------- - // Random Access - //-------------------------------------------------------------------------- - - template - BPSTD_CPP14_CONSTEXPR auto operator+(const proxy_iterator &lhs, - typename proxy_iterator::difference_type rhs) noexcept - -> proxy_iterator; - - template - BPSTD_CPP14_CONSTEXPR auto operator+(typename proxy_iterator::difference_type lhs, - const proxy_iterator &rhs) noexcept - -> proxy_iterator; - - template - BPSTD_CPP14_CONSTEXPR auto operator-(const proxy_iterator &lhs, - typename proxy_iterator::difference_type rhs) noexcept - -> proxy_iterator; - - } // namespace detail -} // namespace bpstd - -//============================================================================== -// definitions : class : proxy_iterator -//============================================================================== - -//------------------------------------------------------------------------------ -// Constructors / Assignment -//------------------------------------------------------------------------------ - -template -inline constexpr bpstd::detail::proxy_iterator:: - proxy_iterator(const Iterator& it) - noexcept - : m_iter{it} -{ - -} - -template -template -inline constexpr bpstd::detail::proxy_iterator - ::proxy_iterator(const proxy_iterator& it) - noexcept - : m_iter{it.m_iter} -{ - -} - -template -template -inline auto bpstd::detail::proxy_iterator::operator=(const proxy_iterator &it) noexcept - -> bpstd::detail::proxy_iterator & -{ - m_iter = it.m_iter; - - return (*this); -} - -//------------------------------------------------------------------------------ -// Iteration -//------------------------------------------------------------------------------ - -template -inline BPSTD_CPP14_CONSTEXPR auto bpstd::detail::proxy_iterator::operator++() noexcept - -> bpstd::detail::proxy_iterator & -{ - ++m_iter; - return (*this); -} - -template -inline BPSTD_CPP14_CONSTEXPR auto bpstd::detail::proxy_iterator::operator++(int) noexcept - -> bpstd::detail::proxy_iterator -{ - return proxy_iterator{m_iter++}; -} - -//------------------------------------------------------------------------------ - -template -inline BPSTD_CPP14_CONSTEXPR auto bpstd::detail::proxy_iterator::operator--() noexcept - -> bpstd::detail::proxy_iterator & -{ - --m_iter; - return (*this); -} - -template -inline BPSTD_CPP14_CONSTEXPR auto bpstd::detail::proxy_iterator::operator--(int) noexcept - -> bpstd::detail::proxy_iterator -{ - return proxy_iterator{m_iter--}; -} - -//------------------------------------------------------------------------------ -// Random Access -//------------------------------------------------------------------------------ - -template -inline BPSTD_CPP14_CONSTEXPR auto bpstd::detail::proxy_iterator::operator+=(difference_type n) noexcept - -> bpstd::detail::proxy_iterator & -{ - m_iter += n; - return (*this); -} - -template -inline BPSTD_CPP14_CONSTEXPR auto bpstd::detail::proxy_iterator::operator-=(difference_type n) noexcept - -> bpstd::detail::proxy_iterator & -{ - m_iter -= n; - return (*this); -} - -template -inline constexpr auto -bpstd::detail::proxy_iterator::operator-(const proxy_iterator &rhs) const noexcept -> - typename bpstd::detail::proxy_iterator::difference_type -{ - return m_iter - rhs.m_iter; -} - -template -inline constexpr auto bpstd::detail::proxy_iterator::operator[](difference_type index) const noexcept -> - typename bpstd::detail::proxy_iterator::reference -{ - return m_iter[index]; -} - -//------------------------------------------------------------------------------ -// Observers -//------------------------------------------------------------------------------ - -template -inline constexpr auto bpstd::detail::proxy_iterator::operator->() const noexcept -> - typename bpstd::detail::proxy_iterator::pointer -{ - return m_iter; -} - -template -inline constexpr auto bpstd::detail::proxy_iterator::operator*() const noexcept -> - typename bpstd::detail::proxy_iterator::reference -{ - return *m_iter; -} - -//------------------------------------------------------------------------------ -// Comparisons -//------------------------------------------------------------------------------ - -template -inline constexpr auto bpstd::detail::proxy_iterator::operator==(const proxy_iterator &rhs) const noexcept - -> bool -{ - return m_iter == rhs.m_iter; -} - -template -inline constexpr auto bpstd::detail::proxy_iterator::operator!=(const proxy_iterator &rhs) const noexcept - -> bool -{ - return m_iter != rhs.m_iter; -} - -template -inline constexpr auto bpstd::detail::proxy_iterator::operator<(const proxy_iterator &rhs) const noexcept - -> bool -{ - return m_iter < rhs.m_iter; -} - -template -inline constexpr auto bpstd::detail::proxy_iterator::operator<=(const proxy_iterator &rhs) const noexcept - -> bool -{ - return m_iter <= rhs.m_iter; -} - -template -inline constexpr auto bpstd::detail::proxy_iterator::operator>(const proxy_iterator &rhs) const noexcept - -> bool -{ - return m_iter > rhs.m_iter; -} - -template -inline constexpr auto bpstd::detail::proxy_iterator::operator>=(const proxy_iterator &rhs) const noexcept - -> bool -{ - return m_iter >= rhs.m_iter; -} - -//============================================================================== -// definitions : non-member functions : class : proxy_iterator -//============================================================================== - -//------------------------------------------------------------------------------ -// Random Access (free functions) -//------------------------------------------------------------------------------ - -template -inline BPSTD_CPP14_CONSTEXPR auto -bpstd::detail::operator+(const proxy_iterator &lhs, - typename proxy_iterator::difference_type rhs) noexcept - -> bpstd::detail::proxy_iterator -{ - return proxy_iterator{lhs} += rhs; -} - -template -inline BPSTD_CPP14_CONSTEXPR auto bpstd::detail::operator+(typename proxy_iterator::difference_type lhs, - const proxy_iterator &rhs) noexcept - -> bpstd::detail::proxy_iterator -{ - return proxy_iterator{rhs} += lhs; -} - -template -inline BPSTD_CPP14_CONSTEXPR auto -bpstd::detail::operator-(const proxy_iterator &lhs, - typename proxy_iterator::difference_type rhs) noexcept - -> bpstd::detail::proxy_iterator -{ - return proxy_iterator{lhs} -= rhs; -} - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_DETAIL_PROXY_ITERATOR_HPP */ diff --git a/src/libs/vmisc/bpstd/detail/variant_base.hpp b/src/libs/vmisc/bpstd/detail/variant_base.hpp deleted file mode 100644 index 687c9f01c..000000000 --- a/src/libs/vmisc/bpstd/detail/variant_base.hpp +++ /dev/null @@ -1,240 +0,0 @@ -/***************************************************************************** - * \file variant_base.hpp - * - * \brief This internal header provides the definition of a utility for - * variant, variant_base - *****************************************************************************/ - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_DETAIL_VARIANT_BASE_HPP -#define BPSTD_DETAIL_VARIANT_BASE_HPP - -#include "config.hpp" // BPSTD_CPP14_CONSTEXPR -#include "variant_union.hpp" // detail::variant_union - -#include // std::size_t -#include // std::forward - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -namespace bpstd { - namespace detail { - - //========================================================================== - // class : variant_base - //========================================================================== - - //////////////////////////////////////////////////////////////////////////// - /// \brief The base class used by variant - //////////////////////////////////////////////////////////////////////////// - template - class variant_base; - - //========================================================================== - // class : variant_base - //========================================================================== - - template - class variant_base - { - //------------------------------------------------------------------------ - // Constructors - //------------------------------------------------------------------------ - public: - - constexpr variant_base(); - - template - constexpr variant_base(variant_index_tag, Args&&...args); - - //------------------------------------------------------------------------ - // Protected Members - //------------------------------------------------------------------------ - protected: - - variant_union m_union; - std::size_t m_index; - - //--------------------------------------------------------------------- - // Protected Member Functions - //--------------------------------------------------------------------- - protected: - - void destroy_active_object(); - }; - - //========================================================================== - // class : variant_base - //========================================================================== - - template - class variant_base - { - public: - - constexpr variant_base(); - - template - constexpr variant_base(variant_index_tag, Args&&...args); - - ~variant_base(); - - //--------------------------------------------------------------------- - // Protected Members - //--------------------------------------------------------------------- - protected: - - variant_union m_union; - std::size_t m_index; - - //--------------------------------------------------------------------- - // Protected Member Functions - //--------------------------------------------------------------------- - protected: - - void destroy_active_object(); - - //--------------------------------------------------------------------- - // Private Static Member Functions - //--------------------------------------------------------------------- - private: - - struct destroy_visitor - { - template - inline BPSTD_INLINE_VISIBILITY - void operator()(T& v) { - v.~T(); - } - }; - }; - - } // namespace detail -} // namespace bpstd - -//============================================================================== -// class : variant_base -//============================================================================== - -//------------------------------------------------------------------------------ -// Constructors -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::detail::variant_base::variant_base() - : m_union{}, - m_index{static_cast(-1)} -{ - -} - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::detail::variant_base::variant_base(variant_index_tag, - Args&&...args) - : m_union{variant_index_tag{}, std::forward(args)...}, - m_index{N} -{ - -} - -//------------------------------------------------------------------------------ -// Protected Members -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY -void bpstd::detail::variant_base::destroy_active_object() -{ - m_index = static_cast(-1); -} - -//============================================================================== -// class : variant_base -//============================================================================== - -//------------------------------------------------------------------------------ -// Constructors / Destructor -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::detail::variant_base::variant_base() - : m_union{}, - m_index{static_cast(-1)} -{ - -} - -#if defined(_MSC_VER) -# pragma warning(push) -# pragma warning(disable:4702) -#endif - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::detail::variant_base::variant_base(variant_index_tag, - Args&&...args) - : m_union{variant_index_tag{}, std::forward(args)...}, - m_index{N} -{ - -} - -#if defined(_MSC_VER) -# pragma warning(pop) -#endif - -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY -bpstd::detail::variant_base::~variant_base() -{ - destroy_active_object(); -} - -//------------------------------------------------------------------------------ -// Protected Members -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY -void bpstd::detail::variant_base::destroy_active_object() -{ - if (m_index == static_cast(-1)) { - return; - } - - visit_union(m_index, destroy_visitor{}, m_union); - m_index = static_cast(-1); -} - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_DETAIL_VARIANT_BASE_HPP */ diff --git a/src/libs/vmisc/bpstd/detail/variant_fwds.hpp b/src/libs/vmisc/bpstd/detail/variant_fwds.hpp deleted file mode 100644 index aba8339a0..000000000 --- a/src/libs/vmisc/bpstd/detail/variant_fwds.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/***************************************************************************** - * \file variant_fwds.hpp - * - * \brief This internal header provides forward declarations of various - * variant types used internally - *****************************************************************************/ - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_DETAIL_VARIANT_FWDS_HPP -#define BPSTD_DETAIL_VARIANT_FWDS_HPP - -namespace bpstd { - namespace detail { - - template - union variant_union; - - template - class variant_base; - - } // namespace detail - - template - class variant; - -} // namespace bpstd - -#endif /* BPSTD_DETAIL_VARIANT_FWDS_HPP */ diff --git a/src/libs/vmisc/bpstd/detail/variant_traits.hpp b/src/libs/vmisc/bpstd/detail/variant_traits.hpp deleted file mode 100644 index cb1354aa8..000000000 --- a/src/libs/vmisc/bpstd/detail/variant_traits.hpp +++ /dev/null @@ -1,112 +0,0 @@ -/***************************************************************************** - * \file variant_traits.hpp - * - * \brief This internal header provides forward declarations of various - * variant traits - *****************************************************************************/ - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_DETAIL_VARIANT_TRAITS_HPP -#define BPSTD_DETAIL_VARIANT_TRAITS_HPP - -#include "config.hpp" -#include "variant_fwds.hpp" -#include "invoke.hpp" // invoke_result - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -namespace bpstd { - namespace detail { - - template - struct variant_first_type; - - template - struct variant_first_type> - { - using type = Type0; - }; - - template - struct variant_first_type> - { - using type = Type0; - }; - - template - struct variant_first_type> - { - using type = Type0; - }; - - template - struct variant_first_type - { - using type = typename variant_first_type::type&; - }; - - template - struct variant_first_type - { - using type = typename variant_first_type::type&&; - }; - - template - struct variant_first_type - { - using type = const typename variant_first_type::type; - }; - - template - struct variant_first_type - { - using type = const typename variant_first_type::type&; - }; - - template - struct variant_first_type - { - using type = const typename variant_first_type::type&&; - }; - - template - using variant_first_type_t = typename variant_first_type::type; - - //-------------------------------------------------------------------------- - - template - struct variant_visitor_invoke_result - : invoke_result...>{}; - - template - using variant_visitor_invoke_result_t - = typename variant_visitor_invoke_result::type; - - } // namespace detail -} // namespace bpstd - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_DETAIL_VARIANT_TRAITS_HPP */ diff --git a/src/libs/vmisc/bpstd/detail/variant_union.hpp b/src/libs/vmisc/bpstd/detail/variant_union.hpp deleted file mode 100644 index 9681adc99..000000000 --- a/src/libs/vmisc/bpstd/detail/variant_union.hpp +++ /dev/null @@ -1,554 +0,0 @@ -/***************************************************************************** - * \file variant_union.hpp - * - * \brief This internal header provides the definition of a utility for - * variant, variant_union - *****************************************************************************/ - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_DETAIL_VARIANT_UNION_HPP -#define BPSTD_DETAIL_VARIANT_UNION_HPP - -#include "config.hpp" // BPSTD_CPP14_CONSTEXPR -#include "nth_type.hpp" // detail::nth_type -#include "move.hpp" // forward -#include "variant_traits.hpp" - -#include // std::size_t -#include // std::decay -#include - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -namespace bpstd { - namespace detail { - - template - struct match_cv { - using type = To; - }; - template - struct match_cv { - using type = const To; - }; - template - struct match_cv { - using type = volatile To; - }; - template - struct match_cv { - using type = const volatile To; - }; - - template - struct match_reference { - using type = To&&; - }; - - template - struct match_reference { - using type = To&&; - }; - - template - struct match_reference { - using type = To&; - }; - - template - using match_cvref = match_reference::type,To - >::type - >; - - template - using match_cvref_t = typename match_cvref::type; - - //////////////////////////////////////////////////////////////////////////// - /// \brief A tag type used to represent an empty variant - //////////////////////////////////////////////////////////////////////////// - struct variant_empty{}; - - template - struct variant_index_tag{}; - - ///////////////////////////////////////////////////////////////////////////// - /// \brief Implementation of the variant_union class - /// - /// \tparam IsTrivial true if all the types in the variant are trivial - /// \tparam Types the types in the variant - //////////////////////////////////////////////////////////////////////////// - template - union variant_union; - - /// \brief A type-trait for retrieving the number of elements in a variant - /// union - template - struct variant_union_size - : variant_union_size::type>{}; - - template - struct variant_union_size> - : std::integral_constant{}; - - //========================================================================== - // union : variant_union - //========================================================================== - - // Partial specialization: All types are trivial; is trivially destructible - template - union variant_union - { - //------------------------------------------------------------------------ - // Public Members Types - //------------------------------------------------------------------------ - - using current_type = Type0; - using next_type = variant_union; - - //------------------------------------------------------------------------ - // Public Members - //------------------------------------------------------------------------ - - variant_empty empty; - current_type current; - next_type next; - - //------------------------------------------------------------------------ - // Constructors - //------------------------------------------------------------------------ - - constexpr variant_union(); - - template - constexpr variant_union(variant_index_tag<0>, Args&&...args); - - template - constexpr variant_union(variant_index_tag, Args&&...args); - }; - - //========================================================================== - // union : variant_union - //========================================================================== - - // Partial specialization: At least one type is not trivial - // This specialization needs to exist to explicitly define ~variant_union, - // but is otherwise the *only* difference - template - union variant_union - { - //------------------------------------------------------------------------ - // Public Members Types - //------------------------------------------------------------------------ - - using current_type = Type0; - using next_type = variant_union; - - //------------------------------------------------------------------------ - // Public Members - //------------------------------------------------------------------------ - - variant_empty empty; - current_type current; - next_type next; - - //------------------------------------------------------------------------ - // Constructors / Destructor - //------------------------------------------------------------------------ - - constexpr variant_union(); - - template - constexpr variant_union(variant_index_tag<0>, Args&&...args); - - template - constexpr variant_union(variant_index_tag, Args&&...args); - - ~variant_union(){} - }; - - //========================================================================== - // union : variant_union - //========================================================================== - - template - union variant_union - { - //------------------------------------------------------------------------ - // Public Members - //------------------------------------------------------------------------ - - variant_empty empty; - - //------------------------------------------------------------------------ - // Constructors - //------------------------------------------------------------------------ - - constexpr variant_union(); - - template - constexpr variant_union(variant_index_tag<0>); - }; - - //========================================================================== - // non-member functions : class : variant_union - //========================================================================== - - //-------------------------------------------------------------------------- - // Utilities - //-------------------------------------------------------------------------- - - /// \brief Visits the element in the variant_union \p v at index \p n - /// - /// \param n the index - /// \param fn the function to invoke on the underlying value - /// \param v the variant_union - template - BPSTD_CPP14_CONSTEXPR auto visit_union(std::size_t n, Fn &&fn, VariantUnion &&v) - -> bpstd::detail::variant_visitor_invoke_result_t; - - /// \brief Visits the elements in the variant_union \p v1 and \p v2 at - /// index \p n - /// - /// \note it is assumed that \p n is the active member of both \p v1 and - /// \p v2 - /// - /// \param n the index - /// \param fn the function to invoke on the underlying value - /// \param v1 the first variant_union - /// \param v2 the second variant_union - template - BPSTD_CPP14_CONSTEXPR auto visit_union(std::size_t n, Fn &&fn, VariantUnion &&v1, UVariantUnion &&v2) - -> bpstd::detail::variant_visitor_invoke_result_t; - - /// \{ - /// \brief Gets the element at index \p N out of the variant_union - /// - /// \tparam N the nth object to retrieve - /// \param u the union - /// \return the object at N - template - constexpr auto union_get(variant_union &u) -> bpstd::detail::nth_type_t &; - - template - constexpr auto union_get(const variant_union &u) - -> const bpstd::detail::nth_type_t &; - - template - constexpr auto union_get(variant_union &&u) -> bpstd::detail::nth_type_t &&; - - template - constexpr auto union_get(const variant_union &&u) - -> const bpstd::detail::nth_type_t &&; - /// \} - - } // namespace detail -} // namespace bpstd - -//============================================================================== -// union : variant_union -//============================================================================== - -//------------------------------------------------------------------------------ -// Constructors -//------------------------------------------------------------------------------ - -template -inline constexpr bpstd::detail::variant_union - ::variant_union() - : empty{} -{ - -} - -template -template -inline constexpr bpstd::detail::variant_union - ::variant_union(variant_index_tag<0>, Args&&...args) - : current(bpstd::forward(args)...) -{ - -} - -template -template -inline constexpr bpstd::detail::variant_union - ::variant_union(variant_index_tag, Args&&...args) - : next{variant_index_tag{}, bpstd::forward(args)...} -{ - -} - -//============================================================================== -// union : variant_union -//============================================================================== - -//------------------------------------------------------------------------------ -// Constructors -//------------------------------------------------------------------------------ - -template -inline constexpr bpstd::detail::variant_union - ::variant_union() - : empty{} -{ - -} - -template -template -inline constexpr bpstd::detail::variant_union - ::variant_union(variant_index_tag<0>, Args&&...args) - : current(bpstd::forward(args)...) -{ - -} - -template -template -inline constexpr bpstd::detail::variant_union - ::variant_union(variant_index_tag, Args&&...args) - : next{variant_index_tag{}, bpstd::forward(args)...} -{ - -} - -//============================================================================== -// union : variant_union -//============================================================================== - -//------------------------------------------------------------------------------ -// Constructors -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::detail::variant_union::variant_union() - : empty{} -{ - // base-case; should never be executed -} - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::detail::variant_union::variant_union(variant_index_tag<0>) - : empty{} -{ - // base-case; should never be executed -} - -//============================================================================== -// non-member functions : class : variant_union -//============================================================================== - -//------------------------------------------------------------------------------ -// Utilities -//------------------------------------------------------------------------------ - -namespace bpstd { namespace detail { - - // Single-case - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto do_visit_union(variant_index_tag<1>, std::size_t n, Fn &&fn, - VariantUnion &&v) - -> bpstd::detail::variant_visitor_invoke_result_t -{ - BPSTD_UNUSED(n); - - return bpstd::forward(fn)(union_get<0>(bpstd::forward(v))); - } - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto do_visit_union(variant_index_tag, std::size_t n, Fn &&fn, - VariantUnion &&v) - -> bpstd::detail::variant_visitor_invoke_result_t - { - using size_type = variant_union_size; - - if (n == 0) { - return bpstd::forward(fn)( - union_get<0>(bpstd::forward(v)) - ); - } - - return do_visit_union( - variant_index_tag<(size_type::value - 1)>{}, - n-1, - bpstd::forward(fn), - static_cast>(v.next) - ); - } - - // Double-case - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto do_visit_union(variant_index_tag<1>, std::size_t n, Fn &&fn, - VariantUnion &&v0, UVariantUnion &&v1) - -> bpstd::detail::variant_visitor_invoke_result_t - { - BPSTD_UNUSED(n); - - return bpstd::forward(fn)( - union_get<0>(bpstd::forward(v0)), - union_get<0>(bpstd::forward(v1)) - ); - } - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto do_visit_union(variant_index_tag, std::size_t n, Fn &&fn, - VariantUnion &&v0, UVariantUnion &&v1) - -> bpstd::detail::variant_visitor_invoke_result_t - { - using size_type = variant_union_size; - - if (n == 0) { - return bpstd::forward(fn)( - union_get<0>(bpstd::forward(v0)), - union_get<0>(bpstd::forward(v1)) - ); - } - - return do_visit_union( - variant_index_tag<(size_type::value - 1)>{}, - n-1, - bpstd::forward(fn), - static_cast>(v0.next), - static_cast>(v1.next) - ); - } - - -}} // namespace bpstd::detail - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::detail::visit_union(std::size_t n, Fn &&fn, - VariantUnion &&v) - -> bpstd::detail::variant_visitor_invoke_result_t -{ - using size_type = variant_union_size; - - return detail::do_visit_union( - variant_index_tag{}, - n, - bpstd::forward(fn), - bpstd::forward(v) - ); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::detail::visit_union(std::size_t n, Fn &&fn, VariantUnion &&v1, UVariantUnion &&v2) - -> bpstd::detail::variant_visitor_invoke_result_t -{ - using size_type = variant_union_size; - - return detail::do_visit_union( - variant_index_tag{}, - n, - bpstd::forward(fn), - bpstd::forward(v1), - bpstd::forward(v2) - ); -} - -//------------------------------------------------------------------------------ - -namespace bpstd { namespace detail { - - // private implementation: recurse on index - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto do_union_get(variant_index_tag, variant_union &u) - -> nth_type_t & -{ - return do_union_get(variant_index_tag{}, u.next); - } - template - inline BPSTD_INLINE_VISIBILITY constexpr auto do_union_get(variant_index_tag<0>, - variant_union &u) - -> nth_type_t<0, Types...> & - { - return u.current; - } - - template - inline BPSTD_INLINE_VISIBILITY constexpr auto do_union_get(variant_index_tag, - const variant_union &u) - -> const nth_type_t & - { - return do_union_get(variant_index_tag{}, u.next); - } - template - inline BPSTD_INLINE_VISIBILITY constexpr auto do_union_get(variant_index_tag<0>, - const variant_union &u) - -> const nth_type_t<0, Types...> & - { - return u.current; - } - -}} // namespace bpstd::detail - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::detail::union_get(variant_union &u) - -> bpstd::detail::nth_type_t & -{ - static_assert(N < sizeof...(Types), "N index out of bounds"); - - return do_union_get(variant_index_tag{}, u); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::detail::union_get(const variant_union &u) - -> const bpstd::detail::nth_type_t & -{ - static_assert(N < sizeof...(Types), "N index out of bounds"); - - return do_union_get(variant_index_tag{}, u); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::detail::union_get(variant_union &&u) - -> bpstd::detail::nth_type_t && -{ - static_assert(N < sizeof...(Types), "N index out of bounds"); - - return bpstd::move(do_union_get(variant_index_tag{}, u)); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::detail::union_get(const variant_union &&u) - -> const bpstd::detail::nth_type_t && -{ - static_assert(N < sizeof...(Types), "N index out of bounds"); - - return bpstd::move(do_union_get(variant_index_tag{}, u)); -} - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_DETAIL_VARIANT_UNION_HPP */ diff --git a/src/libs/vmisc/bpstd/detail/variant_visitors.hpp b/src/libs/vmisc/bpstd/detail/variant_visitors.hpp deleted file mode 100644 index de8996cf0..000000000 --- a/src/libs/vmisc/bpstd/detail/variant_visitors.hpp +++ /dev/null @@ -1,195 +0,0 @@ -/***************************************************************************** - * \file variant_visitors.hpp - * - * \brief This internal header provides the definition of various visitors for - * the variant. - * - * These variants are used internally to construct a variant. - *****************************************************************************/ - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_DETAIL_VARIANT_VISITORS_HPP -#define BPSTD_DETAIL_VARIANT_VISITORS_HPP - -#include "config.hpp" -#include "move.hpp" -#include "../tuple.hpp" // get -#include "../utility.hpp" // index_sequence - -#include // placement new -#include // std::swap - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -namespace bpstd { - namespace detail { - - //////////////////////////////////////////////////////////////////////////// - /// \brief A visitor for copy-constructing an underlying variant from the - /// same active type from the other variant - //////////////////////////////////////////////////////////////////////////// - struct variant_copy_construct_visitor - { - template - inline BPSTD_INLINE_VISIBILITY - void operator()(T& self, const T& other) const - { - new (&self) T(other); - } - }; - - //////////////////////////////////////////////////////////////////////////// - /// \brief A visitor for copy-assigning an underlying variant from the - /// same active type from the other variant - //////////////////////////////////////////////////////////////////////////// - struct variant_copy_assign_visitor - { - template - inline BPSTD_INLINE_VISIBILITY - void operator()(T& self, const T& other) const - { - self = other; - } - }; - - //////////////////////////////////////////////////////////////////////////// - /// \brief A visitor for move-constructing an underlying variant from the - /// same active type from the other variant - //////////////////////////////////////////////////////////////////////////// - struct variant_move_construct_visitor - { - template - inline BPSTD_INLINE_VISIBILITY - void operator()(T& self, U&& other) const - { - new (&self) T(bpstd::forward(other)); - } - }; - - //////////////////////////////////////////////////////////////////////////// - /// \brief A visitor for move-assign an underlying variant from the - /// same active type from the other variant - //////////////////////////////////////////////////////////////////////////// - struct variant_move_assign_visitor - { - template - inline BPSTD_INLINE_VISIBILITY - void operator()(T& self, U&& other) const - { - self = bpstd::forward(other); - } - }; - - //////////////////////////////////////////////////////////////////////////// - /// \brief A visitor for swapping the underlying elements of a variant - //////////////////////////////////////////////////////////////////////////// - struct variant_swap_visitor - { - template - inline BPSTD_INLINE_VISIBILITY - void operator()(T& lhs, T& rhs) const - { - using std::swap; - swap(lhs,rhs); - } - }; - - //////////////////////////////////////////////////////////////////////////// - /// \brief A visitor for assigning an element from T to the underlying - /// active variant alternative - //////////////////////////////////////////////////////////////////////////// - template - struct variant_assign_visitor - { - Arg m_value; - - template - inline BPSTD_INLINE_VISIBILITY - variant_assign_visitor(UArg&& u) - : m_value(bpstd::forward(u)) - { - - } - - template - inline BPSTD_INLINE_VISIBILITY - void operator()(U&) - { - } - - inline BPSTD_INLINE_VISIBILITY - void operator()(T& x) - { - x = static_cast(m_value); - } - }; - - //////////////////////////////////////////////////////////////////////////// - /// \brief A visitor for emplacing elements into a variant - //////////////////////////////////////////////////////////////////////////// - template - struct variant_emplace_visitor - { - Tuple m_tuple; - - template - inline BPSTD_INLINE_VISIBILITY - variant_emplace_visitor(UTuple&& tuple) - : m_tuple{bpstd::forward(tuple)} - { - - } - - template - inline BPSTD_INLINE_VISIBILITY - void operator()(U&) - { - } - - inline BPSTD_INLINE_VISIBILITY - void operator()(T& x) - { - emplace_from_tuple( - &x, - bpstd::move(m_tuple), - make_index_sequence::value>{} - ); - } - - template - inline BPSTD_INLINE_VISIBILITY - static void emplace_from_tuple(void* p, UTuple&& tuple, index_sequence) - { - new(p) T(std::get(bpstd::forward(tuple))...); - } - - }; - - } // namespace detail -} // namespace bpstd - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_DETAIL_VARIANT_VISITORS_HPP */ diff --git a/src/libs/vmisc/bpstd/exception.hpp b/src/libs/vmisc/bpstd/exception.hpp deleted file mode 100644 index 45ff998a0..000000000 --- a/src/libs/vmisc/bpstd/exception.hpp +++ /dev/null @@ -1,197 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file exception.hpp -/// -/// \brief This header provides definitions from the C++ header -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_EXCEPTION_HPP -#define BPSTD_EXCEPTION_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "detail/config.hpp" - -#include - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -// The large #if/endif block below, and the definition of -// bpstd::uncaught_exceptions is taken from boost: -// https://beta.boost.org/doc/libs/develop/boost/core/uncaught_exceptions.hpp - -// Copyright Andrey Semashev 2018. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#if (__cplusplus >= 201703L && defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411) || \ - defined(_MSC_VER) && _MSC_VER >= 1900 -# define BPSTD_HAS_UNCAUGHT_EXCEPTIONS -#endif - -#if !defined(BPSTD_HAS_UNCAUGHT_EXCEPTIONS) - -// cxxabi.h availability macro -# if defined(__has_include) -# if __has_include() -# define BPSTD_HAS_CXXABI_H -# endif -# elif defined(__GLIBCXX__) || defined(__GLIBCPP__) -# define BPSTD_HAS_CXXABI_H -# endif - -# if defined(BPSTD_HAS_CXXABI_H) -// MinGW GCC 4.4 seem to not work the same way the newer GCC versions do. As -// a result, __cxa_get_globals based implementation will always return 0. -// Just disable it for now and fall back to std::uncaught_exception(). -# if !(defined(__MINGW32__) && (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 405)) -# include -# include -# define BPSTD_HAS_CXA_GET_GLOBALS - -// At least on MinGW and Linux, only GCC since 4.7 declares __cxa_get_globals() -// in cxxabi.h. Older versions of GCC do not expose this function but it's -// there. -// On OpenBSD, it seems, the declaration is also missing. -// Note that at least on FreeBSD 11, cxxabi.h declares __cxa_get_globals with -// a different exception specification, so we can't declare the function -// unconditionally. On Linux with clang and libc++ and on OS X, there is a -// version of cxxabi.h from libc++abi that doesn't declare __cxa_get_globals, -// but provides __cxa_uncaught_exceptions. -// The function only appeared in version _LIBCPPABI_VERSION >= 1002 of the -// library. Unfortunately, there are linking errors about undefined reference -// to __cxa_uncaught_exceptions on Ubuntu Trusty and OS X, so we avoid using -// it and forward-declare __cxa_get_globals instead. On QNX SDP 7.0 (QCC 5.4.0), -// there are multiple cxxabi.h, one from glibcxx from gcc and another from -// libc++abi from LLVM. Which one is included will be determined by the qcc -// command line arguments (-V and/or -Y; -// http://www.qnx.com/developers/docs/7.0.0/#com.qnx.doc.neutrino.utilities/topic/q/qcc.html -// ). -// The LLVM libc++abi is missing the declaration of __cxa_get_globals but it is -// also patched by QNX developers to not define _LIBCPPABI_VERSION. Older QNX -// SDP versions, up to and including 6.6, don't provide LLVM and libc++abi. -// See https://github.com/boostorg/core/issues/59. -# if !defined(__FreeBSD__) && \ - ( \ - (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 407) || \ - defined(__OpenBSD__) || \ - (defined(__QNXNTO__) && !defined(__GLIBCXX__) && !defined(__GLIBCPP__)) || \ - defined(_LIBCPPABI_VERSION) \ - ) -namespace __cxxabiv1 { - struct __cxa_eh_globals; -# if defined(__OpenBSD__) - extern "C" __cxa_eh_globals* __cxa_get_globals(); -# else - extern "C" __cxa_eh_globals* __cxa_get_globals() noexcept __attribute__((__const__)); -# endif -} // namespace __cxxabiv1 -# endif -# endif // !(defined(__MINGW32__) && (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) < 405)) -# endif // defined(BPSTD_HAS_CXXABI_H) - -# if defined(_MSC_VER) && _MSC_VER >= 1400 -# include -# define BPSTD_HAS_GETPTD -namespace scope { - namespace detail { - extern "C" void* _getptd(); - } // namespace detail -} // namespace scope -# endif // defined(_MSC_VER) && _MSC_VER >= 1400 -#endif // !defined(BPSTD_HAS_UNCAUGHT_EXCEPTIONS) - -#if !defined(BPSTD_HAS_UNCAUGHT_EXCEPTIONS) && \ - !defined(BPSTD_HAS_CXA_GET_GLOBALS) && \ - !defined(BPSTD_HAS_GETPTD) -//! This macro is defined when `uncaught_exceptions` is not guaranteed to -//! return values greater than 1 if multiple exceptions are pending -# define BPSTD_UNCAUGHT_EXCEPTIONS_EMULATED -#endif - -namespace bpstd { - - //============================================================================ - // non-member functions - //============================================================================ - - /// \brief Returns the number of exceptions currently in-flight in the current - /// frame - /// - /// \return the number of exceptions -auto uncaught_exceptions() noexcept -> int; - -} // namespace bpstd - -//============================================================================== -// definitions : non-member functions -//============================================================================== - -//------------------------------------------------------------------------------ -// Utilities -//------------------------------------------------------------------------------ - -inline BPSTD_INLINE_VISIBILITY auto bpstd::uncaught_exceptions() noexcept -> int -{ -#if defined(BPSTD_HAS_UNCAUGHT_EXCEPTIONS) - // C++17 implementation - return std::uncaught_exceptions(); -#elif defined(BPSTD_HAS_CXA_GET_GLOBALS) - // Tested on {clang 3.2,GCC 3.5.6,GCC 4.1.2,GCC 4.4.6,GCC 4.4.7}x{x32,x64} - using byte = unsigned char; - auto count = int{}; - const auto* ptr = reinterpret_cast(::abi::__cxa_get_globals()) + sizeof(void*); - - // __cxa_eh_globals::uncaughtExceptions, x32 offset - 0x4, x64 - 0x8 - std::memcpy(&count, ptr, sizeof(count)); - return count; -#elif defined(BPSTD_HAS_GETPTD) - // MSVC specific. Tested on {MSVC2005SP1,MSVC2008SP1,MSVC2010SP1,MSVC2012}x{x32,x64}. - using byte = unsigned char; - auto count = int{}; - - const auto offset = (sizeof(void*) == 8u ? 0x100 : 0x90); - const auto* ptr = static_cast(::scope::detail::_getptd()) + offset; - - // _tiddata::_ProcessingThrow, x32 offset - 0x90, x64 - 0x100 - std::memcpy(&count, ptr, sizeof(count)); - return count; -#else - // Portable C++03 implementation. Does not allow to detect multiple - // nested exceptions. - - // This is a buggy fallback since it will only work with 1 exception - // in-flight, but we don't have any other options without exploiting - // internal compiler features. - return static_cast(std::uncaught_exception()); -#endif -} - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_EXCEPTION_HPP */ diff --git a/src/libs/vmisc/bpstd/functional.hpp b/src/libs/vmisc/bpstd/functional.hpp deleted file mode 100644 index 5561a8261..000000000 --- a/src/libs/vmisc/bpstd/functional.hpp +++ /dev/null @@ -1,649 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file functional.hpp -/// -/// \brief This header provides definitions from the C++ header -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_FUNCTIONAL_HPP -#define BPSTD_FUNCTIONAL_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "detail/config.hpp" -#include "type_traits.hpp" -#include "utility.hpp" -#include "detail/invoke.hpp" - -#include // to proxy API - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -namespace bpstd { - - /// \brief Invoke the Callable object \p function with the parameters \p args. - /// - /// As by \c INVOKE(std::forward(f), std::forward(args)...) - /// - /// \param function Callable object to be invoked - /// \param args arguments to pass to \p function -template -constexpr auto invoke(Func &&function, Args &&...args) noexcept(is_nothrow_invocable::value) - -> invoke_result_t; - -namespace detail -{ -template struct not_fn_t -{ - Fn fn; - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto - operator()(Args &&...args) & noexcept(noexcept(!::bpstd::invoke(fn, ::bpstd::forward(args)...))) - -> decltype(!::bpstd::invoke(fn, ::bpstd::forward(args)...)) - { - return !::bpstd::invoke(fn, bpstd::forward(args)...); - } - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR - auto operator()(Args&&... args) && - noexcept(noexcept(!::bpstd::invoke(std::move(fn), ::bpstd::forward(args)...))) - -> decltype(!::bpstd::invoke(std::move(fn), ::bpstd::forward(args)...)) - { - return !::bpstd::invoke(std::move(fn), bpstd::forward(args)...); - } - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(Args&&... args) const& - noexcept(noexcept(!::bpstd::invoke(fn, ::bpstd::forward(args)...))) - -> decltype(!::bpstd::invoke(fn, ::bpstd::forward(args)...)) - { - return !::bpstd::invoke(fn, bpstd::forward(args)...); - } - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(Args&&... args) const&& - noexcept(noexcept(!::bpstd::invoke(std::move(fn), ::bpstd::forward(args)...))) - -> decltype(!::bpstd::invoke(std::move(fn), ::bpstd::forward(args)...)) - { - return !::bpstd::invoke(std::move(fn), bpstd::forward(args)...); - } - }; - } // namespace detail - - /// \brief Creates a forwarding call wrapper that returns the negation of the - /// callable object it holds. - /// - /// \param fn the object from which the Callable object held by the wrapper - /// is constructed - /// \return the negated object - template constexpr auto not_fn(Fn &&fn) -> detail::not_fn_t>; - - //============================================================================ - // struct : plus - //============================================================================ - - template - struct plus - { - inline BPSTD_INLINE_VISIBILITY constexpr auto operator()(const T &lhs, const T &rhs) const -> T - { - return lhs + rhs; - } - }; - - template <> - struct plus - { - using is_transparent = true_type; - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(T&& lhs, U&& rhs) const - -> decltype(::bpstd::forward(lhs) + ::bpstd::forward(rhs)) - { - return bpstd::forward(lhs) + bpstd::forward(rhs); - } - }; - - //============================================================================ - // struct : minus - //============================================================================ - - template - struct minus - { - inline BPSTD_INLINE_VISIBILITY constexpr auto operator()(const T &lhs, const T &rhs) const -> T - { - return lhs - rhs; - } - }; - - template <> - struct minus - { - using is_transparent = true_type; - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(T&& lhs, U&& rhs) const - -> decltype(::bpstd::forward(lhs) - ::bpstd::forward(rhs)) - { - return bpstd::forward(lhs) - bpstd::forward(rhs); - } - }; - - //============================================================================ - // struct : multiplies - //============================================================================ - - template - struct multiplies - { - inline BPSTD_INLINE_VISIBILITY constexpr auto operator()(const T &lhs, const T &rhs) const -> T - { - return lhs * rhs; - } - }; - - template <> - struct multiplies - { - using is_transparent = true_type; - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(T&& lhs, U&& rhs) const - -> decltype(::bpstd::forward(lhs) * ::bpstd::forward(rhs)) - { - return bpstd::forward(lhs) * bpstd::forward(rhs); - } - }; - - //============================================================================ - // struct : divides - //============================================================================ - - template - struct divides - { - inline BPSTD_INLINE_VISIBILITY constexpr auto operator()(const T &lhs, const T &rhs) const -> T - { - return lhs / rhs; - } - }; - - template <> - struct divides - { - using is_transparent = true_type; - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(T&& lhs, U&& rhs) const - -> decltype(::bpstd::forward(lhs) / ::bpstd::forward(rhs)) - { - return bpstd::forward(lhs) / bpstd::forward(rhs); - } - }; - - //============================================================================ - // struct : modulus - //============================================================================ - - template - struct modulus - { - inline BPSTD_INLINE_VISIBILITY constexpr auto operator()(const T &lhs, const T &rhs) const -> T - { - return lhs % rhs; - } - }; - - template <> - struct modulus - { - using is_transparent = true_type; - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(T&& lhs, U&& rhs) const - -> decltype(::bpstd::forward(lhs) % ::bpstd::forward(rhs)) - { - return bpstd::forward(lhs) % bpstd::forward(rhs); - } - }; - - //============================================================================ - // struct : negate - //============================================================================ - - template - struct negate - { - inline BPSTD_INLINE_VISIBILITY constexpr auto operator()(const T &arg) const -> T { return -arg; } - }; - - template <> - struct negate - { - using is_transparent = true_type; - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(T&& arg) const - -> decltype(-::bpstd::forward(arg)) - { - return -bpstd::forward(arg); - } - }; - - //============================================================================ - // struct : equal_to - //============================================================================ - - template - struct equal_to - { - inline BPSTD_INLINE_VISIBILITY constexpr auto operator()(const T &lhs, const T &rhs) const -> bool - { - return lhs == rhs; - } - }; - - template <> - struct equal_to - { - using is_transparent = true_type; - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(T&& lhs, U&& rhs) const - -> decltype(::bpstd::forward(lhs) == ::bpstd::forward(rhs)) - { - return bpstd::forward(lhs) == bpstd::forward(rhs); - } - }; - - //============================================================================ - // struct : not_equal_to - //============================================================================ - - template - struct not_equal_to - { - inline BPSTD_INLINE_VISIBILITY constexpr auto operator()(const T &lhs, const T &rhs) const -> bool - { - return lhs != rhs; - } - }; - - template <> - struct not_equal_to - { - using is_transparent = true_type; - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(T&& lhs, U&& rhs) const - -> decltype(::bpstd::forward(lhs) != ::bpstd::forward(rhs)) - { - return bpstd::forward(lhs) != bpstd::forward(rhs); - } - }; - - //============================================================================ - // struct : greater - //============================================================================ - - template - struct greater - { - inline BPSTD_INLINE_VISIBILITY constexpr auto operator()(const T &lhs, const T &rhs) const -> bool - { - return lhs > rhs; - } - }; - - template <> - struct greater - { - using is_transparent = true_type; - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(T&& lhs, U&& rhs) const - -> decltype(::bpstd::forward(lhs) > ::bpstd::forward(rhs)) - { - return bpstd::forward(lhs) > bpstd::forward(rhs); - } - }; - - //============================================================================ - // struct : greater_equal - //============================================================================ - - template - struct greater_equal - { - inline BPSTD_INLINE_VISIBILITY constexpr auto operator()(const T &lhs, const T &rhs) const -> bool - { - return lhs >= rhs; - } - }; - - template <> - struct greater_equal - { - using is_transparent = true_type; - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(T&& lhs, U&& rhs) const - -> decltype(::bpstd::forward(lhs) >= ::bpstd::forward(rhs)) - { - return bpstd::forward(lhs) >= bpstd::forward(rhs); - } - }; - - //============================================================================ - // struct : less - //============================================================================ - - template - struct less - { - inline BPSTD_INLINE_VISIBILITY constexpr auto operator()(const T &lhs, const T &rhs) const -> bool - { - return lhs < rhs; - } - }; - - template <> - struct less - { - using is_transparent = true_type; - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(T&& lhs, U&& rhs) const - -> decltype(::bpstd::forward(lhs) < ::bpstd::forward(rhs)) - { - return bpstd::forward(lhs) < bpstd::forward(rhs); - } - }; - - //============================================================================ - // struct : less_equal - //============================================================================ - - template - struct less_equal - { - inline BPSTD_INLINE_VISIBILITY constexpr auto operator()(const T &lhs, const T &rhs) const -> bool - { - return lhs <= rhs; - } - }; - - template <> - struct less_equal - { - using is_transparent = true_type; - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(T&& lhs, U&& rhs) const - -> decltype(::bpstd::forward(lhs) <= ::bpstd::forward(rhs)) - { - return bpstd::forward(lhs) <= bpstd::forward(rhs); - } - }; - - //============================================================================ - // struct : logical_and - //============================================================================ - - template - struct logical_and - { - inline BPSTD_INLINE_VISIBILITY constexpr auto operator()(const T &lhs, const T &rhs) const -> bool - { - return lhs && rhs; - } - }; - - template <> - struct logical_and - { - using is_transparent = true_type; - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(T&& lhs, U&& rhs) const - -> decltype(::bpstd::forward(lhs) && ::bpstd::forward(rhs)) - { - return bpstd::forward(lhs) && bpstd::forward(rhs); - } - }; - - //============================================================================ - // struct : logical_or - //============================================================================ - - template - struct logical_or - { - inline BPSTD_INLINE_VISIBILITY constexpr auto operator()(const T &lhs, const T &rhs) const -> bool - { - return lhs || rhs; - } - }; - - template <> - struct logical_or - { - using is_transparent = true_type; - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(T&& lhs, U&& rhs) const - -> decltype(::bpstd::forward(lhs) || ::bpstd::forward(rhs)) - { - return bpstd::forward(lhs) || bpstd::forward(rhs); - } - }; - - //============================================================================ - // struct : logical_not - //============================================================================ - - template - struct logical_not - { - inline BPSTD_INLINE_VISIBILITY constexpr auto operator()(const T &arg) const -> bool { return !arg; } - }; - - template <> - struct logical_not - { - using is_transparent = true_type; - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(T&& arg) const - -> decltype(!::bpstd::forward(arg)) - { - return !bpstd::forward(arg); - } - }; - - //============================================================================ - // struct : bit_and - //============================================================================ - - template - struct bit_and - { - inline BPSTD_INLINE_VISIBILITY constexpr auto operator()(const T &lhs, const T &rhs) const -> T - { - return lhs & rhs; - } - }; - - template <> - struct bit_and - { - using is_transparent = true_type; - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(T&& lhs, U&& rhs) const - -> decltype(::bpstd::forward(lhs) & ::bpstd::forward(rhs)) - { - return bpstd::forward(lhs) & bpstd::forward(rhs); - } - }; - - //============================================================================ - // struct : bit_or - //============================================================================ - - template - struct bit_or - { - inline BPSTD_INLINE_VISIBILITY constexpr auto operator()(const T &lhs, const T &rhs) const -> T - { - return lhs | rhs; - } - }; - - template <> - struct bit_or - { - using is_transparent = true_type; - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(T&& lhs, U&& rhs) const - -> decltype(::bpstd::forward(lhs) | ::bpstd::forward(rhs)) - { - return bpstd::forward(lhs) | bpstd::forward(rhs); - } - }; - - //============================================================================ - // struct : bit_xor - //============================================================================ - - template - struct bit_xor - { - inline BPSTD_INLINE_VISIBILITY constexpr auto operator()(const T &lhs, const T &rhs) const -> T - { - return lhs ^ rhs; - } - }; - - template <> - struct bit_xor - { - using is_transparent = true_type; - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(T&& lhs, U&& rhs) const - -> decltype(::bpstd::forward(lhs) ^ ::bpstd::forward(rhs)) - { - return bpstd::forward(lhs) ^ bpstd::forward(rhs); - } - }; - - //============================================================================ - // struct : bit_not - //============================================================================ - - template - struct bit_not - { - inline BPSTD_INLINE_VISIBILITY constexpr auto operator()(const T &arg) const -> T { return ~arg; } - }; - - template <> - struct bit_not - { - using is_transparent = true_type; - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto operator()(T&& arg) const - -> decltype(~::bpstd::forward(arg)) - { - return ~bpstd::forward(arg); - } - }; - -} // namespace bpstd - -//============================================================================== -// definition : invoke -//============================================================================== - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto -bpstd::invoke(Func &&function, Args &&...args) noexcept(is_nothrow_invocable::value) - -> bpstd::invoke_result_t -{ - return detail::INVOKE(bpstd::forward(function), bpstd::forward(args)...); -} - - -//============================================================================== -// definition : not_fn -//============================================================================== - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::not_fn(Fn &&fn) -> bpstd::detail::not_fn_t> -{ - static_assert( - is_move_constructible::value, - "Fn must be move constructible" - ); - static_assert( - is_constructible,Fn>::value, - "Fn must be constructible from an instance of fn" - ); - - return { bpstd::forward(fn) }; -} - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_FUNCTIONAL_HPP */ diff --git a/src/libs/vmisc/bpstd/iterator.hpp b/src/libs/vmisc/bpstd/iterator.hpp deleted file mode 100644 index facc7995e..000000000 --- a/src/libs/vmisc/bpstd/iterator.hpp +++ /dev/null @@ -1,258 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file iterator.hpp -/// -/// \brief This header provides definitions from the C++ header -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_ITERATOR_HPP -#define BPSTD_ITERATOR_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "detail/config.hpp" -#include "type_traits.hpp" // common_type_t - -#include -#include // std::size_t -#include - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -namespace bpstd { - - //============================================================================ - // class : reverse_iterator - //============================================================================ - - template - using reverse_iterator = std::reverse_iterator; - - //============================================================================ - // non-member functions : class : reverse_iterator - //============================================================================ - - /// \brief Makes a reverse_iterator given an iterator \p i - /// - /// This is a convenience function template that constructs a - /// reverse_iterator for the given iterator \p i with the type deduced from - /// the type of the argument. - /// - /// \param i the iterator - /// \return the reverse_iterator - template constexpr auto make_reverse_iterator(Iterator i) -> reverse_iterator; - - //============================================================================ - // non-member functions - //============================================================================ - - /// \{ - /// \brief Gets a pointer to the data from \p c - /// - /// \param c the container to get the data pointe rrom - /// \return a pointer to the data - template - constexpr auto data(C& c) -> decltype(c.data()); - template - constexpr auto data(const C& c) -> decltype(c.data()); - /// \} - - /// \brief Gets a pointer to the start of an array - /// - /// \param array the array to get the pointer to - /// \return a pointer to the data - template constexpr auto data(T (&array)[N]) noexcept -> T *; - - /// \brief Gets a pointer to the start of an initializer list - /// - /// \param il the initializer list - /// \return a pointer to the start of the initializer list - template constexpr auto data(std::initializer_list il) noexcept -> const E *; - - //---------------------------------------------------------------------------- - - /// \brief Queries whether \p c is empty - /// - /// \param c the container to query - /// \return true if \p is empty - template - constexpr auto empty(const C& c) -> decltype(c.empty()); - - /// \brief Queries whether the array is empty - /// - /// \param array the array to check - /// \return true if N is 0 - template constexpr auto empty(const T (&array)[N]) noexcept -> bool; - - /// \brief Queries whether an initializer list is empty - /// - /// \param il the initializer list to check - /// \return true if \p il is empty - template constexpr auto empty(std::initializer_list il) noexcept -> bool; - - //---------------------------------------------------------------------------- - - /// \brief Gets the size of a container - /// - /// \param c the container to check - /// \return the container's size - template - constexpr auto size(const C& c) -> decltype(c.size()); - - /// \brief Gets the size of an array - /// - /// \param array the array to get the size from - /// \return the size of an array - template constexpr auto size(const T (&array)[N]) noexcept -> std::size_t; - - //---------------------------------------------------------------------------- - - /// \brief Gets the signed-size of a container - /// - /// \param c the container to get the size from - /// \return the size of the container - template - constexpr auto ssize(const C& c) - -> common_type_t>; - - /// \brief Gets the signed size of an array - /// - /// \param array the array to get the size from - /// \return the size of an array - template constexpr auto ssize(const T (&array)[N]) noexcept -> std::ptrdiff_t; - -} // namespace bpstd - -//============================================================================== -// non-member functions : class : reverse_iterator -//============================================================================== - -//------------------------------------------------------------------------------ -// Utilities -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::make_reverse_iterator(Iterator i) - -> bpstd::reverse_iterator -{ - return reverse_iterator{i}; -} - -//============================================================================== -// non-member functions -//============================================================================== - -//------------------------------------------------------------------------------ -// Utilities -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr - auto bpstd::data(C& c) - -> decltype(c.data()) -{ - return c.data(); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr - auto bpstd::data(const C& c) - -> decltype(c.data()) -{ - return c.data(); -} -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::data(T (&array)[N]) noexcept -> T * -{ - return array; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::data(std::initializer_list il) noexcept -> const E * -{ - return il.begin(); -} - -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr - auto bpstd::empty(const C& c) - -> decltype(c.empty()) -{ - return c.empty(); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::empty(const T (&)[N]) noexcept -> bool -{ - return N == 0; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::empty(std::initializer_list il) noexcept -> bool -{ - return il.begin() == il.end(); -} - -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr - auto bpstd::size(const C& c) - -> decltype(c.size()) -{ - return c.size(); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::size(const T (&)[N]) noexcept -> std::size_t -{ - return N; -} - -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr - auto bpstd::ssize(const C& c) - -> bpstd::common_type_t> -{ - using type = bpstd::common_type_t>; - - return static_cast(c.size()); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::ssize(const T (&)[N]) noexcept -> std::ptrdiff_t -{ - return N; -} - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_ITERATOR_HPP */ diff --git a/src/libs/vmisc/bpstd/memory.hpp b/src/libs/vmisc/bpstd/memory.hpp deleted file mode 100644 index f2b6fd295..000000000 --- a/src/libs/vmisc/bpstd/memory.hpp +++ /dev/null @@ -1,245 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file memory.hpp -/// -/// \brief This header provides definitions from the C++ header -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_MEMORY_HPP -#define BPSTD_MEMORY_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "detail/config.hpp" -#include "type_traits.hpp" // conditional_t, void_t -#include "utility.hpp" // forward - -#include // std::unique_ptr -#include // std::size_t -#include // std::declval - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -namespace bpstd { - - namespace detail { - template - struct make_unique_result - { - using object = T; - }; - template - struct make_unique_result - { - using unbounded_array = T[]; - }; - template - struct make_unique_result - { - using bounded_array = T[N]; - }; - } - - /// \brief Constructs an object of type T and wraps it in a std::unique_ptr - /// - /// Constructs a non-array type T. The arguments args are passed to the - /// constructor of T. This overload only participates in overload resolution - /// if T is not an array type. - /// - /// \tparam T the type to construct - /// \param args the arguments to forward to T's constructor - /// \return the unique_ptr - template - auto make_unique(Args &&...args) -> std::unique_ptr::object>; - - /// \brief Constructs an object of type T[] and wraps it in a std::unique_ptr - /// - /// Constructs an array of unknown bound T. This overload only participates - /// in overload resolution if T is an array of unknown bound. - /// - /// \tparam T the type to construct - /// \param size the size of the array - /// \return the unique_ptr - template - auto make_unique(std::size_t size) -> std::unique_ptr::unbounded_array>; - - // Construction of arrays of known bound is disallowed - template - auto make_unique() -> std::unique_ptr::bounded_array> = delete; - - /// \brief Constructs an object of type T through default-initialization - /// and wraps it in a std::unique_ptr - /// - /// Constructs a non-array type T. This overload only participates in - /// overload resolution if T is not an array type. The object is - /// default-initialised, which may mean it will need to be overwritten before - /// it is legal to be read - /// - /// \tparam T the type to construct - /// \return the unique_ptr - template - auto make_unique_for_overwrite() -> std::unique_ptr::object>; - - /// \brief Constructs an object of type T[] through default-initialization - /// and wraps it in a std::unique_ptr - /// - /// Constructs an array of unknown bound T. This overload only participates - /// in overload resolution if T is an array of unknown bound. The array is - /// default-initialised, which may mean it will need to be overwritten before - /// it is legal to be read - /// - /// \tparam T the type to construct - /// \return the unique_ptr - template - auto make_unique_for_overwrite(std::size_t size) - -> std::unique_ptr::unbounded_array>; - - // Construction of arrays of known bound is disallowed - template - auto make_unique_for_overwrite() -> std::unique_ptr::bounded_array> = delete; - - //---------------------------------------------------------------------------- - - namespace detail { - - template - struct has_to_address : false_type{}; - - template - struct has_to_address::to_address(std::declval()))>> - : true_type{}; - - //-------------------------------------------------------------------------- - - template - struct operator_deref - { - using type = decltype(std::declval().operator->()); - }; - - template - struct operator_deref{}; - - //-------------------------------------------------------------------------- - - template - struct to_address_result - : operator_deref>::value, T>{}; - - template - struct to_address_result::to_address(std::declval()))>> - { - using type = decltype(std::pointer_traits::to_address(std::declval())); - }; - - template - using to_address_result_t = typename to_address_result::type; - - } // namespace detail - - /// \{ - /// \brief Converts a pointer-like type to a raw pointer by recursively - /// calling to_address on it - /// - /// \param p the pointer-like type - /// \return the pointer - template constexpr auto to_address(T *p) noexcept -> T *; - template constexpr auto to_address(const T &p) noexcept -> detail::to_address_result_t; - /// \} - -} // namespace bpstd - -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::make_unique(Args &&...args) - -> std::unique_ptr::object> -{ - return std::unique_ptr{new T(bpstd::forward(args)...)}; -} - -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::make_unique(std::size_t size) - -> std::unique_ptr::unbounded_array> -{ - return std::unique_ptr{new remove_extent_t[size]()}; -} - -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::make_unique_for_overwrite() - -> std::unique_ptr::object> -{ - return std::unique_ptr{new T}; -} - -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::make_unique_for_overwrite(std::size_t size) - -> std::unique_ptr::unbounded_array> -{ - return std::unique_ptr{new remove_extent_t[size]}; -} - -namespace bpstd { - namespace detail { - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto to_address_impl(const T& p, std::true_type) - -> decltype(std::pointer_traits::to_address(std::declval())) - { - return to_address(std::pointer_traits::to_address(p)); - } - - template - inline BPSTD_INLINE_VISIBILITY constexpr - auto to_address_impl(const T& p, std::false_type) - -> decltype(std::declval().operator->()) - { - return to_address(p.operator->()); - } - - } // namespace detail -} // namespace bpstd - -template inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::to_address(T *p) noexcept -> T * -{ - static_assert( - !std::is_function::value, - "T* must not be a function pointer" - ); - - return p; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::to_address(const T &p) noexcept - -> bpstd::detail::to_address_result_t -{ - return detail::to_address_impl(p, detail::has_to_address{}); -} - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_MEMORY_HPP */ diff --git a/src/libs/vmisc/bpstd/optional.hpp b/src/libs/vmisc/bpstd/optional.hpp deleted file mode 100644 index fdbd2b20d..000000000 --- a/src/libs/vmisc/bpstd/optional.hpp +++ /dev/null @@ -1,1668 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file optional.hpp -/// -/// \brief This header provides definitions from the C++ header -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_OPTIONAL_HPP -#define BPSTD_OPTIONAL_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "detail/config.hpp" -#include "detail/enable_overload.hpp" // enable_overload_if, disable_overload_if - -#include "utility.hpp" // in_place_t, forward, move -#include "functional.hpp" // invoke_result_t -#include "type_traits.hpp" - -#include // std::initializer_list -#include // enable_if -#include // std::logic_error -#include // placement new - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -namespace bpstd { - - template class optional; - - namespace detail { - - //========================================================================== - // trait : is_optional - //========================================================================== - - template - using optional_is_convertible = conjunction< - std::is_constructible&>, - std::is_constructible&>, - std::is_constructible&&>, - std::is_constructible&&>, - std::is_convertible&, T>, - std::is_convertible&, T>, - std::is_convertible&&, T>, - std::is_convertible&&, T> - >; - - template - using optional_is_copy_convertible = conjunction< - optional_is_convertible, - std::is_constructible - >; - - template - using optional_is_move_convertible = conjunction< - optional_is_convertible, - std::is_constructible - >; - - template - using optional_is_value_convertible = conjunction< - std::is_constructible, - negation,in_place_t>>, - negation,optional>> - >; - - template - using optional_is_convert_assignable = conjunction< - optional_is_convertible, - std::is_assignable&>, - std::is_assignable&>, - std::is_assignable&&>, - std::is_assignable&&> - >; - - template - using optional_is_copy_convert_assignable = conjunction< - optional_is_convert_assignable, - std::is_constructible, - std::is_assignable - >; - - template - using optional_is_move_convert_assignable = conjunction< - optional_is_convert_assignable, - std::is_constructible, - std::is_assignable - >; - - template - using optional_is_value_assignable = conjunction< - negation,optional>>, - std::is_constructible, - std::is_assignable, - disjunction< - negation,T>>, - negation> - > - >; - - } // namespace detail - - //========================================================================= - // class : bad_optional_access - //========================================================================= - - /////////////////////////////////////////////////////////////////////////// - /// \brief An exception thrown when an optional is attempted to be accessed - /// while not containing a value - /////////////////////////////////////////////////////////////////////////// - class bad_optional_access : public std::logic_error - { - public: - bad_optional_access() : std::logic_error("bad_optional_access"){} - }; - - //========================================================================= - // struct : nullopt_t - //========================================================================= - - /// \brief This type represents null optional value - struct nullopt_t - { - nullopt_t() = delete; - constexpr explicit nullopt_t(int) noexcept{} - }; - - //------------------------------------------------------------------------- - - /// \brief Instance of a nullopt type - constexpr nullopt_t nullopt = nullopt_t{0}; - - //========================================================================= - // class : optional - //========================================================================= - - namespace detail { - - template class optional_base; - - template - class optional_base - { - //--------------------------------------------------------------------- - // Constructors / Assignment - //--------------------------------------------------------------------- - public: - // cppcheck-suppress noExplicitConstructor - constexpr optional_base(nullopt_t) noexcept; - - template - constexpr optional_base(in_place_t, Args&&...args) - noexcept(std::is_nothrow_constructible::value); - - optional_base(optional_base&& other) = default; - optional_base(const optional_base& other) = default; - - //--------------------------------------------------------------------- - - auto operator=(optional_base &&other) -> optional_base & = default; - auto operator=(const optional_base &other) -> optional_base & = default; - - //--------------------------------------------------------------------- - // Protected Modifiers - //--------------------------------------------------------------------- - protected: - BPSTD_CPP14_CONSTEXPR auto val() noexcept -> T *; - constexpr auto val() const noexcept -> const T *; - - constexpr auto contains_value() const noexcept -> bool; - - //--------------------------------------------------------------------- - // Protected Observers - //--------------------------------------------------------------------- - protected: - - template - void construct(Args&&...args); - - void destruct(); - - //--------------------------------------------------------------------- - // Private Member Types - //--------------------------------------------------------------------- - private: - - struct empty{}; - union storage_type { - empty nothing; - T something; - - template - constexpr storage_type(in_place_t, Args&&...args) - : something(bpstd::forward(args)...){} - constexpr storage_type() : nothing(){} - }; - - //--------------------------------------------------------------------- - // Private Members - //--------------------------------------------------------------------- - private: - - storage_type m_storage; - bool m_engaged; - }; - - template - class optional_base - { - //--------------------------------------------------------------------- - // Protected Constructors / Destructor / Assignment - //--------------------------------------------------------------------- - protected: - - // cppcheck-suppress noExplicitConstructor - optional_base(nullopt_t) noexcept; - - template - optional_base(in_place_t, Args&&...args) - noexcept(std::is_nothrow_constructible::value); - - optional_base(optional_base&& other) = default; - optional_base(const optional_base& other) = default; - - //--------------------------------------------------------------------- - - ~optional_base() noexcept(std::is_nothrow_destructible::value); - - //--------------------------------------------------------------------- - - auto operator=(optional_base &&other) -> optional_base & = default; - auto operator=(const optional_base &other) -> optional_base & = default; - - //--------------------------------------------------------------------- - // Protected Observers - //--------------------------------------------------------------------- - protected: - auto val() noexcept -> T *; - auto val() const noexcept -> const T *; - auto contains_value() const noexcept -> bool; - - //--------------------------------------------------------------------- - // Protected Modifiers - //--------------------------------------------------------------------- - protected: - - template - void construct(Args&&...args); - void destruct(); - - //--------------------------------------------------------------------- - // Private Member Types - //--------------------------------------------------------------------- - private: - - struct empty{}; - union storage_type { - empty nothing; - T something; - - template - storage_type(in_place_t, Args&&...args) - : something(bpstd::forward(args)...){} - storage_type() : nothing(){} - ~storage_type(){} - }; - - //--------------------------------------------------------------------- - // Private Members - //--------------------------------------------------------------------- - private: - - storage_type m_storage; - bool m_engaged; - }; - } // namespace detail - - /////////////////////////////////////////////////////////////////////////// - /// \brief The class template optional manages an optional contained value, - /// i.e. a value that may or may not be present. - /// - /// A common use case for optional is the return value of a function that - /// may fail. As opposed to other approaches, such as std::pair, - /// optional handles expensive to construct objects well and is more - /// readable, as the intent is expressed explicitly. - /// - /// Any instance of optional at any given point in time either contains - /// a value or does not contain a value. - /// - /// If an optional contains a value, the value is guaranteed to be - /// allocated as part of the optional object footprint, i.e. no dynamic - /// memory allocation ever takes place. Thus, an optional object models an - /// object, not a pointer, even though the operator*() and operator->() - /// are defined. - /// - /// When an object of type optional is contextually converted to bool, - /// the conversion returns true if the object contains a value and false if - /// it does not contain a value. - /// - /// The optional object contains a value in the following conditions: - /// - The object is initialized with a value of type T - /// - The object is assigned from another optional that contains a value. - /// - The object does not contain a value in the following conditions: - /// - The object is default-initialized. - /// - The object is initialized with a value of nullopt_t or an optional - /// object that does not contain a value. - /// - The object is assigned from a value of nullopt_t or from an optional - /// that does not contain a value - /// - /// \tparam T the underlying type - /////////////////////////////////////////////////////////////////////////// - template - class optional - : detail::optional_base::value> - { - static_assert( - !std::is_void::value, - "optional is ill-formed" - ); - static_assert( - !std::is_reference::value, - "optional is ill-formed" - ); - static_assert( - !std::is_abstract::value, - "optional of an abstract-type is ill-formed" - ); - - using base_type = detail::optional_base::value>; - - //----------------------------------------------------------------------- - // Public Member Types - //----------------------------------------------------------------------- - public: - - using value_type = T; ///< The underlying type of this Optional - - //----------------------------------------------------------------------- - // Constructor / Destructor / Assignment - //----------------------------------------------------------------------- - public: - - /// \{ - /// \brief Constructs an optional that does not contain a value - constexpr optional() noexcept; - // cppcheck-suppress noExplicitConstructor - constexpr optional(nullopt_t) noexcept; - /// \} - - /// \brief Copy constructs an optional - /// - /// If \p other contains a value, initializes the contained value as if - /// direct-initializing (but not direct-list-initializing) an object of - /// type T with the expression *other. - /// - /// If other does not contain a value, constructs an object that does - /// not contain a value. - /// - /// \note This constructor is defined as deleted if std::is_copy_constructible_v is false - /// - /// \param other the optional to copy - // cppcheck-suppress noExplicitConstructor - optional(detail::enable_overload_if_t::value,const optional&> other); - optional(detail::disable_overload_if_t::value,const optional&> other) = delete; - - /// \brief Move constructs an optional - /// - /// If other contains a value, initializes the contained value as if - /// direct-initializing (but not direct-list-initializing) an object - /// of type T with the expression std::move(*other) and does not make - /// other empty: a moved-from optional still contains a value, but the - /// value itself is moved from. - /// - /// If other does not contain a value, constructs an object that does - /// not contain a value. - /// - /// \note This constructor is defined as deleted if std::is_move_constructible_v is false - /// - /// \param other the optional to move - // cppcheck-suppress noExplicitConstructor - optional(detail::enable_overload_if_t::value,optional&&> other); - optional(detail::disable_overload_if_t::value,optional&&> other) = delete; - - /// \{ - /// \brief Converting copy constructor - /// - /// If other doesn't contain a value, constructs an optional object - /// that does not contain a value. Otherwise, constructs an optional - /// object that contains a value, initialized as if direct-initializing - /// (but not direct-list-initializing) an object of type T with the - /// expression *other. - /// - /// \note This constructor does not participate in overload resolution - /// unless the following conditions are met: - /// - std::is_constructible_v is true - /// - T is not constructible or convertible from any expression - /// of type (possibly const) optional, i.e., the - /// following 8 type traits are all false: - /// - std::is_constructible_v&> - /// - std::is_constructible_v&> - /// - std::is_constructible_v&&> - /// - std::is_constructible_v&&> - /// - std::is_convertible_v&, T> - /// - std::is_convertible_v&, T> - /// - std::is_convertible_v&&, T> - /// - std::is_convertible_v&&, T> - /// - /// \note This constructor is explicit if and only if - /// std::is_convertible_v is false - /// - /// \param other the other type to convert - template ::value && std::is_convertible::value>* =nullptr> - // cppcheck-suppress noExplicitConstructor - optional(const optional& other); - template ::value && !std::is_convertible::value>* =nullptr> - explicit optional(const optional& other); - /// \} - - /// \{ - /// \brief Converting move constructor - /// - /// If other doesn't contain a value, constructs an optional object - /// that does not contain a value. Otherwise, constructs an optional - /// object that contains a value, initialized as if direct-initializing - /// (but not direct-list-initializing) an object of type T with the - /// expression std::move(*other). - /// - /// \note This constructor does not participate in overload resolution - /// unless the following conditions are met: - /// - std::is_constructible_v is true - /// - T is not constructible or convertible from any expression - /// of type (possibly const) optional, i.e., the - /// following 8 type traits are all false: - /// - std::is_constructible_v&> - /// - std::is_constructible_v&> - /// - std::is_constructible_v&&> - /// - std::is_constructible_v&&> - /// - std::is_convertible_v&, T> - /// - std::is_convertible_v&, T> - /// - std::is_convertible_v&&, T> - /// - std::is_convertible_v&&, T> - /// - /// \note This constructor is explicit if and only if - /// std::is_convertible_v is false - /// - /// \param other the other optional to move - template ::value && std::is_convertible::value>* =nullptr> - // cppcheck-suppress noExplicitConstructor - optional(optional&& other); - template ::value && !std::is_convertible::value>* =nullptr> - explicit optional(optional&& other); - /// \} - - /// \brief Constructs an optional object that contains a value - /// - /// the value is initialized as if direct-initializing (but not - /// direct-list-initializing) an object of type T from the arguments - /// std::forward(args)... - /// - /// \param args the arguments to pass to T's constructor - template ::value>> - constexpr explicit optional(in_place_t, Args&&... args); - - /// \brief Constructs an optional object that contains a value - /// - /// The value is initialized as if direct-initializing (but not - /// direct-list-initializing) an object of type T from the arguments - /// std::forward>(ilist), std::forward(args)... - /// - /// \param ilist An initializer list of entries to forward - /// \param args the arguments to pass to T's constructor - template &, Args...>::value>> - constexpr explicit optional(in_place_t, - std::initializer_list ilist, - Args&&...args); - - /// \{ - /// \brief Constructs an optional object that contains a value - /// - /// The value is initialized as if direct-initializing (but not - /// direct-list-initializing) an object of type T with the expression - /// value. - /// - /// \note This constructor is constexpr if the constructor of T - /// selected by direct-initialization is constexpr - /// - /// \note This constructor does not participate in overload - /// resolution unless std::is_constructible_v is true - /// and decay_t is neither std::in_place_t nor - /// optional. - /// - /// \note This constructor is explicit if and only if - /// std::is_convertible_v is false - /// - /// \param value the value to copy - template ::value && std::is_convertible::value>* =nullptr> - // cppcheck-suppress noExplicitConstructor - constexpr optional(U&& value); - template ::value && !std::is_convertible::value>* =nullptr> - constexpr explicit optional(U&& value); - /// \} - - //----------------------------------------------------------------------- - - /// \brief Assigns this optional to be a null optional - /// - /// If \c (*this) had a value before the call, the contained value is - /// destroyed. - auto operator=(nullopt_t) -> optional &; - - /// \brief Copy assigns the optional stored in \p other - /// - /// \param other the other optional to copy - auto - operator=(detail::enable_overload_if_t::value && std::is_copy_assignable::value, - const optional &> - other) -> optional &; - auto - operator=(detail::disable_overload_if_t::value && std::is_copy_assignable::value, - const optional &> - other) -> optional & = delete; - - /// \brief Move assigns the optional stored in \p other - /// - /// \note If \p other contained a value before the call, it is left as a - /// null optional - /// - /// \remark This assignment does not participate in overload resolution - /// unless U is - /// - /// \param other the other optional to move - auto - operator=(detail::enable_overload_if_t::value && std::is_move_assignable::value, - optional &&> - other) -> optional &; - auto - operator=(detail::disable_overload_if_t::value && std::is_move_assignable::value, - optional &&> - other) -> optional & = delete; - - /// \brief Perfect-forwarded assignment - /// - /// Depending on whether *this contains a value before the call, the - /// contained value is either direct-initialized from std::forward(value) - /// or assigned from std::forward(value). - /// - /// \note The function does not participate in overload resolution unless - /// - decay_t is not optional, - /// - std::is_constructible_v is true - /// - std::is_assignable_v is true - /// - and at least one of the following is true: - /// - T is not a scalar type; - /// - decay_t is not T. - /// - /// \param value to assign to the contained value - /// \return reference to \c (*this) - template ::value>> - auto operator=(U &&value) -> optional &; - - /// \brief Assigns the state of \p other - /// - /// If both *this and other do not contain a value, the function has no effect. - /// - /// If *this contains a value, but other does not, then the contained - /// value is destroyed by calling its destructor. *this does not - /// contain a value after the call. - /// - /// If other contains a value, then depending on whether *this contains a value, - /// the contained value is either direct-initialized or assigned from *other. - /// - /// \note A moved-from optional still contains a value. - /// - /// \note This overload does not participate in overload resolution unless the - /// following conditions are met: - /// - std::is_constructible_v and - /// std::is_assignable_v are both true. - /// - T is not constructible, convertible, or assignable from any expression - /// of type (possibly const) :optional, i.e., - /// the following 12 type traits are all false: - /// - std::is_constructible_v&> - /// - std::is_constructible_v&> - /// - std::is_constructible_v&&> - /// - std::is_constructible_v&&> - /// - std::is_convertible_v&, T> - /// - std::is_convertible_v&, T> - /// - std::is_convertible_v&&, T> - /// - std::is_convertible_v&&, T> - /// - std::is_assignable_v&> - /// - std::is_assignable_v&> - /// - std::is_assignable_v&&> - /// - std::is_assignable_v&&>. - /// - /// \param other another optional object whose contained value to assign - /// \return reference to (*this) - template - auto operator=(enable_if_t::value, const optional &> other) - -> optional &; - - /// \brief Assigns the state of \p other - /// - /// If both *this and other do not contain a value, the function has no effect. - /// - /// If *this contains a value, but other does not, then the contained - /// value is destroyed by calling its destructor. *this does not - /// contain a value after the call. - /// - /// If other contains a value, then depending on whether *this contains a value, - /// the contained value is either direct-initialized or assigned from - /// std::move(*other). - /// - /// \note A moved-from optional still contains a value. - /// - /// \note This overload does not participate in overload resolution unless the - /// following conditions are met: - /// - std::is_constructible_v and - /// std::is_assignable_v are both true. - /// - T is not constructible, convertible, or assignable from any expression - /// of type (possibly const) :optional, i.e., - /// the following 12 type traits are all false: - /// - std::is_constructible_v&> - /// - std::is_constructible_v&> - /// - std::is_constructible_v&&> - /// - std::is_constructible_v&&> - /// - std::is_convertible_v&, T> - /// - std::is_convertible_v&, T> - /// - std::is_convertible_v&&, T> - /// - std::is_convertible_v&&, T> - /// - std::is_assignable_v&> - /// - std::is_assignable_v&> - /// - std::is_assignable_v&&> - /// - std::is_assignable_v&&>. - /// - /// \param other another optional object whose contained value to assign - /// \return reference to (*this) - template - auto operator=(enable_if_t::value, optional &&> other) - -> optional &; - - //----------------------------------------------------------------------- - // Observers - //----------------------------------------------------------------------- - - /// \{ - /// \brief Accesses the contained value - /// - /// \note The behavior is undefined if \c *this does not contain a value. - /// - /// \return a pointer to the contained value - BPSTD_CPP14_CONSTEXPR auto operator->() noexcept -> value_type *; - constexpr auto operator->() const noexcept -> const value_type *; - /// \} - - /// \{ - /// \brief Accesses the contained value - /// - /// \note The behaviour is undefined if \c *this does not contain a value - /// - /// \return a reference to the contained value - BPSTD_CPP14_CONSTEXPR auto operator*() & noexcept -> value_type &; - BPSTD_CPP14_CONSTEXPR auto operator*() && noexcept -> value_type &&; - constexpr auto operator*() const & noexcept -> const value_type &; - constexpr auto operator*() const && noexcept -> const value_type &&; - /// \} - - /// \brief Checks whether \c *this contains a value - /// - /// \return \c true if \c *this contains a value, \c false if \c *this - /// does not contain a value - constexpr explicit operator bool() const noexcept; - - /// \brief Checks whether \c *this contains a value - /// - /// \return \c true if \c *this contains a value, \c false if \c *this - /// does not contain a value - constexpr auto has_value() const noexcept -> bool; - - //----------------------------------------------------------------------- - - /// \{ - /// \brief Returns the contained value. - /// - /// \throws bad_optional_access if \c *this does not contain a value. - /// - /// \return the value of \c *this - BPSTD_CPP14_CONSTEXPR auto value() & -> value_type &; - BPSTD_CPP14_CONSTEXPR auto value() && -> value_type &&; - /// \} - - /// \{ - /// \brief Returns the contained value. - /// - /// \throws bad_optional_access if \c *this does not contain a value. - /// - /// \return the value of \c *this - BPSTD_CPP14_CONSTEXPR auto value() const & -> const value_type &; - BPSTD_CPP14_CONSTEXPR auto value() const && -> const value_type &&; - /// \} - - //----------------------------------------------------------------------- - - /// \{ - /// \brief Returns the contained value if \c *this has a value, - /// otherwise returns \p default_value. - /// - /// \param default_value the value to use in case \c *this is empty - /// \return the value to use in case \c *this is empty - template constexpr auto value_or(U &&default_value) const & -> value_type; - template BPSTD_CPP14_CONSTEXPR auto value_or(U &&default_value) && -> value_type; - /// \} - - //----------------------------------------------------------------------- - // Modifiers - //----------------------------------------------------------------------- - - /// \brief Swaps the contents with those of other. - /// - /// \param other the optional object to exchange the contents with - void swap(optional& other); - - /// \brief If \c *this contains a value, destroy that value as if by - /// \c value().T::~T(). - /// - /// Otherwise, there are no effects. \c *this does not contain a value - /// after this call. - void reset() noexcept(std::is_nothrow_destructible::value); - - /// \brief Constructs the contained value in-place. - /// - /// If \c *this already contains a value before the call, the contained - /// value is destroyed by calling its destructor. - /// - /// \param args the arguments to pass to the constructor - template - void emplace(Args&&...args); - - /// \brief Constructs the contained value in-place. - /// - /// If \c *this already contains a value before the call, the contained - /// value is destroyed by calling its destructor. - /// - /// \param ilist the initializer list to pass to the constructor - /// \param args the arguments to pass to the constructor - template - void emplace(std::initializer_list ilist, Args&&...args); - }; - - //========================================================================= - // non-member functions : class : optional - //========================================================================= - - //------------------------------------------------------------------------- - // Comparison - //------------------------------------------------------------------------- - - template BPSTD_CPP14_CONSTEXPR auto operator==(const optional &lhs, const optional &rhs) -> bool; - template BPSTD_CPP14_CONSTEXPR auto operator!=(const optional &lhs, const optional &rhs) -> bool; - template BPSTD_CPP14_CONSTEXPR auto operator<(const optional &lhs, const optional &rhs) -> bool; - template BPSTD_CPP14_CONSTEXPR auto operator>(const optional &lhs, const optional &rhs) -> bool; - template BPSTD_CPP14_CONSTEXPR auto operator<=(const optional &lhs, const optional &rhs) -> bool; - template BPSTD_CPP14_CONSTEXPR auto operator>=(const optional &lhs, const optional &rhs) -> bool; - - //------------------------------------------------------------------------- - - template constexpr auto operator==(const optional &opt, nullopt_t) noexcept -> bool; - template constexpr auto operator==(nullopt_t, const optional &opt) noexcept -> bool; - template constexpr auto operator!=(const optional &opt, nullopt_t) noexcept -> bool; - template constexpr auto operator!=(nullopt_t, const optional &opt) noexcept -> bool; - template constexpr auto operator<(const optional &opt, nullopt_t) noexcept -> bool; - template constexpr auto operator<(nullopt_t, const optional &opt) noexcept -> bool; - template constexpr auto operator>(const optional &opt, nullopt_t) noexcept -> bool; - template constexpr auto operator>(nullopt_t, const optional &opt) noexcept -> bool; - template constexpr auto operator<=(const optional &opt, nullopt_t) noexcept -> bool; - template constexpr auto operator<=(nullopt_t, const optional &opt) noexcept -> bool; - template constexpr auto operator>=(const optional &opt, nullopt_t) noexcept -> bool; - template constexpr auto operator>=(nullopt_t, const optional &opt) noexcept -> bool; - - //------------------------------------------------------------------------- - - template constexpr auto operator==(const optional &opt, const T &value) -> bool; - template constexpr auto operator==(const T &value, const optional &opt) -> bool; - template constexpr auto operator!=(const optional &opt, const T &value) -> bool; - template constexpr auto operator!=(const T &value, const optional &opt) -> bool; - template constexpr auto operator<(const optional &opt, const T &value) -> bool; - template constexpr auto operator<(const T &value, const optional &opt) -> bool; - template constexpr auto operator>(const optional &opt, const T &value) -> bool; - template constexpr auto operator>(const T &value, const optional &opt) -> bool; - template constexpr auto operator<=(const optional &opt, const T &value) -> bool; - template constexpr auto operator<=(const T &value, const optional &opt) -> bool; - template constexpr auto operator>=(const optional &opt, const T &value) -> bool; - template constexpr auto operator>=(const T &value, const optional &opt) -> bool; - - //------------------------------------------------------------------------- - // Utilities - //------------------------------------------------------------------------- - - /// \brief Creates an optional object from \p value - /// - /// \param value the value to construct the optional from - template constexpr auto make_optional(T &&value) -> optional>; - - /// \brief Creates an optional object of type \p T from the given \p args - /// - /// \tparam T the type to construct - /// \param args the arguments to pass to \p T's constructor - template constexpr auto make_optional(Args &&...args) -> optional; - - /// \brief Creates an optional object of type \p T from the given - /// \p il \p args - /// - /// \tparam T the type to construct - /// \param il the initializer list to pass - /// \param args the arguments to pass to \p T's constructor - template - constexpr auto make_optional(std::initializer_list il, Args &&...args) -> optional; - - //------------------------------------------------------------------------- - - /// \brief Swaps \p lhs and \p rhs - /// - /// \param lhs the left optional to swap - /// \param rhs the right optional to swap - template - void swap(optional& lhs, optional& rhs); - -} // namespace bpstd - -//============================================================================= -// class : detail::optional_base -//============================================================================= - -//----------------------------------------------------------------------------- -// Constructors -//----------------------------------------------------------------------------- - -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::detail::optional_base - ::optional_base(nullopt_t) - noexcept - : m_storage{}, - m_engaged{false} -{ -} - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::detail::optional_base::optional_base(in_place_t, Args&&...args) - noexcept(std::is_nothrow_constructible::value) - : m_storage(in_place, bpstd::forward(args)...), - m_engaged{true} -{ - -} - -//----------------------------------------------------------------------------- -// Protected Observers -//----------------------------------------------------------------------------- - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::detail::optional_base::val() noexcept -> T * -{ - return &m_storage.something; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::detail::optional_base::val() const noexcept -> const T * -{ - return &m_storage.something; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::detail::optional_base::contains_value() const noexcept - -> bool -{ - return m_engaged; -} - -//----------------------------------------------------------------------------- -// Protected Modifiers -//----------------------------------------------------------------------------- - -template -template -inline BPSTD_INLINE_VISIBILITY -void bpstd::detail::optional_base::construct(Args&&...args) -{ - m_storage.something = T(bpstd::forward(args)...); - m_engaged = true; -} - -template -inline BPSTD_INLINE_VISIBILITY -void bpstd::detail::optional_base::destruct() -{ - m_engaged = false; -} - -//============================================================================= -// class : detail::optional_base -//============================================================================= - -//----------------------------------------------------------------------------- -// Constructors / Destructor -//----------------------------------------------------------------------------- - -template -inline BPSTD_INLINE_VISIBILITY -bpstd::detail::optional_base - ::optional_base(nullopt_t) - noexcept - : m_storage{}, - m_engaged{false} -{ -} - -template -template -inline BPSTD_INLINE_VISIBILITY -bpstd::detail::optional_base - ::optional_base(in_place_t, Args&&...args) - noexcept(std::is_nothrow_constructible::value) - : m_storage(in_place, bpstd::forward(args)...), - m_engaged{true} -{ - -} - -//----------------------------------------------------------------------------- - -template -inline BPSTD_INLINE_VISIBILITY -bpstd::detail::optional_base::~optional_base() - noexcept(std::is_nothrow_destructible::value) -{ - if (m_engaged) { - m_storage.something.~T(); - } -} - -//----------------------------------------------------------------------------- -// Protected Observers -//----------------------------------------------------------------------------- - -template inline BPSTD_INLINE_VISIBILITY auto bpstd::detail::optional_base::val() noexcept -> T * -{ - return &m_storage.something; -} - -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::detail::optional_base::val() const noexcept -> const T * -{ - return &m_storage.something; -} - -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::detail::optional_base::contains_value() const noexcept -> bool -{ - return m_engaged; -} - -//----------------------------------------------------------------------------- -// Protected Modifiers -//----------------------------------------------------------------------------- - -template -template -inline BPSTD_INLINE_VISIBILITY -void bpstd::detail::optional_base::construct(Args&&...args) -{ - new (&m_storage.something) T(bpstd::forward(args)...); - m_engaged = true; -} - -template -inline BPSTD_INLINE_VISIBILITY -void bpstd::detail::optional_base::destruct() -{ - if (m_engaged) { - m_storage.something.~T(); - m_engaged = false; - } -} - -//============================================================================= -// class : optional -//============================================================================= - -//----------------------------------------------------------------------------- -// Constructor / Assignment -//----------------------------------------------------------------------------- - -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::optional::optional() - noexcept - : base_type{ nullopt } -{ - -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::optional::optional(nullopt_t) - noexcept - : optional{} -{ - -} - -//----------------------------------------------------------------------------- - -template -inline BPSTD_INLINE_VISIBILITY -bpstd::optional - ::optional(detail::enable_overload_if_t::value,const optional&> other) - : optional{} -{ - if (other.has_value()) - { - base_type::construct(*other); - } -} - -template -inline BPSTD_INLINE_VISIBILITY -bpstd::optional - ::optional(detail::enable_overload_if_t::value,optional&&> other) - : optional{} -{ - if (other.has_value()) - { - base_type::construct(bpstd::move(*other)); - } -} - -//----------------------------------------------------------------------------- - -template -template ::value && std::is_convertible::value>*> -inline BPSTD_INLINE_VISIBILITY -bpstd::optional::optional(const optional& other) - : optional{} -{ - if (other.has_value()) - { - base_type::construct(*other); - } -} - -template -template ::value && !std::is_convertible::value>*> -inline BPSTD_INLINE_VISIBILITY -bpstd::optional::optional(const optional& other) - : optional{} -{ - if (other.has_value()) - { - base_type::construct(*other); - } -} - -//----------------------------------------------------------------------------- - -template -template ::value && std::is_convertible::value>*> -inline BPSTD_INLINE_VISIBILITY -bpstd::optional::optional(optional&& other) - : optional{} -{ - if (other.has_value()) - { - base_type::construct(bpstd::move(*other)); - } -} -template -template ::value && !std::is_convertible::value>*> -inline BPSTD_INLINE_VISIBILITY -bpstd::optional::optional(optional&& other) - : optional{} -{ - if (other.has_value()) - { - base_type::construct(bpstd::move(*other)); - } -} - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::optional::optional(in_place_t, Args&&...args) - : base_type{ in_place, bpstd::forward(args)... } -{ - -} - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::optional - ::optional( in_place_t, - std::initializer_list ilist, - Args&&...args ) - : base_type{ in_place, ilist, bpstd::forward(args)... } -{ - -} - -template -template ::value && std::is_convertible::value>*> -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::optional::optional(U&& value) - : base_type{ in_place, bpstd::forward(value) } -{ - -} - -template -template ::value && !std::is_convertible::value>*> -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::optional::optional(U&& value) - : base_type{ in_place, bpstd::forward(value) } -{ - -} - -//----------------------------------------------------------------------------- - -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::optional::operator=(nullopt_t) -> bpstd::optional & -{ - base_type::destruct(); - return (*this); -} - -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::optional::operator=( - detail::enable_overload_if_t::value && std::is_copy_assignable::value, - const optional &> - other) -> bpstd::optional & -{ - if (has_value() && other.has_value()) { - (*base_type::val()) = (*other); - } else if (has_value()) { - base_type::destruct(); - } else if (other.has_value()) { - base_type::construct(*other); - } - - return (*this); -} - -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::optional::operator=( - detail::enable_overload_if_t::value && std::is_move_assignable::value, optional &&> - other) -> bpstd::optional & -{ - if (has_value() && other.has_value()) { - (*base_type::val()) = bpstd::move(*other); - } else if (has_value()) { - base_type::destruct(); - } else if (other.has_value()) { - base_type::construct(bpstd::move( *other )); - } - - return (*this); -} - -template -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::optional::operator=(U &&value) -> bpstd::optional & -{ - if (has_value()) { - (*base_type::val()) = bpstd::forward(value); - } else { - base_type::construct(bpstd::forward(value)); - } - return (*this); -} - -//----------------------------------------------------------------------------- -// Observers -//----------------------------------------------------------------------------- - -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::optional::operator bool() - const noexcept -{ - return base_type::contains_value(); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::optional::has_value() const noexcept -> bool -{ - return base_type::contains_value(); -} - -//----------------------------------------------------------------------------- - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::optional::operator->() noexcept -> - typename bpstd::optional::value_type * -{ - return base_type::val(); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::optional::operator->() const noexcept -> const - typename bpstd::optional::value_type * -{ - return base_type::val(); -} - -//----------------------------------------------------------------------------- - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::optional::operator*() & noexcept -> - typename bpstd::optional::value_type & -{ - return *base_type::val(); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::optional::operator*() && noexcept -> - typename bpstd::optional::value_type && -{ - return bpstd::move(*base_type::val()); -} - -//----------------------------------------------------------------------------- - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::optional::operator*() const & noexcept -> const - typename bpstd::optional::value_type & -{ - return *base_type::val(); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::optional::operator*() const && noexcept -> const - typename bpstd::optional::value_type && -{ - return bpstd::move(*base_type::val()); -} - -//----------------------------------------------------------------------------- - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::optional::value() & -> - typename bpstd::optional::value_type & -{ - if (static_cast(*this)) { - return *base_type::val(); - } - throw bad_optional_access{}; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::optional::value() && -> - typename bpstd::optional::value_type && -{ - if (static_cast(*this)) { - return bpstd::move(*base_type::val()); - } - throw bad_optional_access{}; -} - -//----------------------------------------------------------------------------- - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::optional::value() const & -> const - typename bpstd::optional::value_type & -{ - if (static_cast(*this)) { - return *base_type::val(); - } - throw bad_optional_access{}; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::optional::value() const && -> const - typename bpstd::optional::value_type && -{ - if (static_cast(*this)) { - return bpstd::move(*base_type::val()); - } - throw bad_optional_access{}; -} - -//----------------------------------------------------------------------------- - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::optional::value_or(U &&default_value) const & -> - typename bpstd::optional::value_type -{ - return bool(*this) ? (*base_type::val()) : bpstd::forward(default_value); -} - -template -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::optional::value_or(U &&default_value) && -> - typename bpstd::optional::value_type -{ - return bool(*this) ? (*base_type::val()) : bpstd::forward(default_value); -} - -//----------------------------------------------------------------------------- -// Modifiers -//----------------------------------------------------------------------------- - -template -inline BPSTD_INLINE_VISIBILITY -void bpstd::optional::swap(optional& other) -{ - using std::swap; - - if (has_value() && other.has_value()){ - swap(*base_type::val(), *other); - } else if (has_value()) { - other = bpstd::move(*this); - reset(); // leave this unengaged - } else if (other.has_value()) { - *this = bpstd::move(other); - other.reset(); // leave 'other' unengaged - } -} - -template -inline BPSTD_INLINE_VISIBILITY -void bpstd::optional::reset() - noexcept(std::is_nothrow_destructible::value) -{ - base_type::destruct(); -} - -//----------------------------------------------------------------------------- - -template -template -inline BPSTD_INLINE_VISIBILITY -void bpstd::optional::emplace(Args&&...args) -{ - base_type::destruct(); - base_type::construct(bpstd::forward(args)...); -} - -template -template -inline BPSTD_INLINE_VISIBILITY -void bpstd::optional::emplace(std::initializer_list ilist, - Args&&...args) -{ - base_type::destruct(); - base_type::construct(ilist, bpstd::forward(args)...); -} - -//============================================================================= -// Equality Operators -//============================================================================= - -//----------------------------------------------------------------------------- -// Comparison -//----------------------------------------------------------------------------- - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::operator==(const optional &lhs, - const optional &rhs) -> bool -{ - if (static_cast(lhs) != static_cast(rhs)) { - return false; - } - if (!static_cast(lhs)) { - return true; - } - return *lhs == *rhs; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::operator!=(const optional &lhs, - const optional &rhs) -> bool -{ - if (static_cast(lhs) != static_cast(rhs)) { - return true; - } - if (!static_cast(lhs)) { - return false; - } - return *lhs != *rhs; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::operator<(const optional &lhs, - const optional &rhs) -> bool -{ - if (!static_cast(rhs)) { - return false; - } - if (!static_cast(lhs)) { - return true; - } - return *lhs < *rhs; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::operator>(const optional &lhs, - const optional &rhs) -> bool -{ - if (!static_cast(lhs)) { - return false; - } - if (!static_cast(rhs)) { - return true; - } - return *lhs > *rhs; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::operator<=(const optional &lhs, - const optional &rhs) -> bool -{ - if (!static_cast(lhs)) { - return true; - } - if (!static_cast(rhs)) { - return false; - } - return *lhs <= *rhs; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::operator>=(const optional &lhs, - const optional &rhs) -> bool -{ - if (!static_cast(rhs)) { - return true; - } - if (!static_cast(lhs)) { - return false; - } - return *lhs >= *rhs; -} - -//----------------------------------------------------------------------------- - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator==(const optional &opt, nullopt_t) noexcept -> bool -{ - return !opt; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator==(nullopt_t, const optional &opt) noexcept -> bool -{ - return !opt; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator!=(const optional &opt, nullopt_t) noexcept -> bool -{ - return static_cast(opt); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator!=(nullopt_t, const optional &opt) noexcept -> bool -{ - return static_cast(opt); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator<(const optional &, nullopt_t) noexcept -> bool -{ - return false; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator<(nullopt_t, const optional &opt) noexcept -> bool -{ - return static_cast(opt); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator>(const optional &opt, nullopt_t) noexcept -> bool -{ - return static_cast(opt); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator>(nullopt_t, const optional &) noexcept -> bool -{ - return false; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator<=(const optional &opt, nullopt_t) noexcept -> bool -{ - return !opt; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator<=(nullopt_t, const optional &) noexcept -> bool -{ - return true; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator>=(const optional &, nullopt_t) noexcept -> bool -{ - return true; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator>=(nullopt_t, const optional &opt) noexcept -> bool -{ - return !opt; -} - -//----------------------------------------------------------------------------- - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator==(const optional &opt, const T &value) -> bool -{ - return static_cast(opt) ? *opt == value : false; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator==(const T &value, const optional &opt) -> bool -{ - return static_cast(opt) ? value == *opt : false; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator!=(const optional &opt, const T &value) -> bool -{ - return static_cast(opt) ? *opt != value : true; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator!=(const T &value, const optional &opt) -> bool -{ - return static_cast(opt) ? value != *opt : true; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator<(const optional &opt, const T &value) -> bool -{ - return static_cast(opt) ? *opt < value : true; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator<(const T &value, const optional &opt) -> bool -{ - return static_cast(opt) ? value < *opt : false; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator>(const optional &opt, const T &value) -> bool -{ - return static_cast(opt) ? *opt > value : false; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator>(const T &value, const optional &opt) -> bool -{ - return static_cast(opt) ? value > *opt : true; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator<=(const optional &opt, const T &value) -> bool -{ - return static_cast(opt) ? *opt <= value : true; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator<=(const T &value, const optional &opt) -> bool -{ - return static_cast(opt) ? value <= *opt : false; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator>=(const optional &opt, const T &value) -> bool -{ - return static_cast(opt) ? *opt >= value : false; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator>=(const T &value, const optional &opt) -> bool -{ - return static_cast(opt) ? value >= *opt : true; -} - -//----------------------------------------------------------------------------- -// Non-member functions -//----------------------------------------------------------------------------- - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::make_optional(T &&value) -> bpstd::optional> -{ - return optional>(bpstd::forward(value)); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::make_optional(Args &&...args) -> bpstd::optional -{ - return optional(in_place, bpstd::forward(args)...); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::make_optional(std::initializer_list il, Args &&...args) - -> bpstd::optional -{ - return optional( - in_place, - std::forward>(il), - std::forward(args)... - ); -} - -template -inline BPSTD_INLINE_VISIBILITY -void bpstd::swap(optional& lhs, optional& rhs) -{ - lhs.swap(rhs); -} - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_OPTIONAL_HPP */ diff --git a/src/libs/vmisc/bpstd/span.hpp b/src/libs/vmisc/bpstd/span.hpp deleted file mode 100644 index b6bccecb4..000000000 --- a/src/libs/vmisc/bpstd/span.hpp +++ /dev/null @@ -1,759 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file span.hpp -/// -/// \brief This header provides definitions from the C++ header -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_SPAN_HPP -#define BPSTD_SPAN_HPP - -#include "detail/config.hpp" -#include "detail/proxy_iterator.hpp" - -#include "cstddef.hpp" // byte -#include "memory.hpp" // to_address -#include "type_traits.hpp" // conjunction, remove_cvref_t, etc - -#include // std::size_t -#include // std::array -#include // std::iterator_traits - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -namespace bpstd { - - //============================================================================ - // constants : dynamic_extent - //============================================================================ - - BPSTD_CPP17_INLINE constexpr auto dynamic_extent = static_cast(-1); - - namespace detail { - - template - class extent_storage - { - public: - constexpr extent_storage() noexcept = default; - - template - constexpr explicit extent_storage(extent_storage) - { - static_assert( - UExtent == Extent, - "Extent must be the same size as UExtent" - ); - } - - constexpr explicit extent_storage(std::size_t) - { - - } - - constexpr auto size() const noexcept -> std::size_t { return Extent; } - }; - - template <> - class extent_storage - { - public: - template - constexpr explicit extent_storage(extent_storage ext) - : m_size{ext.size()} - { - - } - - constexpr explicit extent_storage(std::size_t size) - : m_size{size} - { - - } - - constexpr auto size() const noexcept -> std::size_t { return m_size; } - - private: - - std::size_t m_size; - }; - - template - class span_storage_type : public extent_storage - { - //------------------------------------------------------------------------ - // Constructors - //------------------------------------------------------------------------ - public: - - template - constexpr span_storage_type(T* data, ExtentType ext) - : extent_storage(ext), - m_data{data} - { - - } - - //------------------------------------------------------------------------ - // Observers - //------------------------------------------------------------------------ - public: - - using extent_storage::size; - - constexpr auto data() const noexcept -> T * { return m_data; } - - //------------------------------------------------------------------------ - // Private Members - //------------------------------------------------------------------------ - private: - - T* m_data; - }; - - template - struct is_allowed_extent_conversion - : bool_constant<(From == To) || (To == dynamic_extent)>{}; - - template - struct compute_subspan_size - : integral_constant{}; - - template - using iter_reference = typename std::iterator_traits::reference; - - template - using is_iter_convertible = conjunction< - is_same>,remove_cv_t>, - is_convertible,remove_cv_t> - >; - - } // namespace detail - - //============================================================================ - // class : span - //============================================================================ - - ////////////////////////////////////////////////////////////////////////////// - /// \brief This class is a non-owning view of a contiguous piece of memory - /// - /// This type describes an object that can refer to a contiguous sequence of - /// objects with the first element of the sequence at position zero. A span - /// can either have a static extent, in which case the number of elements in - /// the sequence is known and encoded in the type, or a dynamic extent, - /// in which case the size is known at runtime. - /// - /// \tparam T the underlying type of the span - /// \tparam Extent the extent (size) of the span - ////////////////////////////////////////////////////////////////////////////// - template - class span - { - //-------------------------------------------------------------------------- - // Public Member Types - //-------------------------------------------------------------------------- - public: - - using element_type = T; - using value_type = remove_cv_t; - using size_type = std::size_t; - using difference_type = std::ptrdiff_t; - - using pointer = element_type*; - using const_pointer = const element_type*; - using reference = element_type&; - using const_reference = const element_type&; - - using iterator = detail::proxy_iterator>; - using reverse_iterator = std::reverse_iterator; - - //-------------------------------------------------------------------------- - // Public Member Constants - //-------------------------------------------------------------------------- - public: - - BPSTD_CPP17_INLINE static constexpr std::size_t extent = Extent; - - //-------------------------------------------------------------------------- - // Constructors / Assignment - //-------------------------------------------------------------------------- - public: - - /// \brief Default-constructs a span - /// - /// This constructor only participates in overload resolution if the span - /// either is size 0, or has a dynamic extent - template ::value>> - constexpr span() noexcept; - - /// \{ - /// \brief Constructs a span from an iterator \p it and the \p count - /// - /// This constructor only participates in overload resolution if the - /// following criteria are met: - /// * Extent is dynamic_extent - /// * to_address(it) is convertible to T* - /// - /// This constructor is explicit if `Extent` != `dynamic_extent` - /// - /// \param it the iterator - /// \param count the number of entries in the sequence - template ::value,int> = 0> - constexpr span(It it, size_type count) noexcept; - template ::value,int> = 0> - constexpr explicit span(It it, size_type count) noexcept; - /// \} - - /// \brief Constructs a span from an iterator range - /// - /// This constructor only participates in overload resolution if the - /// following criteria are met: - /// * Extent is dynamic_extent - /// * to_address(it) is convertible to T* - /// - /// \param it the iterator - /// \param end the end iterator - template ::value, int> = 0> - constexpr span(It it, End end) noexcept; - template ::value, int> = 0> - constexpr explicit span(It it, End end) noexcept; - - /// \brief Constructs a span from an array reference - /// - /// This constructor only participates in overload resolution if any of the - /// following criteria are met: - /// * Extent is dynamic_extent - /// * N is the same as Extent - /// - /// \param arr the array reference - template ::value>> - // cppcheck-suppress noExplicitConstructor - constexpr span(element_type (&arr)[N]) noexcept; - - /// \{ - /// \brief Constructs a span from a reference to a std::array - /// - /// This constructor only participates in overload resolution if the - /// following criteria are met: - /// * Extent is dynamic_extent or N is the same as Extent - /// * U is at most a cv-qualification difference from T - /// - /// \param arr the array reference - template ::value>> - // cppcheck-suppress noExplicitConstructor - constexpr span(std::array& arr) noexcept; - template ::value>> - // cppcheck-suppress noExplicitConstructor - constexpr span(const std::array& arr) noexcept; - /// \} - - // range-constructor omitted since ranges are not part of backport yet - - /// \brief Constructs a span from a different span - /// - /// This constructor only participates in overload resolution if the - /// following criteria are met: - /// * Extent is dynamic_extent or N is the same as Extent - /// * U is at most a cv-qualification difference from T - /// - /// \param s the span - template ::value>> - // cppcheck-suppress noExplicitConstructor - constexpr span(const span& s) noexcept; - - /// \brief Constructs a span by copying \p other - /// - /// \param other the other span to copy - constexpr span(const span& other) noexcept = default; - - //-------------------------------------------------------------------------- - - /// \brief Assigns a span from \p other - /// - /// \param other the other span to copy - /// \return reference to this - BPSTD_CPP14_CONSTEXPR auto operator=(const span &other) noexcept -> span & = default; - - //-------------------------------------------------------------------------- - // Element Access - //-------------------------------------------------------------------------- - public: - - /// \brief Gets a reference to the front element of this span - /// - /// \pre empty() is false - /// \return reference to front element - constexpr auto front() const noexcept -> reference; - - /// \brief Gets a reference to the back element of this span - /// - /// \pre empty() is false - /// \return reference to back element - constexpr auto back() const noexcept -> reference; - - /// \brief Gets a reference to the element at \p idx - /// - /// \pre \p idx is less than size() - /// \param idx the index - /// \return reference to the element at \p idx - constexpr auto operator[](size_type idx) const noexcept -> reference; - - /// \brief Gets a pointer to the start of the data - /// - /// \return pointer to the data - constexpr auto data() const noexcept -> pointer; - - //-------------------------------------------------------------------------- - // Observers - //-------------------------------------------------------------------------- - public: - - /// \brief Gets the number of elements in this span - /// - /// \return the number of elements in this span - constexpr auto size() const noexcept -> size_type; - - /// \brief Gets the number of bytes in this span - /// - /// \return the number of bytes in this span - constexpr auto size_bytes() const noexcept -> size_type; - - /// \brief Queries whether this span is empty - /// - /// \return true if this span is empty - constexpr auto empty() const noexcept -> bool; - - //-------------------------------------------------------------------------- - // Subviews - //-------------------------------------------------------------------------- - public: - - /// \brief Creates a subspan from the first \p Count elements - /// - /// \pre A program is ill-formed if \p Count > Extent - /// - /// \tparam Count the number of elements to create in the subspan - /// \return the first \p Count elements - template constexpr auto first() const -> span; - - /// \brief Creates a subspan from the first \p count elements - /// - /// \pre It is undefined behavior if \p count > size() - /// - /// \param count the number of elements to create in the subspan - /// \return the first \p count elements - constexpr auto first(size_t count) const -> span; - - //-------------------------------------------------------------------------- - - /// \brief Creates a subspan from the last \p Count elements - /// - /// \pre A program is ill-formed if \p Count > Extent - /// - /// \tparam Count the number of elements to create in the subspan - /// \return the last \p Count elements - template constexpr auto last() const -> span; - - /// \brief Creates a subspan from the last \p count elements - /// - /// \pre It is undefined behavior if \p count > size() - /// - /// \param count the number of elements to create in the subspan - /// \return the last \p count elements - constexpr auto last(size_t count) const -> span; - - //-------------------------------------------------------------------------- - - /// \brief Creates a subspan that is \p Count elements long, \p Offset from - /// the start of this span - /// - /// \tparam Offset the amount to offset the span by - /// \tparam Count the number of elements to create in the subspan - /// \return the created subspan - template - constexpr auto subspan() const -> span::value>; - - /// \brief Creates a subspan that is \p count elements long, \p offset from - /// the start of this span - /// - /// \param offset the amount to offset the span by - /// \param count the number of elements to create in the subspan - /// \return the created subspan - constexpr auto subspan(std::size_t offset, std::size_t count = dynamic_extent) const -> span; - - //-------------------------------------------------------------------------- - // Iterators - //-------------------------------------------------------------------------- - public: - constexpr auto begin() const noexcept -> iterator; - constexpr auto end() const noexcept -> iterator; - constexpr auto rbegin() const noexcept -> reverse_iterator; - constexpr auto rend() const noexcept -> reverse_iterator; - - //-------------------------------------------------------------------------- - // Private Members - //-------------------------------------------------------------------------- - private: - - using storage_type = detail::span_storage_type; - - storage_type m_storage; - }; - - //============================================================================ - // non-member functions : class : span - //============================================================================ - - //---------------------------------------------------------------------------- - // Utilities - //---------------------------------------------------------------------------- - - /// \brief Converts a span \p s to a byte span - /// - /// \param s the span to convert - /// \return a span of the byte range that \p s covered - template auto as_bytes(span s) noexcept -> span; - - /// \brief Converts a span \p s to a writable byte span - /// - /// \param s the span to convert - /// \return a span of the byte range that \p s covered - template auto as_writable_bytes(span s) noexcept -> span; - -} // namespace bpstd - -template -constexpr std::size_t bpstd::span::extent; - -//============================================================================== -// non-member functions : class : span -//============================================================================== - -//------------------------------------------------------------------------------ -// Constructors -//------------------------------------------------------------------------------ - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::span::span() - noexcept - : m_storage{nullptr, detail::extent_storage<0>{}} -{ - -} - -template -template ::value,int>> -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::span::span(It it, size_type count) - noexcept - : m_storage{to_address(it), count} -{ - -} - -template -template ::value,int>> -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::span::span(It it, size_type count) - noexcept - : m_storage{to_address(it), count} -{ - -} - -template -template ::value, int>> -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::span::span(It it, End end) - noexcept - : m_storage{to_address(it), static_cast(end - it)} -{ - -} - -template -template ::value, int>> -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::span::span(It it, End end) - noexcept - : m_storage{to_address(it), static_cast(end - it)} -{ - -} - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::span::span(element_type (&arr)[N]) - noexcept - : m_storage{static_cast(arr), detail::extent_storage{}} -{ - -} - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::span::span(std::array& arr) - noexcept - : m_storage{arr.data(), detail::extent_storage{}} -{ - -} - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::span::span(const std::array& arr) - noexcept - : m_storage{arr.data(), detail::extent_storage{}} -{ - -} - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::span::span(const span& s) - noexcept - : m_storage{s.data(), detail::extent_storage{s.size()}} -{ - -} - -//------------------------------------------------------------------------------ -// Element Access -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::span::front() const noexcept -> - typename bpstd::span::reference -{ - return data()[0]; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::span::back() const noexcept -> - typename bpstd::span::reference -{ - return data()[m_storage.size()-1]; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::span::operator[](size_type idx) const noexcept -> - typename bpstd::span::reference -{ - return data()[idx]; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::span::data() const noexcept -> - typename bpstd::span::pointer -{ - return m_storage.data(); -} - -//------------------------------------------------------------------------------ -// Observers -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::span::size() const noexcept -> - typename bpstd::span::size_type -{ - return m_storage.size(); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::span::size_bytes() const noexcept -> - typename bpstd::span::size_type -{ - return size() * sizeof(T); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::span::empty() const noexcept -> bool -{ - return size() == 0u; -} - -//------------------------------------------------------------------------------ -// Subviews -//------------------------------------------------------------------------------ - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::span::first() const - -> bpstd::span::element_type, Count> -{ - static_assert( - Count <= Extent, - "A Count larger than Extent is ill-formed" - ); - - return span{data(), Count}; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::span::first(size_t count) const - -> bpstd::span::element_type> -{ - return {data(), count}; -} - -//------------------------------------------------------------------------------ - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::span::last() const - -> bpstd::span::element_type, Count> -{ - static_assert( - Count <= Extent, - "A Count larger than Extent is ill-formed" - ); - - return span{data() + (size() - Count), Count}; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::span::last(size_t count) const - -> bpstd::span::element_type> -{ - return {data() + (size() - count), count}; -} - -//------------------------------------------------------------------------------ - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::span::subspan() const - -> bpstd::span::element_type, - bpstd::detail::compute_subspan_size::value> -{ - using result_type = span< - element_type, - detail::compute_subspan_size::value - >; - - return result_type{ - data() + Offset, - (Count == dynamic_extent) ? (size() - Offset) : Count - }; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::span::subspan(std::size_t offset, - std::size_t count) const - -> bpstd::span::element_type> -{ - return { - data() + offset, - (count == dynamic_extent) ? (size() - offset) : count - }; -} - -//------------------------------------------------------------------------------ -// Iterators -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::span::begin() const noexcept -> - typename bpstd::span::iterator -{ - return iterator{data()}; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::span::end() const noexcept -> - typename bpstd::span::iterator -{ - return iterator{data() + size()}; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::span::rbegin() const noexcept -> - typename bpstd::span::reverse_iterator -{ - return reverse_iterator(end()); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::span::rend() const noexcept -> - typename bpstd::span::reverse_iterator -{ - return reverse_iterator(begin()); -} - -//============================================================================== -// non-member functions : class : span -//============================================================================== - -//------------------------------------------------------------------------------ -// Utilities -//------------------------------------------------------------------------------ - -template -inline auto bpstd::as_bytes(span s) noexcept -> bpstd::span -{ - return {reinterpret_cast(s.data()), s.size_bytes()}; -} - -template -inline auto bpstd::as_writable_bytes(span s) noexcept -> bpstd::span -{ - return {reinterpret_cast(s.data()), s.size_bytes()}; -} - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_SPAN_HPP */ diff --git a/src/libs/vmisc/bpstd/string.hpp b/src/libs/vmisc/bpstd/string.hpp deleted file mode 100644 index eee8d1c38..000000000 --- a/src/libs/vmisc/bpstd/string.hpp +++ /dev/null @@ -1,80 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file string.hpp -/// -/// \brief This header provides definitions from the C++ header -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_STRING_HPP -#define BPSTD_STRING_HPP - -#include "detail/config.hpp" - -#include - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -namespace bpstd { - - inline namespace literals { - inline namespace string_literals { - - auto operator""_s(const char *s, std::size_t len) -> std::string; - auto operator""_s(const char16_t *s, std::size_t len) -> std::u16string; - auto operator""_s(const char32_t *s, std::size_t len) -> std::u32string; - auto operator""_s(const wchar_t *s, std::size_t len) -> std::wstring; - - } // inline namespace string_literals - } // inline namespace literals - -} // namespace bpstd - -inline BPSTD_INLINE_VISIBILITY auto bpstd::literals::string_literals::operator""_s(const char *s, std::size_t len) - -> std::string -{ - return std::string{s, len}; -} - -inline BPSTD_INLINE_VISIBILITY auto bpstd::literals::string_literals::operator""_s(const char16_t *s, std::size_t len) - -> std::u16string -{ - return std::u16string{s, len}; -} - -inline BPSTD_INLINE_VISIBILITY auto bpstd::literals::string_literals::operator""_s(const char32_t *s, std::size_t len) - -> std::u32string -{ - return std::u32string{s, len}; -} - -inline BPSTD_INLINE_VISIBILITY auto bpstd::literals::string_literals::operator""_s(const wchar_t *s, std::size_t len) - -> std::wstring -{ - return std::wstring{s, len}; -} - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_STRING_HPP */ diff --git a/src/libs/vmisc/bpstd/string_view.hpp b/src/libs/vmisc/bpstd/string_view.hpp deleted file mode 100644 index 51c0d7a87..000000000 --- a/src/libs/vmisc/bpstd/string_view.hpp +++ /dev/null @@ -1,1342 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file string_view.hpp -/// -/// \brief This header provides definitions from the C++ header -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2016 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_STRING_VIEW_HPP -#define BPSTD_STRING_VIEW_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "detail/config.hpp" // BPSTD_CPP14_CONSTEXPR - -#include // std::min, std::max -#include // std::char_traits -#include // std::basic_ostream -#include // std::size_t -#include // std::allocator -#include // std::out_of_range -#include // std::reverse_iterator -#include // std::streamsize - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -namespace bpstd { // back-port std - - ////////////////////////////////////////////////////////////////////////////// - /// \brief A semantic non-owning wrapper around contiguous character - /// sequences. - /// - /// This class describes an object that can refer to a constant contiguous - /// sequence of char-like objects with the first element of the sequence - /// at position zero. - ////////////////////////////////////////////////////////////////////////////// - template > - class basic_string_view - { - //-------------------------------------------------------------------------- - // Public Member Types - //-------------------------------------------------------------------------- - public: - - using char_type = CharT; - using traits_type = Traits; - using size_type = std::size_t; - - using value_type = CharT; - using reference = value_type&; - using const_reference = const value_type&; - using pointer = value_type*; - using const_pointer = const value_type*; - - using iterator = const CharT*; - using const_iterator = const CharT*; - using reverse_iterator = std::reverse_iterator; - using const_reverse_iterator = std::reverse_iterator; - - //-------------------------------------------------------------------------- - // Public Members - //-------------------------------------------------------------------------- - public: - - static constexpr size_type npos = size_type(-1); - - //-------------------------------------------------------------------------- - // Constructors - //-------------------------------------------------------------------------- - public: - - /// \brief Default constructs a basic_string_view without any content - constexpr basic_string_view() noexcept; - - /// \brief Constructs a basic_string_view by copying another one - /// - /// \param other the string view being copied - constexpr basic_string_view(const basic_string_view& other) noexcept = default; - - /// \brief Constructs a basic_string_view by moving anothe rone - /// - /// \param other the string view being moved - constexpr basic_string_view(basic_string_view&& other) noexcept = default; - - /// \brief Constructs a basic_string_view from a std::basic_string - /// - /// \param str the string to view - template - // cppcheck-suppress noExplicitConstructor - basic_string_view(const std::basic_string& str) noexcept; - - /// \brief Constructs a basic_string_view from an ansi-string - /// - /// \param str the string to view - // cppcheck-suppress noExplicitConstructor - constexpr basic_string_view(const char_type* str) noexcept; - - /// \brief Constructs a basic_string_view from an ansi string of a given size - /// - /// \param str the string to view - /// \param count the size of the string - constexpr basic_string_view(const char_type* str, size_type count) noexcept; - - //-------------------------------------------------------------------------- - // Assignment - //-------------------------------------------------------------------------- - public: - - /// \brief Assigns a basic_string_view from an ansi-string - /// - /// \param view the string to view - /// \return reference to \c (*this) - auto operator=(const basic_string_view &view) -> basic_string_view & = default; - - //-------------------------------------------------------------------------- - // Capacity - //-------------------------------------------------------------------------- - public: - - /// \{ - /// \brief Returns the length of the string, in terms of bytes - /// - /// \return the length of the string, in terms of bytes - constexpr auto size() const noexcept -> size_type; - constexpr auto length() const noexcept -> size_type; - /// \} - - /// \brief The largest possible number of char-like objects that can be - /// referred to by a basic_string_view. - /// \return Maximum number of characters - constexpr auto max_size() const noexcept -> size_type; - - /// \brief Returns whether the basic_string_view is empty - /// (i.e. whether its length is 0). - /// - /// \return whether the basic_string_view is empty - constexpr auto empty() const noexcept -> bool; - - //-------------------------------------------------------------------------- - // Element Access - //-------------------------------------------------------------------------- - public: - - /// \brief Gets the data of the current basic_string_view - /// - /// \note This is an alias of #c_str - /// - /// \return the data this basic_string_view contains - constexpr auto data() const noexcept -> const char_type *; - - /// \brief Accesses the element at index \p pos - /// - /// \param pos the index to access - /// \return const reference to the character - constexpr auto operator[](size_type pos) const noexcept -> const_reference; - - /// \brief Accesses the element at index \p pos - /// - /// \param pos the index to access - /// \return const reference to the character - constexpr auto at(size_type pos) const -> const_reference; - - /// \brief Access the first character of the string - /// - /// \note Undefined behavior if basic_string_view is empty - /// - /// \return reference to the first character of the string - constexpr auto front() const noexcept -> const_reference; - - /// \brief References the last character of the string - /// - /// \note Undefined behavior if basic_string_view is empty - /// - /// \return reference to the last character of the string - constexpr auto back() const noexcept -> const_reference; - - //-------------------------------------------------------------------------- - // Modifiers - //-------------------------------------------------------------------------- - public: - - /// \brief Moves the start of the view forward by n characters. - /// - /// The behavior is undefined if n > size(). - /// - /// \param n number of characters to remove from the start of the view - BPSTD_CPP14_CONSTEXPR void remove_prefix(size_type n) noexcept; - - /// \brief Moves the end of the view back by n characters. - /// - /// The behavior is undefined if n > size(). - /// - /// \param n number of characters to remove from the end of the view - BPSTD_CPP14_CONSTEXPR void remove_suffix(size_type n) noexcept; - - /// \brief Exchanges the view with that of v. - /// - /// \param v view to swap with - BPSTD_CPP14_CONSTEXPR void swap(basic_string_view& v) noexcept; - - //-------------------------------------------------------------------------- - // Conversions - //-------------------------------------------------------------------------- - public: - - /// \brief Creates a basic_string with a copy of the content of the current - /// view. - /// - /// \return A basic_string containing a copy of the characters of the - /// current view. - template - explicit constexpr operator std::basic_string() const; - - //-------------------------------------------------------------------------- - // Operations - //-------------------------------------------------------------------------- - public: - - /// \brief Copies the substring [pos, pos + rcount) to the character string pointed - /// to by dest, where rcount is the smaller of count and size() - pos. - /// - /// \param dest pointer to the destination character string - /// \param count requested substring length - /// \param pos position of the first character - BPSTD_CPP14_CONSTEXPR auto copy(char_type *dest, size_type count = npos, size_type pos = 0) const -> size_type; - - /// \brief Returns a substring of this viewed string - /// - /// \param pos the position of the first character in the substring - /// \param len the length of the substring - /// \return the created substring - BPSTD_CPP14_CONSTEXPR auto substr(size_t pos = 0, size_t len = npos) const -> basic_string_view; - - //-------------------------------------------------------------------------- - - /// \brief Compares two character sequences - /// - /// \param v view to compare - /// \return negative value if this view is less than the other character - /// sequence, zero if the both character sequences are equal, positive - /// value if this view is greater than the other character sequence. - BPSTD_CPP14_CONSTEXPR auto compare(basic_string_view v) const noexcept -> int; - - /// \brief Compares two character sequences - /// - /// \param pos position of the first character in this view to compare - /// \param count number of characters of this view to compare - /// \param v view to compare - /// \return negative value if this view is less than the other character - /// sequence, zero if the both character sequences are equal, positive - /// value if this view is greater than the other character sequence. - BPSTD_CPP14_CONSTEXPR auto compare(size_type pos, size_type count, basic_string_view v) const -> int; - - /// \brief Compares two character sequences - /// - /// \param pos1 position of the first character in this view to compare - /// \param count1 number of characters of this view to compare - /// \param v view to compare - /// \param pos2 position of the second character in this view to compare - /// \param count2 number of characters of the given view to compare - /// \return negative value if this view is less than the other character - /// sequence, zero if the both character sequences are equal, positive - /// value if this view is greater than the other character sequence. - BPSTD_CPP14_CONSTEXPR auto compare(size_type pos1, size_type count1, basic_string_view v, size_type pos2, - size_type count2) const -> int; - - /// \brief Compares two character sequences - /// - /// \param s pointer to the character string to compare to - /// \return negative value if this view is less than the other character - /// sequence, zero if the both character sequences are equal, positive - /// value if this view is greater than the other character sequence. - BPSTD_CPP14_CONSTEXPR auto compare(const char_type *s) const -> int; - - /// \brief Compares two character sequences - /// - /// \param pos position of the first character in this view to compare - /// \param count number of characters of this view to compare - /// \param s pointer to the character string to compare to - /// \return negative value if this view is less than the other character - /// sequence, zero if the both character sequences are equal, positive - /// value if this view is greater than the other character sequence. - BPSTD_CPP14_CONSTEXPR auto compare(size_type pos, size_type count, const char_type *s) const -> int; - - /// \brief Compares two character sequences - /// - /// \param pos position of the first character in this view to compare - /// \param count1 number of characters of this view to compare - /// \param s pointer to the character string to compare to - /// \param count2 number of characters of the given view to compare - /// \return negative value if this view is less than the other character - /// sequence, zero if the both character sequences are equal, positive - /// value if this view is greater than the other character sequence. - BPSTD_CPP14_CONSTEXPR auto compare(size_type pos, size_type count1, const char_type *s, size_type count2) const - -> int; - - //-------------------------------------------------------------------------- - - BPSTD_CPP14_CONSTEXPR auto find(basic_string_view v, size_type pos = 0) const -> size_type; - BPSTD_CPP14_CONSTEXPR auto find(char_type c, size_type pos = 0) const -> size_type; - BPSTD_CPP14_CONSTEXPR auto find(const char_type *s, size_type pos, size_type count) const -> size_type; - BPSTD_CPP14_CONSTEXPR auto find(const char_type *s, size_type pos = 0) const -> size_type; - - //-------------------------------------------------------------------------- - - BPSTD_CPP14_CONSTEXPR auto rfind(basic_string_view v, size_type pos = npos) const -> size_type; - BPSTD_CPP14_CONSTEXPR auto rfind(char_type c, size_type pos = npos) const -> size_type; - BPSTD_CPP14_CONSTEXPR auto rfind(const char_type *s, size_type pos, size_type count) const -> size_type; - BPSTD_CPP14_CONSTEXPR auto rfind(const char_type *s, size_type pos = npos) const -> size_type; - - //-------------------------------------------------------------------------- - - BPSTD_CPP14_CONSTEXPR auto find_first_of(basic_string_view v, size_type pos = 0) const -> size_type; - BPSTD_CPP14_CONSTEXPR auto find_first_of(char_type c, size_type pos = 0) const -> size_type; - BPSTD_CPP14_CONSTEXPR auto find_first_of(const char_type *s, size_type pos, size_type count) const -> size_type; - BPSTD_CPP14_CONSTEXPR auto find_first_of(const char_type *s, size_type pos = 0) const -> size_type; - - //-------------------------------------------------------------------------- - - BPSTD_CPP14_CONSTEXPR auto find_last_of(basic_string_view v, size_type pos = npos) const -> size_type; - BPSTD_CPP14_CONSTEXPR auto find_last_of(char_type c, size_type pos = npos) const -> size_type; - BPSTD_CPP14_CONSTEXPR auto find_last_of(const char_type *s, size_type pos, size_type count) const -> size_type; - BPSTD_CPP14_CONSTEXPR auto find_last_of(const char_type *s, size_type pos = npos) const -> size_type; - - //-------------------------------------------------------------------------- - - BPSTD_CPP14_CONSTEXPR auto find_first_not_of(basic_string_view v, size_type pos = 0) const -> size_type; - BPSTD_CPP14_CONSTEXPR auto find_first_not_of(char_type c, size_type pos = 0) const -> size_type; - BPSTD_CPP14_CONSTEXPR auto find_first_not_of(const char_type *s, size_type pos, size_type count) const - -> size_type; - BPSTD_CPP14_CONSTEXPR auto find_first_not_of(const char_type *s, size_type pos = 0) const -> size_type; - - //-------------------------------------------------------------------------- - - BPSTD_CPP14_CONSTEXPR auto find_last_not_of(basic_string_view v, size_type pos = npos) const -> size_type; - BPSTD_CPP14_CONSTEXPR auto find_last_not_of(char_type c, size_type pos = npos) const -> size_type; - BPSTD_CPP14_CONSTEXPR auto find_last_not_of(const char_type *s, size_type pos, size_type count) const - -> size_type; - BPSTD_CPP14_CONSTEXPR auto find_last_not_of(const char_type *s, size_type pos = npos) const -> size_type; - - //-------------------------------------------------------------------------- - // Iterators - //-------------------------------------------------------------------------- - public: - - /// \{ - /// \brief Retrieves the begin iterator for this basic_string_view - /// - /// \return the begin iterator - BPSTD_CPP14_CONSTEXPR auto begin() const noexcept -> const_iterator; - BPSTD_CPP14_CONSTEXPR auto cbegin() const noexcept -> const_iterator; - /// \} - - /// \{ - /// \brief Retrieves the end iterator for this basic_string_view - /// - /// \return the end iterator - BPSTD_CPP14_CONSTEXPR auto end() const noexcept -> const_iterator; - BPSTD_CPP14_CONSTEXPR auto cend() const noexcept -> const_iterator; - /// \} - - /// \{ - /// \brief Retrieves the reverse begin iterator for this basic_string_view - /// - /// \return the reverse begin iterator - BPSTD_CPP14_CONSTEXPR auto rbegin() const noexcept -> const_reverse_iterator; - BPSTD_CPP14_CONSTEXPR auto rend() const noexcept -> const_reverse_iterator; - /// \} - - /// \{ - /// \brief Retrieves the reverse end iterator for this basic_string_view - /// - /// \return the reverse end iterator - BPSTD_CPP14_CONSTEXPR auto crbegin() const noexcept -> const_reverse_iterator; - BPSTD_CPP14_CONSTEXPR auto crend() const noexcept -> const_reverse_iterator; - /// \} - - //-------------------------------------------------------------------------- - // Private Member - //-------------------------------------------------------------------------- - private: - - const char_type* m_str; ///< The internal string type - size_type m_size; ///< The size of this string - - /// \brief Checks whether \p c is one of the characters in \p str - /// - /// \param c the character to check - /// \param str the characters to compare against - /// \return true if \p c is one of the characters in \p str - static BPSTD_CPP14_CONSTEXPR auto is_one_of(CharT c, basic_string_view str) -> bool; - }; - - template - constexpr typename bpstd::basic_string_view::size_type - basic_string_view::npos; - - //---------------------------------------------------------------------------- - // Public Functions - //---------------------------------------------------------------------------- - - /// \brief Overload for ostream output of basic_string_view - /// - /// \param o The output stream to print to - /// \param str the string to print - /// \return reference to the output stream - template - auto operator<<(std::basic_ostream &o, const basic_string_view &str) - -> std::basic_ostream &; - - template - void swap(basic_string_view& lhs, - basic_string_view& rhs) noexcept; - - //---------------------------------------------------------------------------- - // Comparison Functions - //---------------------------------------------------------------------------- - - template - BPSTD_CPP14_CONSTEXPR auto operator==(const basic_string_view &lhs, - const basic_string_view &rhs) noexcept -> bool; - template - BPSTD_CPP14_CONSTEXPR auto operator!=(const basic_string_view &lhs, - const basic_string_view &rhs) noexcept -> bool; - template - BPSTD_CPP14_CONSTEXPR auto operator<(const basic_string_view &lhs, - const basic_string_view &rhs) noexcept -> bool; - template - BPSTD_CPP14_CONSTEXPR auto operator>(const basic_string_view &lhs, - const basic_string_view &rhs) noexcept -> bool; - template - BPSTD_CPP14_CONSTEXPR auto operator<=(const basic_string_view &lhs, - const basic_string_view &rhs) noexcept -> bool; - template - BPSTD_CPP14_CONSTEXPR auto operator>=(const basic_string_view &lhs, - const basic_string_view &rhs) noexcept -> bool; - - //---------------------------------------------------------------------------- - // Type Aliases - //---------------------------------------------------------------------------- - - using string_view = basic_string_view; - using wstring_view = basic_string_view; - using u16string_view = basic_string_view; - using u32string_view = basic_string_view; - -} // namespace bpstd - -//============================================================================== -// definition : class : basic_string_view -//============================================================================== - -//------------------------------------------------------------------------------ -// Constructor -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::basic_string_view::basic_string_view() - noexcept - : m_str{nullptr}, - m_size{0} -{ - -} - -template -template -inline BPSTD_INLINE_VISIBILITY -bpstd::basic_string_view - ::basic_string_view(const std::basic_string& str) - noexcept - : m_str{str.c_str()}, - m_size{str.size()} -{ - -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::basic_string_view - ::basic_string_view(const char_type* str) - noexcept - : m_str{str}, - m_size{traits_type::length(str)} -{ - -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::basic_string_view - ::basic_string_view(const char_type* str, size_type count) - noexcept - : m_str{str}, - m_size{count} -{ - -} - -//------------------------------------------------------------------------------ -// Capacity -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::basic_string_view::size() const noexcept -> - typename bpstd::basic_string_view::size_type -{ - return m_size; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::basic_string_view::length() const noexcept -> - typename bpstd::basic_string_view::size_type -{ - return size(); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::basic_string_view::max_size() const noexcept -> - typename bpstd::basic_string_view::size_type -{ - return npos - 1; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::basic_string_view::empty() const noexcept -> bool -{ - return m_size == 0u; -} - -//------------------------------------------------------------------------------ -// Element Access -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::basic_string_view::data() const noexcept -> const - typename bpstd::basic_string_view::char_type * -{ - return m_str; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto -bpstd::basic_string_view::operator[](size_type pos) const noexcept -> - typename bpstd::basic_string_view::const_reference -{ - return m_str[pos]; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::basic_string_view::at(size_type pos) const -> - typename bpstd::basic_string_view::const_reference -{ - return (pos < m_size) - ? m_str[pos] - : (throw std::out_of_range{"Input out of range in basic_string_view::at"}), m_str[pos]; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::basic_string_view::front() const noexcept -> - typename bpstd::basic_string_view::const_reference -{ - return *m_str; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::basic_string_view::back() const noexcept -> - typename bpstd::basic_string_view::const_reference -{ - return m_str[m_size-1]; -} - -//------------------------------------------------------------------------------ -// Modifiers -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR -void bpstd::basic_string_view::remove_prefix(size_type n) - noexcept -{ - m_str += n, m_size -= n; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR -void bpstd::basic_string_view::remove_suffix(size_type n) - noexcept -{ - m_size -= n; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR -void bpstd::basic_string_view::swap(basic_string_view& v) - noexcept -{ - using std::swap; - swap(m_size,v.m_size); - swap(m_str,v.m_str); -} - -//------------------------------------------------------------------------------ -// Conversions -//------------------------------------------------------------------------------ - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::basic_string_view::operator - std::basic_string() - const -{ - return std::basic_string(m_str, m_size); -} - -//------------------------------------------------------------------------------ -// String Operations -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::copy(char_type *dest, size_type count, size_type pos) const -> - typename bpstd::basic_string_view::size_type -{ - if(pos >= m_size) { - throw std::out_of_range("Index out of range in basic_string_view::copy"); - } - - const auto rcount = std::min(m_size - pos,count+1); - auto* const begin = m_str + pos; - auto* const end = m_str + pos + rcount; - for (auto it = begin; it != end; ++it) { - *dest = *it; - ++dest; - } - return rcount; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::substr(size_type pos, size_type len) const - -> bpstd::basic_string_view -{ - const size_type max_length = pos > m_size ? 0 : m_size - pos; - - if (pos > size()) { - throw std::out_of_range("Index out of range in basic_string_view::substr"); - } - - return basic_string_view(m_str + pos, std::min(len, max_length) ); -} - -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::compare(basic_string_view v) const noexcept -> int -{ - const size_type rlen = std::min(m_size,v.m_size); - const int compare = Traits::compare(m_str,v.m_str,rlen); - - if (compare != 0) { - return compare; - } - if (m_size < v.m_size) { - return -1; - } - if (m_size > v.m_size) { - return 1; - } - return 0; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::compare(size_type pos, size_type count, basic_string_view v) const -> int -{ - return substr(pos,count).compare(v); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::compare(size_type pos1, size_type count1, basic_string_view v, size_type pos2, - size_type count2) const -> int -{ - return substr(pos1,count1).compare(v.substr(pos2,count2)); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::compare(const char_type *s) const -> int -{ - return compare(basic_string_view(s)); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::compare(size_type pos, size_type count, const char_type *s) const -> int -{ - return substr(pos, count).compare(basic_string_view(s)); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::compare(size_type pos, size_type count1, const char_type *s, - size_type count2) const -> int -{ - return substr(pos, count1).compare(basic_string_view(s, count2)); -} - -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::find(basic_string_view v, size_type pos) const -> - typename bpstd::basic_string_view::size_type -{ - // Can't find a substring if the substring is bigger than this - if (pos > size()) { - return npos; - } - if ((pos + v.size()) > size()) { - return npos; - } - - const auto offset = pos; - const auto increments = size() - v.size(); - - for (auto i = 0u; i <= increments; ++i) { - const auto j = i + offset; - if (substr(j, v.size()) == v) { - return j; - } - } - return npos; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::find(char_type c, size_type pos) const -> - typename bpstd::basic_string_view::size_type -{ - return find(basic_string_view(&c, 1), pos); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::find(const char_type *s, size_type pos, size_type count) const -> - typename bpstd::basic_string_view::size_type -{ - return find(basic_string_view(s, count), pos); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::find(const char_type *s, size_type pos) const -> - typename bpstd::basic_string_view::size_type -{ - return find(basic_string_view(s), pos); -} - -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::rfind(basic_string_view v, size_type pos) const -> - typename bpstd::basic_string_view::size_type -{ - if (empty()) { - return v.empty() ? 0u : npos; - } - if (v.empty()) { - return std::min(size() - 1, pos); - } - if (v.size() > size()) { - return npos; - } - - auto i = std::min(pos, (size() - v.size())); - while (i != npos) { - if (substr(i, v.size()) == v) { - return i; - } - --i; - } - - return npos; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::rfind(char_type c, size_type pos) const -> - typename bpstd::basic_string_view::size_type -{ - return rfind(basic_string_view(&c, 1), pos); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::rfind(const char_type *s, size_type pos, size_type count) const -> - typename bpstd::basic_string_view::size_type -{ - return rfind(basic_string_view(s, count), pos); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::rfind(const char_type *s, size_type pos) const -> - typename bpstd::basic_string_view::size_type -{ - return rfind(basic_string_view(s), pos); -} - -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::find_first_of(basic_string_view v, size_type pos) const -> - typename bpstd::basic_string_view::size_type -{ - const auto max_index = size(); - for (auto i = pos; i < max_index; ++i) { - if (is_one_of(m_str[i],v)) { - return i; - } - } - - return npos; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::find_first_of(char_type c, size_type pos) const -> - typename bpstd::basic_string_view::size_type -{ - return find_first_of(basic_string_view(&c, 1), pos); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::find_first_of(const char_type *s, size_type pos, size_type count) const -> - typename bpstd::basic_string_view::size_type -{ - return find_first_of(basic_string_view(s, count), pos); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::find_first_of(const char_type *s, size_type pos) const -> - typename bpstd::basic_string_view::size_type -{ - return find_first_of(basic_string_view(s), pos); -} - -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::find_last_of(basic_string_view v, size_type pos) const -> - typename bpstd::basic_string_view::size_type -{ - if (empty()) { - return npos; - } - const auto max_index = std::min(size() - 1, pos); - for (auto i = 0u; i <= max_index; ++i) { - const auto j = max_index - i; - - if (is_one_of(m_str[j],v)) { - return j; - } - } - - return npos; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::find_last_of(char_type c, size_type pos) const -> - typename bpstd::basic_string_view::size_type -{ - return find_last_of(basic_string_view(&c, 1), pos); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::find_last_of(const char_type *s, size_type pos, size_type count) const -> - typename bpstd::basic_string_view::size_type -{ - return find_last_of(basic_string_view(s, count), pos); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::find_last_of(const char_type *s, size_type pos) const -> - typename bpstd::basic_string_view::size_type -{ - return find_last_of(basic_string_view(s), pos); -} - -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::find_first_not_of(basic_string_view v, size_type pos) const -> - typename bpstd::basic_string_view::size_type -{ - const auto max_index = size(); - for (auto i = pos; i < max_index; ++i) { - if (!is_one_of(m_str[i],v)) { - return i; - } - } - - return npos; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::find_first_not_of(char_type c, size_type pos) const -> - typename bpstd::basic_string_view::size_type -{ - return find_first_not_of(basic_string_view(&c, 1), pos); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::find_first_not_of(const char_type *s, size_type pos, size_type count) const -> - typename bpstd::basic_string_view::size_type -{ - return find_first_not_of(basic_string_view(s, count), pos); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::find_first_not_of(const char_type *s, size_type pos) const -> - typename bpstd::basic_string_view::size_type -{ - return find_first_not_of(basic_string_view(s), pos); -} - -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::find_last_not_of(basic_string_view v, size_type pos) const -> - typename bpstd::basic_string_view::size_type -{ - if (empty()) { - return npos; - } - const auto max_index = std::min(size() - 1, pos); - for (auto i = 0u; i <= max_index; ++i) { - const auto j = max_index - i; - - if (!is_one_of(m_str[j],v)) { - return j; - } - } - - return npos; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::find_last_not_of(char_type c, size_type pos) const -> - typename bpstd::basic_string_view::size_type -{ - return find_last_not_of(basic_string_view(&c, 1), pos); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::find_last_not_of(const char_type *s, size_type pos, size_type count) const -> - typename bpstd::basic_string_view::size_type -{ - return find_last_not_of(basic_string_view(s, count), pos); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::find_last_not_of(const char_type *s, size_type pos) const -> - typename bpstd::basic_string_view::size_type -{ - return find_last_not_of(basic_string_view(s), pos); -} - -//------------------------------------------------------------------------------ -// Iterator -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::begin() const noexcept -> - typename bpstd::basic_string_view::const_iterator -{ - return m_str; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::cbegin() const noexcept -> - typename bpstd::basic_string_view::const_iterator -{ - return begin(); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::basic_string_view::end() const noexcept - -> typename bpstd::basic_string_view::const_iterator -{ - return m_str + m_size; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::basic_string_view::cend() const noexcept - -> typename bpstd::basic_string_view::const_iterator -{ - return cend(); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::rbegin() const noexcept -> - typename bpstd::basic_string_view::const_reverse_iterator -{ - return const_reverse_iterator{end()}; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::crbegin() const noexcept -> - typename bpstd::basic_string_view::const_reverse_iterator -{ - return rbegin(); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::basic_string_view::rend() const noexcept - -> typename bpstd::basic_string_view::const_reverse_iterator -{ - return const_reverse_iterator{begin()}; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::crend() const noexcept -> - typename bpstd::basic_string_view::const_reverse_iterator -{ - return crend(); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -bpstd::basic_string_view::is_one_of(CharT c, basic_string_view str) -> bool -{ - for (auto s : str) { - if (Traits::eq(c,s)) { - return true; - } - } - return false; -} - -//------------------------------------------------------------------------------ -// Public Functions -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::operator<<(std::basic_ostream &o, - const basic_string_view &str) - -> std::basic_ostream & -{ - o.write(str.data(),static_cast(str.size())); - return o; -} - -template -inline BPSTD_INLINE_VISIBILITY -void bpstd::swap(basic_string_view& lhs, - basic_string_view& rhs) - noexcept -{ - lhs.swap(rhs); -} - -//------------------------------------------------------------------------------ -// Comparison Functions -//------------------------------------------------------------------------------ - -namespace bpstd { - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto -operator==(const basic_string_view &lhs, const basic_string_view &rhs) noexcept -> bool -{ - return lhs.compare(rhs) == 0; - } - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto operator==(basic_string_view lhs, - const CharT *rhs) noexcept -> bool - { - return lhs == basic_string_view(rhs); - } - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto - operator==(const CharT *lhs, const basic_string_view &rhs) noexcept -> bool - { - return basic_string_view(lhs) == rhs; - } - - template - inline BPSTD_INLINE_VISIBILITY auto operator==(const std::basic_string &lhs, - const basic_string_view &rhs) -> bool - { - return basic_string_view(lhs) == rhs; - } - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto - operator==(const basic_string_view &lhs, const std::basic_string &rhs) - -> bool - { - return lhs == basic_string_view(rhs); - } - - //---------------------------------------------------------------------------- - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto - operator!=(const basic_string_view &lhs, const basic_string_view &rhs) noexcept -> bool - { - return lhs.compare(rhs) != 0; - } - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto operator!=(const basic_string_view &lhs, - const CharT *rhs) noexcept -> bool - { - return lhs != basic_string_view(rhs); - } - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto - operator!=(const CharT *lhs, const basic_string_view &rhs) noexcept -> bool - { - return basic_string_view(lhs) != rhs; - } - - template - inline BPSTD_INLINE_VISIBILITY auto operator!=(const std::basic_string &lhs, - const basic_string_view &rhs) -> bool - { - return basic_string_view(lhs) != rhs; - } - - template - inline BPSTD_INLINE_VISIBILITY auto operator!=(const basic_string_view &lhs, - const std::basic_string &rhs) -> bool - { - return lhs != basic_string_view(rhs); - } - //---------------------------------------------------------------------------- - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto - operator<(const basic_string_view &lhs, const basic_string_view &rhs) noexcept -> bool - { - return lhs.compare(rhs) < 0; - } - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto operator<(const basic_string_view &lhs, - const CharT *rhs) noexcept -> bool - { - return lhs < basic_string_view(rhs); - } - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto - operator<(const CharT *lhs, const basic_string_view &rhs) noexcept -> bool - { - return basic_string_view(lhs) < rhs; - } - - template - inline BPSTD_INLINE_VISIBILITY auto operator<(const std::basic_string &lhs, - const basic_string_view &rhs) -> bool - { - return basic_string_view(lhs) < rhs; - } - - template - inline BPSTD_INLINE_VISIBILITY auto operator<(const basic_string_view &lhs, - const std::basic_string &rhs) -> bool - { - return lhs < basic_string_view(rhs); - } - - //---------------------------------------------------------------------------- - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto - operator>(const basic_string_view &lhs, const basic_string_view &rhs) noexcept -> bool - { - return lhs.compare(rhs) > 0; - } - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto operator>(const basic_string_view &lhs, - const CharT *rhs) noexcept -> bool - { - return lhs > basic_string_view(rhs); - } - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto - operator>(const CharT *lhs, const basic_string_view &rhs) noexcept -> bool - { - return basic_string_view(lhs) > rhs; - } - - template - inline BPSTD_INLINE_VISIBILITY auto operator>(const std::basic_string &lhs, - const basic_string_view &rhs) -> bool - { - return basic_string_view(lhs) > rhs; - } - - template - inline BPSTD_INLINE_VISIBILITY auto operator>(const basic_string_view &lhs, - const std::basic_string &rhs) -> bool - { - return lhs > basic_string_view(rhs); - } - - //---------------------------------------------------------------------------- - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto - operator<=(const basic_string_view &lhs, const basic_string_view &rhs) noexcept -> bool - { - return lhs.compare(rhs) <= 0; - } - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto operator<=(const basic_string_view &lhs, - const CharT *rhs) noexcept -> bool - { - return lhs <= basic_string_view(rhs); - } - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto - operator<=(const CharT *lhs, const basic_string_view &rhs) noexcept -> bool - { - return basic_string_view(lhs) <= rhs; - } - - template - inline BPSTD_INLINE_VISIBILITY auto operator<=(const std::basic_string &lhs, - const basic_string_view &rhs) -> bool - { - return basic_string_view(lhs) <= rhs; - } - - template - inline BPSTD_INLINE_VISIBILITY auto operator<=(const basic_string_view &lhs, - const std::basic_string &rhs) -> bool - { - return lhs <= basic_string_view(rhs); - } - - //---------------------------------------------------------------------------- - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto - operator>=(const basic_string_view &lhs, const basic_string_view &rhs) noexcept -> bool - { - return lhs.compare(rhs) >= 0; - } - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto operator>=(const basic_string_view &lhs, - const CharT *rhs) noexcept -> bool - { - return lhs >= basic_string_view(rhs); - } - - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto - operator>=(const CharT *lhs, const basic_string_view &rhs) noexcept -> bool - { - return basic_string_view(lhs) >= rhs; - } - - template - inline BPSTD_INLINE_VISIBILITY auto operator>=(const std::basic_string &lhs, - const basic_string_view &rhs) -> bool - { - return basic_string_view(lhs) >= rhs; - } - - template - inline BPSTD_INLINE_VISIBILITY auto operator>=(const basic_string_view &lhs, - const std::basic_string &rhs) -> bool - { - return lhs >= basic_string_view(rhs); - } - -} // namespace bpstd - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_STRING_VIEW_HPP */ diff --git a/src/libs/vmisc/bpstd/tuple.hpp b/src/libs/vmisc/bpstd/tuple.hpp deleted file mode 100644 index f504c1ec1..000000000 --- a/src/libs/vmisc/bpstd/tuple.hpp +++ /dev/null @@ -1,276 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file tuple.hpp -/// -/// \brief This header provides definitions from the C++ header -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_TUPLE_HPP -#define BPSTD_TUPLE_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "type_traits.hpp" // invoke_result -#include "utility.hpp" // index_sequence, forward -#include "functional.hpp" // invoke - -#include // std::tuple_element, and to proxy API -#include // std::size_t - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -namespace bpstd { - - //============================================================================ - // class : tuple - //============================================================================ - - template - using tuple = std::tuple; - - //============================================================================ - // utilities : tuple - //============================================================================ - - template - using tuple_element = std::tuple_element; - - template - using tuple_element_t = typename tuple_element::type; - - //---------------------------------------------------------------------------- - - template - using tuple_size = std::tuple_size; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto tuple_size_v = tuple_size::value; -#endif - - //============================================================================ - // non-member functions : class : tuple - //============================================================================ - - //---------------------------------------------------------------------------- - // Utilities - //---------------------------------------------------------------------------- - - namespace detail { - template - struct is_tuple : false_type{}; - - template - struct is_tuple> : true_type{}; - } // namespace detail - - template >::value && is_lvalue_reference::value>> - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto get(Tuple &&t) noexcept - -> tuple_element_t> & - { - return std::get(t); - } - - template < - std::size_t N, typename Tuple, - typename = enable_if_t>::value && !is_lvalue_reference::value>> - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto get(Tuple &&t) noexcept - -> tuple_element_t> && - { - return bpstd::move(std::get(t)); - } - - template BPSTD_CPP14_CONSTEXPR auto get(tuple &t) noexcept -> T &; - template BPSTD_CPP14_CONSTEXPR auto get(tuple &&t) noexcept -> T &&; - template - BPSTD_CPP14_CONSTEXPR auto get(const tuple &t) noexcept -> const T &; - template - BPSTD_CPP14_CONSTEXPR auto get(const tuple &&t) noexcept -> const T &&; - - //---------------------------------------------------------------------------- - - namespace detail { - - // primary template left undefined - template - struct apply_result_impl; - - template - struct apply_result_impl, Tuple> - : invoke_result...>{}; - - template - struct apply_result : apply_result_impl< - Fn, - make_index_sequence>::value>, - Tuple - >{}; - - template - using apply_result_t = typename apply_result::type; - } // namespace detail - - /// \brief Invokes the function \p fn using the arguments in \p tuple - /// - /// This invokes \p fn as if it were a call to bpstd::invoke using the - /// arguments in \p tuple - /// - /// \param fn the function to invoke - /// \param tuple the tuple of arguments to pass to fn - /// \return the result from \p fn - template - constexpr auto apply(Fn &&fn, Tuple &&tuple) -> detail::apply_result_t; - - /// \brief Constructs a type \p T using the arguments in \p tuple - /// - /// \tparam T the type to construct - /// \param tuple the tuple of arguments to pass to T's constructor - template constexpr auto make_from_tuple(Tuple &&tuple) -> T; - -} // namespace bpstd - -//============================================================================== -// definitions : non-member functions : class : tuple -//============================================================================== - -//------------------------------------------------------------------------------ -// Utilities -//------------------------------------------------------------------------------ - -namespace bpstd { namespace detail { - - template - struct index_of_impl; - - template - struct index_of_impl - : index_of_impl{}; - - template - struct index_of_impl - : integral_constant{}; - - template - struct index_of : index_of_impl{}; - -}} // namespace bpstd::detail - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::get(tuple &t) noexcept -> T & -{ - return std::get::value>(t); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::get(tuple &&t) noexcept -> T && -{ - return move(std::get::value>(t)); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::get(const tuple &t) noexcept -> const T & -{ - return std::get::value>(t); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::get(const tuple &&t) noexcept -> const T && -{ - return move(std::get::value>(t)); -} - -//============================================================================== -// definition : apply -//============================================================================== - -#if defined(_MSC_VER) -# pragma warning(push) -# pragma warning(disable:4100) // MSVC warns that 'tuple' is not used below -#endif - -namespace bpstd { - namespace detail { - template - inline BPSTD_INLINE_VISIBILITY constexpr auto apply_impl(Fn &&fn, Tuple &&tuple, index_sequence) - -> apply_result_t - { - return ::bpstd::invoke(bpstd::forward(fn), std::get(bpstd::forward(tuple))...); - } - } // namespace detail -} // namespace bpstd - -#if defined(_MSC_VER) -# pragma warning(pop) -#endif - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::apply(Fn &&fn, Tuple &&tuple) - -> bpstd::detail::apply_result_t -{ - return detail::apply_impl( - bpstd::forward(fn), - bpstd::forward(tuple), - make_index_sequence>::value>{} - ); -} - -//============================================================================== -// definition : make_from_tuple -//============================================================================== - -#if defined(_MSC_VER) -# pragma warning(push) -# pragma warning(disable:4100) // MSVC warns that 'tuple' is not used below -#endif - -namespace bpstd { - namespace detail { - template - inline BPSTD_INLINE_VISIBILITY constexpr auto make_from_tuple_impl(Tuple &&tuple, index_sequence) -> T - { - return T(std::get(bpstd::forward(tuple))...); - } - } // namespace detail -} // namespace bpstd - -#if defined(_MSC_VER) -# pragma warning(pop) -#endif - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::make_from_tuple(Tuple &&tuple) -> T -{ - return detail::make_from_tuple_impl( - bpstd::forward(tuple), - make_index_sequence>::value>{} - ); -} - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_TUPLE_HPP */ diff --git a/src/libs/vmisc/bpstd/type_traits.hpp b/src/libs/vmisc/bpstd/type_traits.hpp deleted file mode 100644 index d1f599e8e..000000000 --- a/src/libs/vmisc/bpstd/type_traits.hpp +++ /dev/null @@ -1,1398 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file type_traits.hpp -/// -/// \brief This header provides definitions from the C++ header -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_TYPE_TRAITS_HPP -#define BPSTD_TYPE_TRAITS_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "detail/config.hpp" -#include "detail/move.hpp" // move, forward -#include "detail/invoke.hpp" // detail::INVOKE - -#include -#include // std::size_t - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -// GCC versions prior to gcc-5 did not implement the type traits for triviality -// in completion. Several traits are implemented under a different names from -// pre-standardization, such as 'has_trivial_copy_destructor' instead of -// 'is_trivially_destructible'. However, most of these cannot be implemented -// without compiler support. -// -// https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2014 -#if !defined(__clang__) && defined(__GNUC__) && __GNUC__ < 5 -# define BPSTD_HAS_TRIVIAL_TYPE_TRAITS 0 -#else -# define BPSTD_HAS_TRIVIAL_TYPE_TRAITS 1 -#endif - -namespace bpstd { - - //============================================================================ - // Type constants - //============================================================================ - - template - using integral_constant = std::integral_constant; - - template - using bool_constant = integral_constant; - - using std::true_type; - using std::false_type; - - template - struct type_identity { - using type = T; - }; - - namespace detail { - template - struct make_void : type_identity{}; - } // namespace detail - - template - using void_t = typename detail::make_void::type; - - //============================================================================ - // Metafunctions - //============================================================================ - - template - using enable_if = std::enable_if; - - template - using enable_if_t = typename enable_if::type; - - //---------------------------------------------------------------------------- - - template - using conditional = std::conditional; - - template - using conditional_t = typename conditional::type; - - /// \brief Type trait to determine the bool_constant from a logical - /// AND operation of other bool_constants - /// - /// The result is aliased as \c ::value - template - struct conjunction; - - template - struct conjunction : B1{}; - - template - struct conjunction - : conditional_t, B1>{}; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto disconjunction_v = conjunction::value; -#endif - - //---------------------------------------------------------------------------- - - /// \brief Type trait to determine the \c bool_constant from a logical - /// OR operations of other bool_constant - /// - /// The result is aliased as \c ::value - template - struct disjunction : false_type { }; - - template - struct disjunction : B1{}; - - template - struct disjunction - : conditional_t>{}; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto disjunction_v = disjunction::value; -#endif - - //---------------------------------------------------------------------------- - - /// \brief Utility metafunction for negating a bool_constant - /// - /// The result is aliased as \c ::value - /// - /// \tparam B the constant - template - struct negation : bool_constant(B::value)>{}; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto negation_v = negation::value; -#endif - - //---------------------------------------------------------------------------- - - template - using invoke_result = detail::invoke_result; - - template - using invoke_result_t = typename invoke_result::type; - - //---------------------------------------------------------------------------- - - namespace detail { - - template - struct is_invocable_return : std::is_convertible, R>{}; - - template - struct is_invocable_return : false_type{}; - - } // namespace detail - - template - using is_invocable = detail::is_invocable; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_invocable_v = is_invocable::value; -#endif - - //---------------------------------------------------------------------------- - - template - struct is_invocable_r - : detail::is_invocable_return::value, R, Fn, Args...>{}; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_invocable_r_v = is_invocable_r::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_nothrow_invocable = detail::is_nothrow_invocable; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_nothrow_invocable_v = is_nothrow_invocable::value; -#endif - - //---------------------------------------------------------------------------- - - template - struct is_nothrow_invocable_r - : detail::is_invocable_return::value, R, Fn, Args...>{}; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_nothrow_invocable_r_v - = is_nothrow_invocable_r::value; -#endif - - //============================================================================ - // Type categories - //============================================================================ - - template - using is_void = std::is_void; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_void_v = is_void::value; -#endif - - //---------------------------------------------------------------------------- - - template - struct is_null_pointer : false_type{}; - - template <> - struct is_null_pointer : true_type{}; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_null_pointer_v = is_null_pointer::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_array = std::is_array; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_array_v = is_array::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_pointer = std::is_pointer; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_pointer_v = is_pointer::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_enum = std::is_enum; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_enum_v = is_enum::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_union = std::is_union; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_union_v = is_union::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_class = std::is_class; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_class_v = is_class::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_function = std::is_function; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_function_v = is_function::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_object = std::is_object; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_object_v = is_object::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_scalar = std::is_scalar; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_scalar_v = is_scalar::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_compound = std::is_compound; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_compound_v = is_compound::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_integral = std::is_integral; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_integral_v = is_integral::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_floating_point = std::is_floating_point; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_floating_point_v = is_floating_point::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_fundamental = std::is_fundamental; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_fundamental_v = is_fundamental::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_arithmetic = std::is_arithmetic; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_arithmetic_v = is_arithmetic::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_reference = std::is_reference; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_reference_v = is_reference::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_lvalue_reference = std::is_lvalue_reference; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_lvalue_reference_v = is_lvalue_reference::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_rvalue_reference = std::is_rvalue_reference; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_rvalue_reference_v = is_rvalue_reference::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_member_pointer = std::is_member_pointer; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_member_pointer_v = is_member_pointer::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_member_object_pointer = std::is_member_object_pointer; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_member_object_pointer_v = is_member_object_pointer::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_member_function_pointer = std::is_member_function_pointer; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_member_function_pointer_v = is_member_function_pointer::value; -#endif - - //============================================================================ - // Type properties - //============================================================================ - - template - using is_const = std::is_const; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_const_v = is_const::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_volatile = std::is_volatile; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_volatile_v = is_volatile::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_empty = std::is_empty; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_empty_v = is_empty::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_polymorphic = std::is_polymorphic; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_polymorphic_v = is_polymorphic::value; -#endif - - //---------------------------------------------------------------------------- - -#if __cplusplus >= 201402L - // is_final is only defined in C++14 - template - struct is_final : std::is_final{}; -#else - // is_final requires compiler-support to implement. - // Without this support, the best we can do is require explicit - // specializations of 'is_final' for any types that are known to be final - template - struct is_final : false_type{}; -#endif - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_final_v = is_final::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_abstract = std::is_abstract; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_abstract_v = is_abstract::value; -#endif - - //---------------------------------------------------------------------------- - - // is_aggregate is only defined in C++17 -#if __cplusplus >= 201703L - - template - using is_aggregate = std::is_aggregate; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_aggregate_v = is_aggregate::value; -#endif -#endif - - //---------------------------------------------------------------------------- - - template - using is_trivial = std::is_trivial; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_trivial_v = is_trivial::value; -#endif - - //---------------------------------------------------------------------------- - -#if BPSTD_HAS_TRIVIAL_TYPE_TRAITS - - template - using is_trivially_copyable = std::is_trivially_copyable; - -#else - - // std::is_trivially_copyable is not implemented in gcc < 5, and unfortunately - // can't be implemented without compiler intrinsics. This definition is - // left out to avoid problems - template - using is_trivially_copyable = false_type; - -#endif - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_trivially_copyable_v = is_trivially_copyable::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_standard_layout = std::is_standard_layout; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_standard_layout_v = is_standard_layout::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_literal_type = std::is_literal_type; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_literal_type_v = is_literal_type::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_pod = std::is_pod; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_pod_v = is_pod::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_signed = std::is_signed; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_signed_v = is_signed::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_unsigned = std::is_unsigned; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_unsigned_v = is_unsigned::value; -#endif - - //---------------------------------------------------------------------------- - - template - struct is_bounded_array : false_type{}; - - template - struct is_bounded_array : true_type{}; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_bounded_array_v = is_bounded_array::value; -#endif - - //---------------------------------------------------------------------------- - - - template - struct is_unbounded_array : false_type{}; - - template - struct is_unbounded_array : true_type{}; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_unbounded_array_v = is_unbounded_array::value; -#endif - - //---------------------------------------------------------------------------- - - // has_unique_object_representation only defined in C++17 -#if __cplusplus >= 201703L - template - using has_unique_object_representations = std::has_unique_object_representations; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto has_unique_object_representations_v = has_unique_object_representations::value; -#endif -#endif - - //============================================================================ - // Type Modification - //============================================================================ - - template - using remove_cv = std::remove_cv; - - template - using remove_cv_t = typename remove_cv::type; - - //---------------------------------------------------------------------------- - - template - using remove_const = std::remove_const; - - template - using remove_const_t = typename remove_const::type; - - //---------------------------------------------------------------------------- - - template - using remove_volatile = std::remove_volatile; - - template - using remove_volatile_t = typename remove_volatile::type; - - //---------------------------------------------------------------------------- - - template - using add_cv = std::add_cv; - - template - using add_cv_t = typename add_cv::type; - - //---------------------------------------------------------------------------- - - template - using add_const = std::add_const; - - template - using add_const_t = typename add_const::type; - - //---------------------------------------------------------------------------- - - template - using add_volatile = std::add_volatile; - - template - using add_volatile_t = typename add_volatile::type; - - //---------------------------------------------------------------------------- - - template - using make_signed = std::make_signed; - - template - using make_signed_t = typename make_signed::type; - - //---------------------------------------------------------------------------- - - template - using make_unsigned = std::make_unsigned; - - template - using make_unsigned_t = typename make_unsigned::type; - - //---------------------------------------------------------------------------- - - template - using remove_reference = std::remove_reference; - - template - using remove_reference_t = typename remove_reference::type; - - //---------------------------------------------------------------------------- - - template - using add_lvalue_reference = std::add_lvalue_reference; - - template - using add_lvalue_reference_t = typename add_lvalue_reference::type; - - //---------------------------------------------------------------------------- - - template - using add_rvalue_reference = std::add_rvalue_reference; - - template - using add_rvalue_reference_t = typename add_rvalue_reference::type; - - //---------------------------------------------------------------------------- - - template - using remove_pointer = std::remove_pointer; - - template - using remove_pointer_t = typename remove_pointer::type; - - //---------------------------------------------------------------------------- - - template - using add_pointer = std::add_pointer; - - template - using add_pointer_t = typename add_pointer::type; - - //---------------------------------------------------------------------------- - - template - using remove_extent = std::remove_extent; - - template - using remove_extent_t = typename remove_extent::type; - - //---------------------------------------------------------------------------- - - template - using remove_all_extents = std::remove_all_extents; - - template - using remove_all_extents_t = typename remove_all_extents::type; - - //---------------------------------------------------------------------------- - - template - using remove_cvref = remove_cv>; - - template - using remove_cvref_t = typename remove_cvref::type; - - //============================================================================ - // Type Transformation - //============================================================================ - - template - struct aligned_storage - { - struct type { - alignas(Align) char storage[Size]; - }; - }; - - template - using aligned_storage_t = typename aligned_storage::type; - - //---------------------------------------------------------------------------- - - namespace detail { - - template - struct largest; - - template - struct largest - : largest<(Size0 > Size1 ? Size0 : Size1), Sizes...>{}; - - template - struct largest : integral_constant{}; - - } // namespace detail - - // gcc < 5 does not implement 'std::aligned_union', despite it being a type - // in the C++11 standard -- so it's implemented here to ensure that its - // available. - template - struct aligned_union - { - static constexpr std::size_t alignment_value = detail::largest::value; - - struct type - { - alignas(alignment_value) char buffer[detail::largest::value]; - }; - }; - - template - constexpr std::size_t aligned_union::alignment_value; - - template - using aligned_union_t = typename aligned_union::type; - - //---------------------------------------------------------------------------- - - template - using decay = std::decay; - - template - using decay_t = typename decay::type; - - //---------------------------------------------------------------------------- - - template - using common_type = std::common_type; - - template - using common_type_t = typename common_type::type; - - //---------------------------------------------------------------------------- - - namespace detail { - - template - struct underlying_type_impl : type_identity{}; - - template - struct underlying_type_impl{}; - - } // namespace detail - - template - struct underlying_type : detail::underlying_type_impl::value, T>{}; - - template - using underlying_type_t = typename underlying_type::type; - - //---------------------------------------------------------------------------- - - template - using result_of = std::result_of; - - template - using result_of_t = typename result_of::type; - - //============================================================================ - // Supported Operations - //============================================================================ - - template - using is_constructible = std::is_constructible; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_constructible_v = is_constructible::value; -#endif - - //---------------------------------------------------------------------------- - -#if BPSTD_HAS_TRIVIAL_TYPE_TRAITS - - template - using is_trivially_constructible = std::is_trivially_constructible; - -#else - - // std::is_trivially_constructible is not implemented in gcc < 5, and - // there exists no utilities to implement it in the language without extensions. - // This is left defined to false_type so that the trait may be used, despite - // yielding incorrect results - template - using is_trivially_constructible = false_type; - -#endif - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_trivially_constructible_v = is_trivially_constructible::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_nothrow_constructible = std::is_nothrow_constructible; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_nothrow_constructible_v = is_nothrow_constructible::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_default_constructible = std::is_default_constructible; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_default_constructible_v = is_default_constructible::value; -#endif - - //---------------------------------------------------------------------------- - -#if BPSTD_HAS_TRIVIAL_TYPE_TRAITS - - template - using is_trivially_default_constructible = std::is_trivially_default_constructible; - -#else - - // std::is_trivially_default_constructible is not implemented in gcc < 5, - // however there exists a non-standard - // 'std::has_trivial_default_constructor' which performs a similar check - template - using is_trivially_default_constructible = std::has_trivial_default_constructor; - -#endif - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_trivially_default_constructible_v = is_trivially_default_constructible::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_nothrow_default_constructible = std::is_nothrow_default_constructible; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_nothrow_default_constructible_v = is_nothrow_default_constructible::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_copy_constructible = std::is_copy_constructible; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_copy_constructible_v = is_copy_constructible::value; -#endif - - //---------------------------------------------------------------------------- - -#if BPSTD_HAS_TRIVIAL_TYPE_TRAITS - - template - using is_trivially_copy_constructible = std::is_trivially_copy_constructible; - -#else - - // std::is_trivially_copy_constructible is not implemented in gcc < 5, - // however there exists a non-standard - // 'std::has_trivial_copy_constructor' which performs a similar check - template - using is_trivially_copy_constructible = std::has_trivial_copy_constructor; - -#endif - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_trivially_copy_constructible_v = is_trivially_copy_constructible::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_nothrow_copy_constructible = std::is_nothrow_copy_constructible; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_nothrow_copy_constructible_v = is_nothrow_copy_constructible::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_move_constructible = std::is_move_constructible; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_move_constructible_v = is_move_constructible::value; -#endif - - //---------------------------------------------------------------------------- - -#if BPSTD_HAS_TRIVIAL_TYPE_TRAITS - - template - using is_trivially_move_constructible = std::is_trivially_move_constructible; - -#else - - // std::is_trivially_move_constructible is not implemented in gcc < 5, and - // there exists no utilities to implement it in the language without extensions. - // This is left defined to false_type so that the trait may be used, despite - // yielding incorrect results - template - using is_trivially_move_constructible = false_type; - -#endif - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_trivially_move_constructible_v = is_trivially_move_constructible::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_nothrow_move_constructible = std::is_nothrow_move_constructible; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_nothrow_move_constructible_v = is_nothrow_move_constructible::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_assignable = std::is_assignable; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_assignable_v = is_assignable::value; -#endif - - //---------------------------------------------------------------------------- - -#if BPSTD_HAS_TRIVIAL_TYPE_TRAITS - - template - using is_trivially_assignable = std::is_trivially_assignable; - -#else - - // std::is_trivially_assignable is not implemented in gcc < 5, and - // there exists no utilities to implement it in the language without extensions. - // This is left defined to false_type so that the trait may be used, despite - // yielding incorrect results - template - using is_trivially_assignable = false_type; - -#endif - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_trivially_assignable_v = is_trivially_assignable::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_nothrow_assignable = std::is_nothrow_assignable; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_nothrow_assignable_v = is_nothrow_assignable::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_copy_assignable = std::is_copy_assignable; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_copy_assignable_v = is_copy_assignable::value; -#endif - - //---------------------------------------------------------------------------- - -#if BPSTD_HAS_TRIVIAL_TYPE_TRAITS - - template - using is_trivially_copy_assignable = std::is_trivially_copy_assignable; - -#else - - // std::is_trivially_copy_assignable is not implemented in gcc < 5, - // however there exists a non-standard - // 'std::has_trivial_copy_assign' which performs a similar check - template - using is_trivially_copy_assignable = std::has_trivial_copy_assign; - -#endif - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_trivially_copy_assignable_v = is_trivially_copy_assignable::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_nothrow_copy_assignable = std::is_nothrow_copy_assignable; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_nothrow_copy_assignable_v = is_nothrow_copy_assignable::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_move_assignable = std::is_move_assignable; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_move_assignable_v = is_move_assignable::value; -#endif - - //---------------------------------------------------------------------------- - -#if BPSTD_HAS_TRIVIAL_TYPE_TRAITS - - template - using is_trivially_move_assignable = std::is_trivially_move_assignable; - -#else - - // std::is_trivially_move_assignable is not implemented in gcc < 5, and - // there exists no utilities to implement it in the language without extensions. - // This is left defined to false_type so that the trait may be used, despite - // yielding incorrect results - template - using is_trivially_move_assignable = false_type; - -#endif - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_trivially_move_assignable_v = is_trivially_move_assignable::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_nothrow_move_assignable = std::is_nothrow_move_assignable; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_nothrow_move_assignable_v = is_nothrow_move_assignable::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_destructible = std::is_destructible; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_destructible_v = is_destructible::value; -#endif - - //---------------------------------------------------------------------------- - -#if BPSTD_HAS_TRIVIAL_TYPE_TRAITS - - template - using is_trivially_destructible = std::is_trivially_destructible; - -#else - - // std::is_trivially_destructible is not implemented in gcc < 5, however there - // exists a non-standard '__has_trivial_destructor' which performs a - // similar check - template - using is_trivially_destructible = bool_constant<(__has_trivial_destructor(T))>; - -#endif - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_trivially_destructible_v = is_trivially_destructible::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_nothrow_destructible = std::is_nothrow_destructible; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_nothrow_destructible_v = is_nothrow_destructible::value; -#endif - - //---------------------------------------------------------------------------- - - template - using has_virtual_destructor = std::has_virtual_destructor; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto has_virtual_destructor_v = has_virtual_destructor::value; -#endif - - //============================================================================ - // Relationship - //============================================================================ - - template - using is_same = std::is_same; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_same_v = is_same::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_base_of = std::is_base_of; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_base_of_v = is_base_of::value; -#endif - - //---------------------------------------------------------------------------- - - template - using is_convertible = std::is_convertible; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_convertible_v = is_convertible::value; -#endif - - //---------------------------------------------------------------------------- - - namespace detail { - - template - struct is_nothrow_convertible_impl : false_type{}; - - template - struct is_nothrow_convertible_impl - { - static void test(To) noexcept; - - BPSTD_CPP17_INLINE static constexpr auto value = - noexcept(test(std::declval())); - }; - - } // namespace detail - - template - using is_nothrow_convertible = bool_constant< - detail::is_nothrow_convertible_impl::value,From,To>::value - >; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_nothrow_convertible_v = is_nothrow_convertible::value; -#endif - - namespace detail { - namespace adl_swap { - - void swap(); - - //------------------------------------------------------------------------ - - template - struct is_std_swappable_with : false_type{}; - - template - struct is_std_swappable_with - : conjunction< - is_move_constructible>>, - is_move_assignable>>, - is_lvalue_reference - >{}; - - template - struct is_nothrow_std_swappable_with : false_type{}; - - template - struct is_nothrow_std_swappable_with - : conjunction< - is_nothrow_move_constructible>>, - is_nothrow_move_assignable>>, - is_lvalue_reference - >{}; - - //------------------------------------------------------------------------ -#if !defined(_MSC_FULL_VER) || _MSC_FULL_VER >= 191426428 - - template - using detect_adl_swap = decltype(swap(std::declval(), std::declval())); - - template class Op, typename = void> - struct is_adl_swappable_with : false_type{}; - - template class Op> - struct is_adl_swappable_with>> - : true_type{}; - - template ::value> - struct is_nothrow_adl_swappable_with : false_type{}; - - template - struct is_nothrow_adl_swappable_with - : bool_constant(), std::declval()))>{}; -#endif - - } // namespace adl_swap - -#if defined(_MSC_FULL_VER) && _MSC_FULL_VER < 191426428 - - // MSVC 2017 15.7 or above is required for expression SFINAE. - // I'm not sure if 'is_swappable_with' is properly implementable without - // it, since we need to test calling of 'swap' unqualified. - // For now, the best we can do is test whether std::swap works, until a - // more full-featured compiler is used. - - template - struct is_swappable_with - : adl_swap::is_std_swappable_with{}; - - template - struct is_nothrow_swappable_with - : adl_swap::is_nothrow_std_swappable_with{}; - -#else - - template - struct is_swappable_with - : conditional_t::value, - adl_swap::is_adl_swappable_with, - adl_swap::is_std_swappable_with - >{}; - - template - struct is_nothrow_swappable_with - : conditional_t::value, - adl_swap::is_nothrow_adl_swappable_with, - adl_swap::is_nothrow_std_swappable_with - >{}; - -#endif - - } // namespace detail - - template - using is_swappable_with = detail::is_swappable_with&,remove_cvref_t&>; - - template - using is_swappable = is_swappable_with; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_swappable_with_v = is_swappable_with::value; - - template - BPSTD_CPP17_INLINE constexpr auto is_swappable_v = is_swappable::value; -#endif - - template - using is_nothrow_swappable_with = detail::is_nothrow_swappable_with&,remove_cvref_t&>; - - template - using is_nothrow_swappable = is_nothrow_swappable_with; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto is_nothrow_swappable_with_v = is_nothrow_swappable_with::value; - - template - BPSTD_CPP17_INLINE constexpr auto is_nothrow_swappable_v = is_nothrow_swappable_with::value; -#endif - -} // namespace bpstd - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_TYPE_TRAITS_HPP */ diff --git a/src/libs/vmisc/bpstd/utility.hpp b/src/libs/vmisc/bpstd/utility.hpp deleted file mode 100644 index 22e7b665c..000000000 --- a/src/libs/vmisc/bpstd/utility.hpp +++ /dev/null @@ -1,336 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file utility.hpp -/// -/// \brief This header provides definitions from the C++ header -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_UTILITY_HPP -#define BPSTD_UTILITY_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "detail/config.hpp" -#include "detail/move.hpp" // IWYU pragma: export -#include "type_traits.hpp" // add_const_t - -#include // to proxy the API -#include // std::size_t - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -namespace bpstd { - - //============================================================================ - // struct : in_place_t - //============================================================================ - - /// \brief This function is a special disambiguation tag for variadic - /// functions, used in any and optional - /// - /// \note Calling this function results in undefined behaviour. - struct in_place_t - { - explicit in_place_t() = default; - }; - BPSTD_CPP17_INLINE constexpr in_place_t in_place{}; - - //============================================================================ - // in_place_type_t - //============================================================================ - - /// \brief This function is a special disambiguation tag for variadic - /// functions, used in any and optional - /// - /// \note Calling this function results in undefined behaviour. - template - struct in_place_type_t - { - explicit in_place_type_t() = default; - }; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr in_place_type_t in_place_type{}; -#endif - - //============================================================================ - // in_place_index_t - //============================================================================ - - /// \brief This function is a special disambiguation tag for variadic - /// functions, used in any and optional - /// - /// \note Calling this function results in undefined behaviour. - template struct in_place_index_t - { - explicit in_place_index_t() = default; - }; - -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr in_place_index_t in_place_index{}; -#endif - - //============================================================================ - // non-member functions - //============================================================================ - - //---------------------------------------------------------------------------- - // Utilities - //---------------------------------------------------------------------------- - - /// \brief Moves a type \p x if it move-construction is non-throwing - /// - /// \param x the parameter to move - /// \return an rvalue reference if nothrow moveable, const reference otherwise - template - constexpr auto move_if_noexcept(T &x) noexcept -> typename bpstd::conditional< - !bpstd::is_nothrow_move_constructible::value && bpstd::is_copy_constructible::value, const T &, T &&>::type; - - /// \brief Forms an lvalue reference to const type of t - /// - /// \param t the type to form an lvalue reference to - /// \return the reference to const T - template constexpr auto as_const(T &t) noexcept -> add_const_t &; - template - void as_const(const T&&) = delete; - - /// \brief Replaces the value of obj with new_value and returns the old value - /// of obj. - /// - /// \pre \p T must meet the requirements of MoveConstructible. - /// - /// \pre It must be possible to move-assign objects of type \p U to objects of - /// type \p T - /// - /// \param obj object whose value to replace - /// \param new_value the value to assign to obj - template BPSTD_CPP14_CONSTEXPR auto exchange(T &obj, U &&new_value) -> T; - - //============================================================================ - // class : pair - //============================================================================ - - template - using pair = std::pair; - - //============================================================================ - // non-member functions : class : pair - //============================================================================ - - //---------------------------------------------------------------------------- - // Utilities - //---------------------------------------------------------------------------- - - // C++11 does not implement const pair&& - template - constexpr auto get(pair &p) noexcept -> conditional_t &; - template - constexpr auto get(pair &&p) noexcept -> conditional_t &&; - template - constexpr auto get(const pair &p) noexcept -> const conditional_t &; - template - constexpr auto get(const pair &&p) noexcept -> const conditional_t &&; - - template constexpr auto get(pair &p) noexcept -> T &; - template constexpr auto get(pair &&p) noexcept -> T &&; - template constexpr auto get(const pair &p) noexcept -> const T &; - template constexpr auto get(const pair &&p) noexcept -> const T &&; - - template constexpr auto get(pair &p) noexcept -> T &; - template constexpr auto get(const pair &p) noexcept -> const T &; - template constexpr auto get(pair &&p) noexcept -> T &&; - template constexpr auto get(const pair &&p) noexcept -> const T &&; - - //============================================================================ - // struct : integer_sequence - //============================================================================ - - template - struct integer_sequence - { - using value_type = T; - - static constexpr auto size() noexcept -> std::size_t { return sizeof...(Ints); } - }; - - template - using index_sequence = integer_sequence; - - namespace detail { - template - struct make_integer_sequence_impl - : make_integer_sequence_impl{}; - - template - struct make_integer_sequence_impl - : type_identity>{}; - - } // namespace detail - - template - using make_integer_sequence - = typename detail::make_integer_sequence_impl::type; - - template - using make_index_sequence = make_integer_sequence; - - template - using index_sequence_for = make_index_sequence; - -} // namespace bpstd - -//============================================================================== -// non-member functions -//============================================================================== - -//------------------------------------------------------------------------------ -// Utilities -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::move_if_noexcept(T &x) noexcept -> typename bpstd::conditional< - !bpstd::is_nothrow_move_constructible::value && bpstd::is_copy_constructible::value, const T &, T &&>::type -{ - using result_type = conditional_t< - !is_nothrow_move_constructible::value && is_copy_constructible::value, - const T&, - T&& - >; - - return static_cast(x); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::as_const(T &t) noexcept -> bpstd::add_const_t & -{ - return t; -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::exchange(T &obj, U &&new_value) -> T -{ - auto old_value = bpstd::move(obj); - obj = bpstd::forward(new_value); - return old_value; -} - -//============================================================================== -// definitions : non-member functions : class : pair -//============================================================================== - -//------------------------------------------------------------------------------ -// Utilities -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::get(pair &p) noexcept -> bpstd::conditional_t & -{ - static_assert(N<=1, "N must be either 0 or 1 for get(pair)"); - - return std::get(p); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::get(pair &&p) noexcept - -> bpstd::conditional_t && -{ - static_assert(N<=1, "N must be either 0 or 1 for get(pair)"); - - return move(std::get(p)); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::get(const pair &p) noexcept - -> const bpstd::conditional_t & -{ - static_assert(N<=1, "N must be either 0 or 1 for get(pair)"); - - return std::get(p); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::get(const pair &&p) noexcept - -> const bpstd::conditional_t && -{ - static_assert(N<=1, "N must be either 0 or 1 for get(pair)"); - - return move(std::get(p)); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::get(pair &p) noexcept -> T & -{ - return p.first; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::get(const pair &p) noexcept -> const T & -{ - return p.first; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::get(pair &&p) noexcept -> T && -{ - return move(p.first); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::get(const pair &&p) noexcept -> const T && -{ - return move(p.first); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::get(pair &p) noexcept -> T & -{ - return p.second; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::get(const pair &p) noexcept -> const T & -{ - return p.second; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::get(pair &&p) noexcept -> T && -{ - return move(p.second); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::get(const pair &&p) noexcept -> const T && -{ - return move(p.second); -} - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_UTILITY_HPP */ diff --git a/src/libs/vmisc/bpstd/variant.hpp b/src/libs/vmisc/bpstd/variant.hpp deleted file mode 100644 index f4eaba534..000000000 --- a/src/libs/vmisc/bpstd/variant.hpp +++ /dev/null @@ -1,1859 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// \file variant.hpp -/// -/// \brief This header provides definitions from the C++ header -//////////////////////////////////////////////////////////////////////////////// - -/* - The MIT License (MIT) - - Copyright (c) 2020 Matthew Rodusek All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef BPSTD_VARIANT_HPP -#define BPSTD_VARIANT_HPP - -#if defined(_MSC_VER) && (_MSC_VER >= 1200) -# pragma once -#endif // defined(_MSC_VER) && (_MSC_VER >= 1200) - -#include "detail/config.hpp" -#include "detail/enable_overload.hpp" // enable_overload_if -#include "detail/nth_type.hpp" -#include "detail/variant_base.hpp" -#include "detail/variant_visitors.hpp" -#include "detail/variant_traits.hpp" -#include "tuple.hpp" -#include "utility.hpp" // in_place_index_t, in_place_type_t -#include "type_traits.hpp" // conjunction -#include "functional.hpp" // less, greater, equal_to, etc - -#include // std::initializer_list -#include // std::uses_allocator -#include // std::exception -#include // std::size_t -#include // std::forward, std::move - -BPSTD_COMPILER_DIAGNOSTIC_PREAMBLE - -namespace bpstd { - - //============================================================================ - // class : monostate - //============================================================================ - - struct monostate{}; - - constexpr auto operator==(monostate, monostate) noexcept -> bool; - constexpr auto operator!=(monostate, monostate) noexcept -> bool; - constexpr auto operator<(monostate, monostate) noexcept -> bool; - constexpr auto operator>(monostate, monostate) noexcept -> bool; - constexpr auto operator<=(monostate, monostate) noexcept -> bool; - constexpr auto operator>=(monostate, monostate) noexcept -> bool; - - //============================================================================ - // forward declaration : variant - //============================================================================ - - template - class variant; - - //========================================================================= - // trait : variant_size - //========================================================================= - - /// \{ - /// \brief Provides access to the number of alternatives in a possibly - /// cv-qualified variant as a compile-time constant expression. - /// - /// The result is accessible as ::value - template - struct variant_size; // not defined - - template - struct variant_size - : variant_size{}; - - template - struct variant_size - : variant_size{}; - - template - struct variant_size - : variant_size{}; - - template - struct variant_size> - : integral_constant{}; - /// \} - - /// \brief Helper variable template for extracting variant_size::value -#if BPSTD_HAS_TEMPLATE_VARIABLES - template - BPSTD_CPP17_INLINE constexpr auto variant_size_v = variant_size::value; -#endif - - //============================================================================ - // trait : variant_alternative - //============================================================================ - - /// \{ - /// \brief A metafunction for extracting the type at index \p I from the - /// (possibly CV-qualified) variant - /// - /// \note This template is not defined for non-variant types - /// - /// \note The result is only defined for I < sizeof...(Types) in variant - /// - /// \tparam I the index - /// \tparam T the type - template - struct variant_alternative; // not defined - - template - struct variant_alternative - : add_const::type>{}; - - template - struct variant_alternative - : add_volatile::type>{}; - - template - struct variant_alternative - : add_cv::type>{}; - - template - struct variant_alternative> - : detail::nth_type{}; - /// \} - - //---------------------------------------------------------------------------- - - /// \brief A helper template for extracting the ::type from - /// variant_alternative - /// - /// \tparam I the index - /// \tparam T the variant - template - using variant_alternative_t = typename variant_alternative::type; - - //============================================================================ - // globals : variant - //============================================================================ - - /// \brief This is a special value equal to the largest value - /// representable by the type std::size_t, used as the return type - /// of index() when valueless_by_exception() is true - BPSTD_CPP17_INLINE constexpr auto variant_npos = static_cast(-1); - - //============================================================================ - // class : bad_variant_access - //============================================================================ - - ////////////////////////////////////////////////////////////////////////// - /// \brief Exception thrown by variant - /// - /// bad_variant_access is the type of the exception thrown in the - /// following situations: - /// - get(std::variant) called with an index or type that does not match - /// the currently active alternative - /// - visit called to visit a variant that is valueless_by_exception - ////////////////////////////////////////////////////////////////////////// - class bad_variant_access : public std::exception - { - //-------------------------------------------------------------------------- - // Constructor - //-------------------------------------------------------------------------- - public: - - /// \brief Constructs a new instance of bad_variant_access. - bad_variant_access() noexcept = default; - - //-------------------------------------------------------------------------- - // Observers - //-------------------------------------------------------------------------- - public: - - /// \brief returns an explanatory string of the exception - /// - /// \return string explaining the issue - auto what() const noexcept -> const char * override; - }; - - namespace detail { - - //========================================================================== - // trait : index_from - //========================================================================== - - template - struct index_from_impl; - - template - struct index_from_impl - : integral_constant{}; - - template - struct index_from_impl - : index_from_impl{}; - - template - struct index_from_impl - : integral_constant{}; - - /// \brief Type-trait to get the index of T in a list of Ts - template - struct index_from : index_from_impl<0,T,Ts...>{}; - - //========================================================================== - // trait : is_not_in_place - //========================================================================== - - /// \brief Type-trait for determining if 'T' is *not* an in_place type - template - struct is_not_in_place : true_type{}; - - template - struct is_not_in_place> : false_type{}; - - template - struct is_not_in_place> : false_type{}; - - template <> - struct is_not_in_place : false_type{}; - - //========================================================================== - // trait : index_of_constructible_alternative - //========================================================================== - - template - struct variant_f_impl; - - template - struct variant_f_impl - : variant_f_impl - { - using variant_f_impl::operator(); - - auto operator()(T0) -> integral_constant; - }; - - // skip 'bool' overloads from consideration - template - struct variant_f_impl - : variant_f_impl - { - using variant_f_impl::operator(); - }; - - template - struct variant_f_impl - : variant_f_impl - { - using variant_f_impl::operator(); - }; - - template - struct variant_f_impl - : variant_f_impl - { - using variant_f_impl::operator(); - }; - - template - struct variant_f_impl - : variant_f_impl - { - using variant_f_impl::operator(); - }; - - template - struct variant_f_impl - { - // End recursion with a variant_npos - auto operator()(...) -> integral_constant; - }; - - template - struct variant_f : variant_f_impl<0,Types...> {}; - - //-------------------------------------------------------------------------- - - /// \brief Type-trait to retrieve the index of the constructible alternative - /// as if presented by an overload set containing all T types. - /// - /// The index result is 'variant_npos' if no overload is valid - /// - /// If 'T' is a possibly CV-qualified bool, this will only yield an index - /// if 'Types...' contains a possible CV-qualified bool as well, to prevent - /// unintentional conversions from string literals and pointers. - template - struct index_of_constructible_alternative - : conditional_t< - is_same,bool>::value, - index_from...>, - decltype(std::declval>()(std::declval())) - >{}; - - template - struct constructible_alternative - : nth_type::value, Types...>{}; - - template - using constructible_alternative_t - = typename constructible_alternative::type; - - //========================================================================== - // trait : has_constructible_alternative - //========================================================================== - - /// \brief Type-trait to check whether an alternative may be constructed - /// when presented with all types as an overload set - template - struct has_constructible_alternative - : bool_constant<(index_of_constructible_alternative::value != variant_npos)>{}; - - template - struct can_construct_alternative_impl : false_type{}; - - template - struct can_construct_alternative_impl - : is_constructible,T>{}; - - template - using can_construct_alternative - = can_construct_alternative_impl::value,T,Types...>; - - template - struct can_assign_alternative_impl : false_type{}; - - template - struct can_assign_alternative_impl - : is_assignable,T>{}; - - template - using can_assign_alternative - = can_assign_alternative_impl::value,T,Types...>; - - } // namespace detail - - //============================================================================ - // class : variant - //============================================================================ - - ////////////////////////////////////////////////////////////////////////////// - /// \brief The class template variant represents a type-safe union. - /// - /// An instance of variant at any given time either holds a value of - /// one of its alternative types, or it holds no value (this state is hard - /// to achieve, \see valueless_by_exception ). - /// - /// As with unions, if a variant holds a value of some object type T, the - /// object representation of T is allocated directly within the object - /// representation of the variant itself. Variant is not allowed to allocate - /// additional (dynamic) memory. - /// - /// A variant is not permitted to hold references, arrays, or the type void. - /// Empty variants are also ill-formed (variant can be - /// used instead). - /// - /// A variant is permitted to hold the same type more than once, and to hold - /// differently cv-qualified versions of the same type. - /// - /// As with unions, the default-initialized variant holds a value of its - /// first alternative, unless that alternative is not default-constructible - /// (in which case default constructor won't compile: the helper class - /// monostate can be used to make such variants default-constructible) - /// - /// \tparam Types the types that may be stored in this variant. All types - /// must be (possibly cv-qualified) non-array object types - ////////////////////////////////////////////////////////////////////////////// - template - class variant - : detail::variant_base< - conjunction...>::value, - Types... - > - { - //-------------------------------------------------------------------------- - // Validation - //-------------------------------------------------------------------------- - - static_assert( - sizeof...(Types) > 0, - "A variant of 0 types is ill-formed. Use variant instead." - ); - static_assert( - conjunction>...>::value, - "A variant containing a reference type is ill-formed. Use reference_wrapper" - ); - static_assert( - conjunction>...>::value, - "A variant containing void is ill-formed." - ); - - //-------------------------------------------------------------------------- - // Public Member Types - //-------------------------------------------------------------------------- - - using base_type = detail::variant_base< - conjunction...>::value, - Types... - >; - using first_type = typename detail::nth_type_t<0,Types...>; - - static constexpr bool is_default_constructible - = bpstd::is_default_constructible::value; - - static constexpr bool is_move_constructible = conjunction< - bpstd::is_move_constructible... - >::value; - - static constexpr bool is_copy_constructible = conjunction< - bpstd::is_copy_constructible... - >::value; - - static constexpr bool is_copy_assignable = conjunction< - bpstd::is_copy_constructible..., - bpstd::is_copy_assignable... - >::value; - - static constexpr bool is_move_assignable = conjunction< - bpstd::is_move_constructible..., - bpstd::is_move_assignable... - >::value; - - static constexpr bool is_nothrow_default_constructible = conjunction< - bpstd::is_nothrow_default_constructible... - >::value; - - static constexpr bool is_nothrow_move_constructible = conjunction< - bpstd::is_nothrow_move_constructible... - >::value; - - static constexpr bool is_nothrow_copy_constructible = conjunction< - bpstd::is_nothrow_copy_constructible... - >::value; - - template - using i_is_in_range = bool_constant<(I < sizeof...(Types))>; - - template - using enable_if_convertible = - enable_if_t< - conjunction< - negation, variant>>, - detail::is_not_in_place>, - detail::has_constructible_alternative, - detail::can_construct_alternative - >::value - >; - - template - using enable_if_convert_assignable = - enable_if_t< - conjunction< - negation, variant>>, - detail::is_not_in_place>, - detail::has_constructible_alternative, - detail::can_construct_alternative, - detail::can_assign_alternative - >::value - >; - - template - using T_j = detail::constructible_alternative_t; - - struct variant_ctor{}; - - //-------------------------------------------------------------------------- - // Constructors - //-------------------------------------------------------------------------- - public: - - // (1) - - /// \brief Default constructor. - /// - /// Constructs a variant holding the value-initialized value of the first - /// alternative (index() is zero). - /// - /// \note This constructor is constexpr if and only if the value - /// initialization of the alternative type T_0 would satisfy the - /// requirements for a constexpr function. - /// - /// \note This overload only participates in overload resolution if - /// std::is_default_constructible_v is true. - constexpr variant(detail::enable_overload_if_t = {}) - noexcept(std::is_nothrow_default_constructible::value); - - // (2) - - /// \brief Copy constructor. - /// - /// If other is not valueless_by_exception, constructs a variant holding - /// the same alternative as other and direct-initializes the contained - /// value with std::get(other). - /// Otherwise, initializes a valueless_by_exception variant. - /// - /// \note This overload only participates in overload resolution if - /// std::is_copy_constructible_v is true for all T_i in Types.... - /// - /// \param other the other variant to copy - variant(detail::enable_overload_if_t other) - noexcept(bpstd::conjunction...>::value); - variant(detail::disable_overload_if_t other) = delete; - - // (3) - - /// \brief Move constructor. - /// - /// If other is not valueless_by_exception, constructs a variant holding - /// the same alternative as other and direct-initializes the contained - /// value with std::get(std::move(other)). - /// Otherwise, initializes a valueless_by_exception variant. - /// - /// \note This overload only participates in overload resolution if - /// std::is_move_constructible_v is true for all T_i in Types... - /// - /// \param other the other variant to move - variant(detail::enable_overload_if_t other) - noexcept(bpstd::conjunction...>::value); - variant(detail::disable_overload_if_t other) = delete; - - // (4) - - /// \brief Converting constructor. - /// - /// Constructs a variant holding the alternative type T_j that would be - /// selected by overload resolution for the expression - /// F(std::forward(t)) if there was an overload of imaginary function - /// F(T_i) for every T_i from Types... in scope at the same time. - /// - /// Direct-initializes the contained value as if by direct - /// non-list-initialization from std::forward(t). - /// - /// \note This overload only participates in overload resolution if - /// - sizeof...(Types) > 0 - /// - std::is_same_v, variant> is false - /// - decay_t is neither a specialization of in_place_type_t - /// nor a specialization of in_place_index_t - /// - std::is_constructible_v is true - /// - and the expression F(std::forward(t)) (with F being the - /// above-mentioned set of imaginary functions) is well formed. - /// - /// \note This constructor is a constexpr constructor if T_j's selected - /// constructor is a constexpr constructor. - /// - /// \param t the value to direct-initialize - template > - constexpr variant(T&& t) - noexcept(bpstd::is_nothrow_constructible::template T_j,T>::value); - - // (5) - - /// \brief Constructs a variant with the specified alternative T and - /// initializes the contained value with the arguments - /// std::forward(args).... - /// - /// \note If T's selected constructor is a constexpr constructor, this - /// constructor is also a constexpr constructor. - /// - /// \note This overload only participates in overload resolution if - /// there is exactly one occurrence of T in Types... and - /// std::is_constructible_v is true - /// - /// \param args the arguments to forward to \p T's constructor - template ::value>> - constexpr explicit variant(in_place_type_t, Args&&... args); - - /// \brief Constructs a variant with the specified alternative T and - /// initializes the contained value with the arguments il, - /// std::forward(args)..... - /// - /// \note If T's selected constructor is a constexpr constructor, this - /// constructor is also a constexpr constructor. - /// - /// \note This overload only participates in overload resolution if - /// there is exactly one occurrence of T in Types... and - /// std::is_constructible_v&, Args...> is true. - /// - /// \param il initializer list of type \p U - /// \param args the arguments to forward to \p T's constructor - template ,Args...>::value>> - constexpr explicit variant(in_place_type_t, - std::initializer_list il, Args&&... args); - - // (7) - - /// \brief Constructs a variant with the alternative T_i specified by - /// the index I and initializes the contained value with the - /// arguments std::forward(args).... - /// - /// \note If T_i's selected constructor is a constexpr constructor, this - /// constructor is also a constexpr constructor. - /// - /// \note This overload only participates in overload resolution if - /// I < sizeof...(Types) and std::is_constructible_v - /// is true - /// - /// \param args the arguments to forward to \p T_i's constructor - template ::value && std::is_constructible,Args...>::value>> - constexpr explicit variant(in_place_index_t, Args&&... args); - - // (8) - - /// \brief Constructs a variant with the alternative T_i specified by - /// the index I and initializes the contained value with the - /// arguments il, std::forward(args).... - /// - /// \note If T_i's selected constructor is a constexpr constructor, this - /// constructor is also a constexpr constructor. - /// - /// \note This overload only participates in overload resolution if - /// I < sizeof...(Types) and - /// std::is_constructible_v&, Args...> - /// is true. - /// - /// \param il initializer list of type \p U - /// \param args the arguments to forward to \p T_i 's constructor - template ::value && std::is_constructible,std::initializer_list,Args...>::value>> - constexpr explicit variant(in_place_index_t, - std::initializer_list il, Args&&... args); - - //-------------------------------------------------------------------------- - - /// \brief Copy assigns the contents of \p other to this - /// - /// If the active variant alternative is the same as \p other , then this - /// will perform an assignment. Otherwise, this destructs the currently - /// active alternative and performs a copy construction. - /// - /// \param other the other variant to copy - auto operator=(detail::enable_overload_if_t other) -> variant &; - auto operator=(detail::disable_overload_if_t other) -> variant & = delete; - - /// \brief Move assigns the contents of \p other to this - /// - /// If the active variant alternative is the same as \p other , then this - /// will perform an assignment. Otherwise, this destructs the currently - /// active alternative and performs a move construction. - /// - /// \param other the other variant to move - auto operator=(detail::enable_overload_if_t other) noexcept( - conjunction..., std::is_nothrow_move_assignable...>::value) - -> variant &; - auto operator=(detail::disable_overload_if_t other) -> variant & = delete; - - template > - auto operator=(T &&t) noexcept( - std::is_nothrow_assignable::template T_j, T>::value - &&std::is_nothrow_constructible::template T_j, T>::value) -> variant &; - - //-------------------------------------------------------------------------- - // Observers - //-------------------------------------------------------------------------- - public: - - /// \brief Returns the zero-based index of the alternative that is - /// currently held by the variant. - /// - /// If the variant is valueless_by_exception, returns variant_npos. - /// - /// \return the zero-based index - constexpr auto index() const noexcept -> std::size_t; - - /// \brief Returns false if and only if the variant holds a value - /// - /// \return false if and only if the variant holds a value - constexpr auto valueless_by_exception() const noexcept -> bool; - - //-------------------------------------------------------------------------- - // Modifiers - //-------------------------------------------------------------------------- - public: - - /// \brief Creates a new value in-place - /// - /// Equivalent to emplace(std::forward(args)...), where I is the - /// zero-based index of T in Types.... - /// - /// \note This overload only participates in overload resolution if - /// std::is_constructible_v is true, and T - /// occurs exactly once in Types... - /// - /// \tparam T the type to construct - /// \param args the arguments to forward to the constructor of \p T - /// \return reference to constructed element - template ::value>> - auto emplace(Args &&...args) -> T &; - - /// \brief Creates a new value in-place - /// - /// Equivalent to emplace(il, std::forward(args)...), where I is - /// the zero-based index of T in Types.... - /// - /// \note This overload only participates in overload resolution if - /// std::is_constructible_v, Args...> - /// is true, and \p T occurs exactly once in Types... - /// - /// \tparam T the type to construct - /// \param il an initializer list of entries - /// \param args the arguments to forward to the constructor of \p T - /// \return reference to constructed element - template &, Args...>::value>> - auto emplace(std::initializer_list il, Args &&...args) -> T &; - - /// \brief Creates a new value in-place - /// - /// First, destroys the currently contained value (if any). - /// Then direct-initializes the contained value as if constructing a - /// value of type T_I with the arguments std::forward(args)... - /// - /// If an exception is thrown, *this may become - /// valueless_by_exception. - /// - /// \note This overload only participates in overload resolution if - /// std::is_constructible_v is true. - /// - /// The behavior is undefined if I is not less than sizeof...(Types). - /// - /// \tparam I the index of the variant alternative to construct - /// \param args the arguments to forward to the constructor of \p T - /// \return reference to constructed element - template , Args...>::value>> - auto emplace(Args &&...args) -> variant_alternative_t &; - - /// \brief Creates a new value in-place - /// - /// First, destroys the currently contained value (if any). - /// Then direct-initializes the contained value as if constructing a - /// value of type T_I with the arguments - /// il,std::forward(args)... - /// - /// If an exception is thrown, *this may become - /// valueless_by_exception. - /// - /// \note This overload only participates in overload resolution if - /// std::is_constructible_v Args...> - /// is true. - /// - /// The behavior is undefined if I is not less than sizeof...(Types). - /// - /// \tparam I the index of the variant alternative to construct - /// \param args the arguments to forward to the constructor of \p T - /// \return reference to constructed element - template , std::initializer_list &, Args...>::value>> - auto emplace(std::initializer_list il, Args &&...args) -> variant_alternative_t &; - - /// \brief Swaps the contents of this and \p rhs - /// - /// \param rhs the entry to swap with - void swap(variant &rhs) noexcept(bpstd::conjunction..., - bpstd::is_nothrow_swappable...>::value); - - //-------------------------------------------------------------------------- - // Private Members - //-------------------------------------------------------------------------- - private: - static auto alternative_is_nothrow_copy_constructible(std::size_t i) noexcept -> bool; - static auto alternative_is_nothrow_move_constructible(std::size_t i) noexcept -> bool; - - //-------------------------------------------------------------------------- - // Friend Declarations - //-------------------------------------------------------------------------- - private: - - // 'variant' requires a whole lot of friends, due to most of its API - // consisting of free-functions that access the underlying data. - - template - friend BPSTD_CPP14_CONSTEXPR auto operator==(const variant &, const variant &) noexcept - -> bool; - - template - friend BPSTD_CPP14_CONSTEXPR auto operator!=(const variant &, const variant &) noexcept - -> bool; - - template - friend BPSTD_CPP14_CONSTEXPR auto operator<(const variant &, const variant &) noexcept - -> bool; - - template - friend BPSTD_CPP14_CONSTEXPR auto operator>(const variant &, const variant &) noexcept - -> bool; - - template - friend BPSTD_CPP14_CONSTEXPR auto operator<=(const variant &, const variant &) noexcept - -> bool; - - template - friend BPSTD_CPP14_CONSTEXPR auto operator>=(const variant &, const variant &) noexcept - -> bool; - - template - BPSTD_CPP14_CONSTEXPR friend auto visit(Visitor &&, Variant &&) - -> detail::variant_visitor_invoke_result_t; - - template - friend BPSTD_CPP14_CONSTEXPR auto get(variant &) -> variant_alternative_t> &; - - template - friend BPSTD_CPP14_CONSTEXPR auto get(variant &&) -> variant_alternative_t> &&; - - template - friend BPSTD_CPP14_CONSTEXPR auto get(const variant &) - -> const variant_alternative_t> &; - - template - friend BPSTD_CPP14_CONSTEXPR auto get(const variant &&) - -> const variant_alternative_t> &&; - - template - friend constexpr auto get_if(variant *) noexcept - -> add_pointer_t>>; - - template - friend constexpr auto get_if(const variant *) noexcept - -> add_pointer_t>>; - }; - - //============================================================================ - // non-member functions : class : variant - //============================================================================ - - //---------------------------------------------------------------------------- - // Comparison - //---------------------------------------------------------------------------- - - template - BPSTD_CPP14_CONSTEXPR auto operator==(const variant &lhs, const variant &rhs) noexcept -> bool; - template - BPSTD_CPP14_CONSTEXPR auto operator!=(const variant &lhs, const variant &rhs) noexcept -> bool; - template - BPSTD_CPP14_CONSTEXPR auto operator<(const variant &lhs, const variant &rhs) noexcept -> bool; - template - BPSTD_CPP14_CONSTEXPR auto operator>(const variant &lhs, const variant &rhs) noexcept -> bool; - template - BPSTD_CPP14_CONSTEXPR auto operator<=(const variant &lhs, const variant &rhs) noexcept -> bool; - template - BPSTD_CPP14_CONSTEXPR auto operator>=(const variant &lhs, const variant &rhs) noexcept -> bool; - - //---------------------------------------------------------------------------- - // Utilities - //---------------------------------------------------------------------------- - - /// \brief Swaps the contents of \p lhs with \p rhs - /// - /// \param lhs the left contents to swap - /// \param rhs the right contents to swap - template - void swap(variant& lhs, variant& rhs) - noexcept(noexcept(lhs.swap(rhs))); - - //---------------------------------------------------------------------------- - // Value Access - //---------------------------------------------------------------------------- - - /// \brief Visits the variant \p v with the given \p visitor - /// - /// \param visitor the visitor to visit the active entry of \p v - /// \param v the variant to visit - /// \return the result of visiting the variant \p v - template - BPSTD_CPP14_CONSTEXPR auto visit(Visitor &&visitor, Variant &&v) - -> bpstd::detail::variant_visitor_invoke_result_t; - - // /// \brief Visits the variants \p variant0 and \p variants - // /// - // /// \param visitor the visitor to visit the active entry of \p v0 - // /// \param variant0 the first variant to visit - // /// \param variants the rest of the variant to visit - // /// \return the result of visiting the variants - template - BPSTD_CPP14_CONSTEXPR auto visit(Visitor &&visitor, Variant0 &&variant0, Variants &&...variants) - -> bpstd::detail::variant_visitor_invoke_result_t; - - //---------------------------------------------------------------------------- - - /// \brief Checks if the variant v holds the alternative T. - /// - /// The call is ill-formed if T appears more than once in Types... - /// - /// \param v variant to examine - /// \return true if the variant currently holds the alternative T - template - constexpr auto holds_alternative(const variant &v) noexcept -> bool; - - //---------------------------------------------------------------------------- - - /// \{ - /// \brief Gets the alternative at index \p I from the variant \p v - /// - /// \tparam I the alternative index - /// \param v the variant - /// \return the alternative at index \p I - template - BPSTD_CPP14_CONSTEXPR auto get(variant &v) -> variant_alternative_t> &; - template - BPSTD_CPP14_CONSTEXPR auto get(variant &&v) -> variant_alternative_t> &&; - template - BPSTD_CPP14_CONSTEXPR auto get(const variant &v) -> const variant_alternative_t> &; - template - BPSTD_CPP14_CONSTEXPR auto get(const variant &&v) -> const variant_alternative_t> &&; - /// \} - - //---------------------------------------------------------------------------- - - /// \{ - /// \brief Gets the underlying element of the variant with the specified type - /// - /// \throw bad_variant_access if T is not the active alternative - /// - /// \tparam T the type of the alternative to retrieve - /// \param v the variant to extract the entry from - /// \return the alternative - template BPSTD_CPP14_CONSTEXPR auto get(variant &v) -> T &; - template BPSTD_CPP14_CONSTEXPR auto get(variant &&v) -> T &&; - template BPSTD_CPP14_CONSTEXPR auto get(const variant &v) -> const T &; - template BPSTD_CPP14_CONSTEXPR auto get(const variant &&v) -> const T &&; - /// \} - - //---------------------------------------------------------------------------- - - /// \{ - /// \brief Index-based non-throwing accessor - /// - /// If \p pv is not a null pointer and pv->index() == I, returns a - /// pointer to the value stored in the variant pointed to by pv. - /// Otherwise, returns a null pointer value. - /// - /// The call is ill-formed if I is not a valid index in the variant - /// - /// \tparam I the index of the alternative to extract - /// \param pv the pointer to the variant to extract the value from - /// \return pointer to the variant alternative when successful - template - constexpr auto get_if(variant *pv) noexcept -> add_pointer_t>>; - template - constexpr auto get_if(const variant *pv) noexcept - -> add_pointer_t>>; - /// \} - - /// \{ - /// \brief Type-based non-throwing accessor - /// - /// Equivalent to the index-based get_if with I being the zero-based - /// index of \p T in Types.... - /// - /// The call is ill-formed if T is not a unique element of Types. - /// - /// \tparam T the alternative type to retrieve - /// \param pv the pointer to the variant to extract the value from - /// \return pointer to the variant alternative when successful - template constexpr auto get_if(variant *pv) noexcept -> add_pointer_t; - template - constexpr auto get_if(const variant *pv) noexcept -> add_pointer_t; - /// \} - -} // namespace bpstd - -//============================================================================== -// struct : monostate -//============================================================================== - -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator==(monostate, monostate) noexcept -> bool -{ - return true; -} - -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator!=(monostate, monostate) noexcept -> bool -{ - return false; -} - -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator<(monostate, monostate) noexcept -> bool -{ - return false; -} - -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator>(monostate, monostate) noexcept -> bool -{ - return false; -} - -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator<=(monostate, monostate) noexcept -> bool -{ - return true; -} - -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::operator>=(monostate, monostate) noexcept -> bool -{ - return true; -} - -//============================================================================== -// class : bad_variant_access -//============================================================================== - -inline auto bpstd::bad_variant_access::what() const noexcept -> const char * -{ - return "bad_variant_access"; -} - -//============================================================================== -// class : variant -//============================================================================== - -//------------------------------------------------------------------------------ -// Constructors / Assignment -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::variant::variant(detail::enable_overload_if_t) - noexcept(std::is_nothrow_default_constructible::value) - : base_type{detail::variant_index_tag<0>{}} -{ - -} - -template -inline BPSTD_INLINE_VISIBILITY -bpstd::variant::variant(detail::enable_overload_if_t other) - noexcept(bpstd::conjunction...>::value) - : base_type{} -{ - if (other.valueless_by_exception()) { - return; - } - detail::visit_union( - other.base_type::m_index, - detail::variant_copy_construct_visitor{}, - base_type::m_union, - other.base_type::m_union - ); - base_type::m_index = other.base_type::m_index; -} - -template -inline BPSTD_INLINE_VISIBILITY -bpstd::variant::variant(detail::enable_overload_if_t other) - noexcept(bpstd::conjunction...>::value) - : base_type{} -{ - if (other.valueless_by_exception()) { - return; - } - detail::visit_union( - other.base_type::m_index, - detail::variant_move_construct_visitor{}, - base_type::m_union, - bpstd::move(other.base_type::m_union) - ); - base_type::m_index = other.base_type::m_index; -} - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::variant::variant(T&& t) - noexcept(bpstd::is_nothrow_constructible::template T_j,T>::value) - : base_type{ - detail::variant_index_tag::value>{}, - bpstd::forward(t) - } -{ - -} - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::variant::variant(in_place_type_t, Args&&... args) - : base_type{ - detail::variant_index_tag::value>{}, - bpstd::forward(args)... - } -{ - -} - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::variant::variant(in_place_type_t, std::initializer_list il, Args&&... args) - : base_type{ - detail::variant_index_tag::value>{}, - il, bpstd::forward(args)... - } -{ - -} - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::variant::variant(in_place_index_t, Args&&... args) - : base_type{ - detail::variant_index_tag{}, - bpstd::forward(args)... - } -{ - -} - -template -template -inline BPSTD_INLINE_VISIBILITY constexpr -bpstd::variant::variant(in_place_index_t, std::initializer_list il, Args&&... args) - : base_type{ - detail::variant_index_tag{}, - il, bpstd::forward(args)... - } -{ - -} - -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY auto -bpstd::variant::operator=(detail::enable_overload_if_t other) - -> bpstd::variant & -{ - if (other.valueless_by_exception()) { - base_type::destroy_active_object(); - return (*this); - } - - if (other.base_type::m_index == base_type::m_index) { - detail::visit_union( - other.base_type::m_index, - detail::variant_copy_assign_visitor{}, - base_type::m_union, - other.base_type::m_union - ); - return (*this); - } - - const auto should_copy = - alternative_is_nothrow_copy_constructible(other.index()) || - !alternative_is_nothrow_move_constructible(other.index()); - - if (should_copy) { - base_type::destroy_active_object(); - detail::visit_union( - other.base_type::m_index, - detail::variant_copy_construct_visitor{}, - base_type::m_union, - other.base_type::m_union - ); - base_type::m_index = other.base_type::m_index; - return (*this); - } - - return this->operator=(variant(other)); -} - -template -inline BPSTD_INLINE_VISIBILITY auto -bpstd::variant::operator=(detail::enable_overload_if_t other) noexcept( - conjunction..., std::is_nothrow_move_assignable...>::value) - -> bpstd::variant & -{ - if (other.valueless_by_exception()) { - base_type::destroy_active_object(); - return (*this); - } - - if (other.base_type::m_index == base_type::m_index) { - detail::visit_union( - other.base_type::m_index, - detail::variant_move_assign_visitor{}, - base_type::m_union, - bpstd::move(other.base_type::m_union) - ); - return (*this); - } - - base_type::destroy_active_object(); - detail::visit_union( - other.base_type::m_index, - detail::variant_move_construct_visitor{}, - base_type::m_union, - bpstd::move(other.base_type::m_union) - ); - base_type::m_index = other.base_type::m_index; - - return (*this); -} - -template -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::variant::operator=(T &&t) noexcept( - std::is_nothrow_assignable::template T_j, T>::value - &&std::is_nothrow_constructible::template T_j, T>::value) - -> bpstd::variant & -{ - static constexpr auto index = detail::index_of_constructible_alternative::value; - - using type = detail::constructible_alternative_t; - - if (base_type::m_index == index) { - detail::visit_union( - base_type::m_index, - detail::variant_assign_visitor{bpstd::forward(t)}, - base_type::m_union - ); - return (*this); - } - - const auto should_emplace = - alternative_is_nothrow_copy_constructible(index) || - !alternative_is_nothrow_move_constructible(index); - - if (should_emplace) { - emplace(bpstd::forward(t)); - return (*this); - } - - return this->operator=(variant(bpstd::forward(t))); -} - -//------------------------------------------------------------------------------ -// Observers -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::variant::index() const noexcept -> std::size_t -{ - return base_type::m_index; -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::variant::valueless_by_exception() const noexcept -> bool -{ - return index() == variant_npos; -} - -//------------------------------------------------------------------------------ -// Modifiers -//------------------------------------------------------------------------------ - -template -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::variant::emplace(Args &&...args) -> T & -{ - using index_type = detail::index_from; - - static_assert(index_type::value != variant_npos, "T must be a valid alternative"); - - return emplace(bpstd::forward(args)...); -} - -template -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::variant::emplace(std::initializer_list il, Args &&...args) - -> T & -{ - using index_type = detail::index_from; - - static_assert(index_type::value != variant_npos, "T must be a valid alternative"); - - return emplace(il, bpstd::forward(args)...); -} - -template -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::variant::emplace(Args &&...args) - -> bpstd::variant_alternative_t> & -{ - using type = detail::nth_type_t; - - base_type::destroy_active_object(); - - using tuple_type = decltype(std::forward_as_tuple(bpstd::forward(args)...)); - - auto visitor = detail::variant_emplace_visitor( - std::forward_as_tuple(bpstd::forward(args)...) - ); - - detail::visit_union(I, visitor, base_type::m_union); - base_type::m_index = I; - - return detail::union_get(base_type::m_union); -} - -template -template -inline BPSTD_INLINE_VISIBILITY auto bpstd::variant::emplace(std::initializer_list il, Args &&...args) - -> bpstd::variant_alternative_t> & -{ - using type = detail::nth_type_t; - - base_type::destroy_active_object(); - - using tuple_type = decltype(std::forward_as_tuple(il, bpstd::forward(args)...)); - - auto visitor = detail::variant_emplace_visitor( - std::forward_as_tuple(il, bpstd::forward(args)...) - ); - - detail::visit_union(I, visitor, base_type::m_union); - base_type::m_index = I; - - return detail::union_get(base_type::m_union); -} - -template -inline BPSTD_INLINE_VISIBILITY -void bpstd::variant::swap(variant& other) - noexcept(bpstd::conjunction..., - bpstd::is_nothrow_swappable...>::value) - -{ - if (valueless_by_exception() && other.valueless_by_exception()) { - return; - } - - if (base_type::m_index == other.base_type::m_index) { - detail::visit_union( - base_type::m_index, - detail::variant_swap_visitor{}, - base_type::m_union, - other.m_union - ); - } else { - auto temp = bpstd::move(*this); - *this = bpstd::move(other); - other = bpstd::move(temp); - } -} - -template -inline BPSTD_INLINE_VISIBILITY auto -bpstd::variant::alternative_is_nothrow_copy_constructible(std::size_t i) noexcept -> bool -{ - const bool alternatives[]{bpstd::is_nothrow_copy_constructible::value...}; - - return alternatives[i]; -} - -template -inline BPSTD_INLINE_VISIBILITY auto -bpstd::variant::alternative_is_nothrow_move_constructible(std::size_t i) noexcept -> bool -{ - const bool alternatives[]{bpstd::is_nothrow_move_constructible::value...}; - - return alternatives[i]; -} - -//============================================================================== -// non-member functions : class : variant -//============================================================================== - -//------------------------------------------------------------------------------ -// Comparisons -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::operator==(const variant &lhs, - const variant &rhs) noexcept - -> bool -{ - if (lhs.index() != rhs.index()) { - return false; - } - if (lhs.valueless_by_exception()) { - return true; - } - return detail::visit_union(lhs.index(), equal_to<>{}, lhs.m_union, rhs.m_union); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::operator!=(const variant &lhs, - const variant &rhs) noexcept - -> bool -{ - if (lhs.index() != rhs.index()) { - return true; - } - if (lhs.valueless_by_exception()) { - return false; - } - return detail::visit_union(lhs.index(), not_equal_to<>{}, lhs.m_union, rhs.m_union); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::operator<(const variant &lhs, - const variant &rhs) noexcept - -> bool -{ - if (rhs.valueless_by_exception()) { - return false; - } - if (lhs.valueless_by_exception()) { - return true; - } - if (lhs.index() < rhs.index()) { - return true; - } - if (lhs.index() > rhs.index()) { - return false; - } - return detail::visit_union(lhs.index(), less<>{}, lhs.m_union, rhs.m_union); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::operator>(const variant &lhs, - const variant &rhs) noexcept - -> bool -{ - if (lhs.valueless_by_exception()) { - return false; - } - if (rhs.valueless_by_exception()) { - return true; - } - if (lhs.index() > rhs.index()) { - return true; - } - if (lhs.index() < rhs.index()) { - return false; - } - return detail::visit_union(lhs.index(), greater<>{}, lhs.m_union, rhs.m_union); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::operator<=(const variant &lhs, - const variant &rhs) noexcept - -> bool -{ - if (lhs.valueless_by_exception()) { - return true; - } - if (rhs.valueless_by_exception()) { - return false; - } - if (lhs.index() < rhs.index()) { - return true; - } - if (lhs.index() > rhs.index()) { - return false; - } - return detail::visit_union(lhs.index(), less_equal<>{}, lhs.m_union, rhs.m_union); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::operator>=(const variant &lhs, - const variant &rhs) noexcept - -> bool -{ - if (rhs.valueless_by_exception()) { - return true; - } - if (lhs.valueless_by_exception()) { - return false; - } - if (lhs.index() > rhs.index()) { - return true; - } - if (lhs.index() < rhs.index()) { - return false; - } - return detail::visit_union(lhs.index(), greater_equal<>{}, lhs.m_union, rhs.m_union); -} - -//------------------------------------------------------------------------------ -// Utilities -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY -void bpstd::swap(variant& lhs, variant& rhs) - noexcept(noexcept(lhs.swap(rhs))) -{ - lhs.swap(rhs); -} - -//------------------------------------------------------------------------------ -// Value Access -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::visit(Visitor &&visitor, Variant &&v) - -> bpstd::detail::variant_visitor_invoke_result_t -{ - using union_type = detail::match_cvref_t; - - if (v.valueless_by_exception()) { - throw bad_variant_access{}; - } - - return detail::visit_union( - v.index(), - bpstd::forward(visitor), - static_cast(v.m_union) - ); -} - -namespace bpstd { namespace detail { - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto are_any_valueless_by_exception(const Variant0 &v0, const Variants &...vs) - -> bool -{ - return v0.valueless_by_exception() || are_any_valueless_by_exception(vs...); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto are_any_valueless_by_exception(const Variant0 &v0) -> bool -{ - return v0.valueless_by_exception(); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto tuple_push_back_aux(std::tuple &args, T &&v, - index_sequence) - -> std::tuple -{ - (void) args; - return std::forward_as_tuple(std::get(bpstd::move(args))..., bpstd::forward(v)); -} - -// Appends an element to a forwarding tuple -// Returns with '&&' to reference-collapse returned types -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto tuple_push_back(std::tuple &args, T &&t) - -> std::tuple -{ - static_assert( - conjunction...,true_type>::value, - "'args' must be a forwarding tuple'" - ); - // return std::tuple_cat(args, std::forward_as_tuple(std::forward(t))); - return tuple_push_back_aux(args, bpstd::forward(t), index_sequence_for{}); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto tuple_pop_front_aux(std::tuple &args, - index_sequence<0, Idxs...>) - -> std::tuple -{ - (void) args; - return std::forward_as_tuple(std::get(bpstd::move(args))...); -} - -// Removes the front element of a forwarding tuple -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto tuple_pop_front(std::tuple &args) - -> std::tuple -{ - static_assert( - conjunction,is_reference...>::value, - "'args' must be a forwarding tuple'" - ); - - return tuple_pop_front_aux(args, index_sequence_for{}); -} - -template -class multi_variant_visitor; - -template -BPSTD_CPP14_CONSTEXPR auto make_multi_visitor(Visitor &&vistior, Variants &&variants, Arguments &&args) - -> multi_variant_visitor, remove_cvref_t>; - -template -class multi_variant_visitor, std::tuple> -{ - static_assert( - conjunction, is_reference...>::value, - "All Variants must be captured by reference" - ); - static_assert( - conjunction...,true_type>::value, - "All arguments must be captured by reference" - ); - -public: - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR - multi_variant_visitor(UVisitor&& visitor, UVariants&& variants, Arguments&& args) - : m_visitor(bpstd::forward(visitor)), - m_variants(bpstd::forward(variants)), - m_args(bpstd::forward(args)) - { - - } - - template inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto operator()(T &&v) -> Return - { - // static_assert(is_reference::value, "T should always be a reference type"); - - return visit( - detail::make_multi_visitor( - bpstd::forward(m_visitor), - tuple_pop_front(m_variants), - tuple_push_back(m_args, bpstd::forward(v)) - ), - std::get<0>(bpstd::move(m_variants)) // 'move' used for reference collapse - ); - } - -private: - - Visitor m_visitor; - std::tuple m_variants; - std::tuple m_args; -}; - -template -class multi_variant_visitor,std::tuple> -{ - static_assert( - conjunction...,true_type>::value, - "All arguments must be captured by reference" - ); - -public: - template - inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR - multi_variant_visitor(UVisitor&& visitor, Variants&&, Arguments&& args) - : m_visitor(bpstd::forward(visitor)), - m_args(bpstd::forward(args)) - { - - } - - template inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto operator()(T &&v) -> Return - { - return apply( - bpstd::forward(m_visitor), - tuple_push_back(m_args, bpstd::forward(v)) - ); - } - -private: - - Visitor m_visitor; - std::tuple m_args; -}; - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto make_multi_visitor(Visitor &&visitor, Variants &&variants, - Arguments &&args) - -> multi_variant_visitor, remove_cvref_t> -{ - return { - bpstd::forward(visitor), - bpstd::forward(variants), - bpstd::forward(args) - }; -} - -}} // namespace bpstd::detail - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::visit(Visitor &&visitor, Variant0 &&variant0, - Variants &&...variants) - -> bpstd::detail::variant_visitor_invoke_result_t -{ - using type = bpstd::detail::variant_visitor_invoke_result_t; - - if (detail::are_any_valueless_by_exception(variant0, variants...)) { - throw bad_variant_access{}; - } - - return visit( - detail::make_multi_visitor( - bpstd::forward(visitor), - std::forward_as_tuple(bpstd::forward(variants)...), - std::make_tuple() - ), - bpstd::forward(variant0) - ); - -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::holds_alternative(const variant &v) noexcept -> bool -{ - return detail::index_from::value == v.index(); -} - -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::get(variant &v) - -> bpstd::variant_alternative_t> & -{ - static_assert( - I < sizeof...(Types), - "I is not a valid index into the variant" - ); - - if (v.index() != I) { - throw bad_variant_access{}; - } - return detail::union_get(v.m_union); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::get(variant &&v) - -> bpstd::variant_alternative_t> && -{ - static_assert( - I < sizeof...(Types), - "I is not a valid index into the variant" - ); - - if (v.index() != I) { - throw bad_variant_access{}; - } - return bpstd::move(detail::union_get(v.m_union)); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::get(const variant &v) - -> const bpstd::variant_alternative_t> & -{ - static_assert( - I < sizeof...(Types), - "I is not a valid index into the variant" - ); - - if (v.index() != I) { - throw bad_variant_access{}; - } - return detail::union_get(v.m_union); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::get(const variant &&v) - -> const bpstd::variant_alternative_t> && -{ - static_assert( - I < sizeof...(Types), - "I is not a valid index into the variant" - ); - - if (v.index() != I) { - throw bad_variant_access{}; - } - return bpstd::move(detail::union_get(v.m_union)); -} - -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::get(variant &v) -> T & -{ - using index_type = detail::index_from; - - return get(v); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::get(variant &&v) -> T && -{ - using index_type = detail::index_from; - - return get(bpstd::move(v)); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::get(const variant &v) -> const T & -{ - using index_type = detail::index_from; - - return get(v); -} - -template -inline BPSTD_INLINE_VISIBILITY BPSTD_CPP14_CONSTEXPR auto bpstd::get(const variant &&v) -> const T && -{ - using index_type = detail::index_from; - - return get(bpstd::move(v)); -} - -//------------------------------------------------------------------------------ -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::get_if(variant *pv) noexcept - -> bpstd::add_pointer_t>> -{ - static_assert( - I < sizeof...(Types), - "I is not a valid index into the variant" - ); - - return (pv == nullptr || I != pv->index()) - ? nullptr - : &detail::union_get(pv->m_union); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::get_if(const variant *pv) noexcept - -> bpstd::add_pointer_t>> -{ - static_assert( - I < sizeof...(Types), - "I is not a valid index into the variant" - ); - - return (pv == nullptr || I != pv->index()) - ? nullptr - : &detail::union_get(pv->m_union); -} - -//------------------------------------------------------------------------------ - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::get_if(variant *pv) noexcept -> bpstd::add_pointer_t -{ - using index_type = detail::index_from; - - return get_if(pv); -} - -template -inline BPSTD_INLINE_VISIBILITY constexpr auto bpstd::get_if(const variant *pv) noexcept - -> bpstd::add_pointer_t -{ - using index_type = detail::index_from; - - return get_if(pv); -} - -BPSTD_COMPILER_DIAGNOSTIC_POSTAMBLE - -#endif /* BPSTD_VARIANT_HPP */ diff --git a/src/libs/vmisc/compatibility.h b/src/libs/vmisc/compatibility.h index 07c2aff69..4e3ce163b 100644 --- a/src/libs/vmisc/compatibility.h +++ b/src/libs/vmisc/compatibility.h @@ -55,52 +55,6 @@ class QPointF; -#if QT_VERSION < QT_VERSION_CHECK(5, 8, 0) -//--------------------------------------------------------------------------------------------------------------------- -inline bool operator==(QChar lhs, const QString &rhs) Q_DECL_NOEXCEPT -{ - return rhs.size() == 1 && lhs == rhs[0]; -} - -//--------------------------------------------------------------------------------------------------------------------- -inline bool operator!=(QChar lhs, const QString &rhs) Q_DECL_NOEXCEPT -{ - return !(lhs == rhs); -} - -//--------------------------------------------------------------------------------------------------------------------- -inline bool operator==(const QString &lhs, QChar rhs) Q_DECL_NOEXCEPT -{ - return rhs == lhs; -} -#endif - -#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) -//--------------------------------------------------------------------------------------------------------------------- -Q_DECL_CONSTEXPR inline bool operator==(QChar c1, char16_t c2) Q_DECL_NOEXCEPT -{ - return c1 == QChar(static_cast(c2)); -} - -//--------------------------------------------------------------------------------------------------------------------- -Q_DECL_CONSTEXPR inline bool operator!=(QChar c1, char16_t c2) Q_DECL_NOEXCEPT -{ - return !(c1 == QChar(static_cast(c2))); -} - -//--------------------------------------------------------------------------------------------------------------------- -Q_DECL_CONSTEXPR inline bool operator==(char16_t c1, QChar c2) Q_DECL_NOEXCEPT -{ - return c2 == c1; -} - -//--------------------------------------------------------------------------------------------------------------------- -Q_DECL_CONSTEXPR inline bool operator!=(char16_t c1, QChar c2) Q_DECL_NOEXCEPT -{ - return c2 != c1; -} -#endif - #if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) namespace Qt { @@ -144,25 +98,10 @@ inline auto operator""_s(const char16_t *str, size_t size)Q_DECL_NOEXCEPT->QStri #endif // Contains helpful methods to hide version dependent code. It can be deprecation of method or change in API -//--------------------------------------------------------------------------------------------------------------------- -template -inline auto Intersects(const T &l1, const T &l2, QPointF *intersectionPoint) -> typename T::IntersectType -{ -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - return l1.intersects(l2, intersectionPoint); -#else - return l1.intersect(l2, intersectionPoint); -#endif -} - //--------------------------------------------------------------------------------------------------------------------- template class C> inline auto ConvertToList(const C &container) -> QList { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) return QList(container.begin(), container.end()); -#else - return container.toList(); -#endif } //--------------------------------------------------------------------------------------------------------------------- @@ -174,55 +113,27 @@ template class C> inline auto ConvertToStringLi //--------------------------------------------------------------------------------------------------------------------- template class C> inline auto ConvertToSet(const C &container) -> QSet { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) return QSet(container.begin(), container.end()); -#else - return container.toSet(); -#endif } //--------------------------------------------------------------------------------------------------------------------- template inline auto ConvertToSet(const C &container) -> QSet { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) return QSet(container.begin(), container.end()); -#else - return container.toSet(); -#endif } //--------------------------------------------------------------------------------------------------------------------- template class C> inline auto ConvertToVector(const C &container) -> QVector { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) return QVector(container.begin(), container.end()); -#else - return container.toVector(); -#endif } //--------------------------------------------------------------------------------------------------------------------- template inline auto ConvertToVector(const QSet &container) -> QVector { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) return QVector(container.begin(), container.end()); -#else - return container.toList().toVector(); -#endif } -//--------------------------------------------------------------------------------------------------------------------- -// NOTE: Delete if not necessary anymore -// template -// inline void SwapItemsAt(T &container, int i, int j) -//{ -// #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) -// container.swapItemsAt(i, j); -// #else -// container.swap(i, j); -// #endif -//} - //--------------------------------------------------------------------------------------------------------------------- template inline auto Reverse(const QVector &container) -> QVector { @@ -254,58 +165,6 @@ inline auto Reverse(const T &container) -> T return Reverse(container); } -//--------------------------------------------------------------------------------------------------------------------- -inline auto TextWidth(const QFontMetrics &fm, const QString &text, int len = -1) -> int -{ -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) - return fm.horizontalAdvance(text, len); -#else - return fm.width(text, len); -#endif -} - -//--------------------------------------------------------------------------------------------------------------------- -inline auto TextWidthF(const QFontMetricsF &fm, const QString &text) -> qreal -{ -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) - return fm.horizontalAdvance(text); -#else - return fm.width(text); -#endif -} - -//--------------------------------------------------------------------------------------------------------------------- -template inline auto Insert(QMap &map1, const QMap &map2) -> void -{ -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) - map1.insert(map2); -#else - auto i = map2.constBegin(); - while (i != map2.constEnd()) - { - map1.insert(i.key(), i.value()); - ++i; - } -#endif -} - -//--------------------------------------------------------------------------------------------------------------------- -inline auto VLocaleCharacter(const QString &character) -> QChar -{ - Q_ASSERT(character.size() == 1); -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) - return character.front(); -#else - return character.at(0); -#endif -} - -//--------------------------------------------------------------------------------------------------------------------- -inline auto VLocaleCharacter(const QChar &character) -> QChar -{ - return character; -} - //--------------------------------------------------------------------------------------------------------------------- template inline auto DropEventPos(const T *event) -> QPoint { @@ -326,16 +185,6 @@ template inline auto QLibraryPath(T loc) -> QString #endif } -//--------------------------------------------------------------------------------------------------------------------- -inline auto LineCenter(const QLineF &line) -> QPointF -{ -#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) - return line.center(); -#else - return {0.5 * line.p1().x() + 0.5 * line.p2().x(), 0.5 * line.p1().y() + 0.5 * line.p2().y()}; -#endif -} - //--------------------------------------------------------------------------------------------------------------------- template inline auto First(const T &list, N n) -> T { @@ -394,26 +243,6 @@ template inline auto Sliced(const T &list, N pos, N n) #endif } -//--------------------------------------------------------------------------------------------------------------------- -inline auto Back(const QString &str) -> QChar -{ -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) - return str.back(); -#else - return str.at(str.size() - 1); -#endif -} - -//--------------------------------------------------------------------------------------------------------------------- -inline auto Front(const QString &str) -> QChar -{ -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) - return str.front(); -#else - return str.at(0); -#endif -} - //--------------------------------------------------------------------------------------------------------------------- inline auto FontFromString(const QString &descrip) -> QFont { @@ -493,21 +322,4 @@ inline void RemoveLast(QString &str) #endif } -//--------------------------------------------------------------------------------------------------------------------- -inline void SetWindowFlag(QWidget *widget, Qt::WindowType flag, bool on = true) -{ -#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) - widget->setWindowFlag(flag, on); -#else - if (on) - { - widget->setWindowFlags(widget->windowFlags() | flag); - } - else - { - widget->setWindowFlags(widget->windowFlags() & ~flag); - } -#endif -} - #endif // COMPATIBILITY_H diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index 70f2c5706..04bfa7912 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -54,13 +54,10 @@ #include #include -#include "vabstractapplication.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) -#include "vdatastreamenum.h" -#endif #include "../ifc/exception/vexception.h" #include "compatibility.h" #include "literals.h" +#include "vabstractapplication.h" using namespace Qt::Literals::StringLiterals; diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index e91a341b6..7ab44706e 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -51,27 +51,10 @@ template class QSharedPointer; #include // and, not, or #endif -#if (defined(Q_CC_GNU) && Q_CC_GNU <= 409) && !defined(Q_CC_CLANG) -// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define COPY_CONSTRUCTOR_IMPL(className) \ - className::className(const className &item) \ - : d(item.d) \ - { \ - } - -// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define COPY_CONSTRUCTOR_IMPL_2(className, baseClassName) \ - className::className(const className &item) \ - : baseClassName(item), \ - d(item.d) \ - { \ - } -#else // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define COPY_CONSTRUCTOR_IMPL(className) className::className(const className &) = default; // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define COPY_CONSTRUCTOR_IMPL_2(className, baseClassName) className::className(const className &) = default; -#endif // https://stackoverflow.com/questions/75008386/constructor-is-implicitly-deleted-because-its-exception-specification-does-not-m #if (defined(Q_CC_GNU) && Q_CC_GNU < 1001) && !defined(Q_CC_CLANG) @@ -454,34 +437,6 @@ enum class IMD : qint8 // Individual measurement dimension #define __has_cpp_attribute(x) 0 #endif -#if QT_VERSION < QT_VERSION_CHECK(5, 8, 0) - -#ifndef QT_HAS_CPP_ATTRIBUTE -#ifdef __has_cpp_attribute -#define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) -#else -#define QT_HAS_CPP_ATTRIBUTE(x) 0 -#endif -#endif // QT_HAS_CPP_ATTRIBUTE - -#if defined(__cplusplus) -#if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough) -#define Q_FALLTHROUGH() [[clang::fallthrough]] -#elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough) -#define Q_FALLTHROUGH() [[gnu::fallthrough]] -#elif QT_HAS_CPP_ATTRIBUTE(fallthrough) -#define Q_FALLTHROUGH() [[fallthrough]] -#endif -#endif -#ifndef Q_FALLTHROUGH -#if (defined(Q_CC_GNU) && Q_CC_GNU >= 700) && !defined(Q_CC_INTEL) -#define Q_FALLTHROUGH() __attribute__((fallthrough)) -#else -#define Q_FALLTHROUGH() (void)0 -#endif -#endif // defined(__cplusplus) -#endif // QT_VERSION < QT_VERSION_CHECK(5, 8, 0) - #ifdef Q_OS_MAC // Fix QT issue on MacOS version 11.0 "Big Sur" // https://bugreports.qt.io/browse/QTBUG-87014 @@ -500,8 +455,7 @@ enum class IMD : qint8 // Individual measurement dimension // We'll assume that it will be fixed in 5.12.11, 5.15.3, and 6.0.1. // Feel free to add other versions if needed. #define MACOS_LAYER_BACKING_AFFECTED \ - (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) && QT_VERSION < QT_VERSION_CHECK(5, 12, 11) || \ - (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) && QT_VERSION < QT_VERSION_CHECK(5, 15, 3)) || \ + ((QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) && QT_VERSION < QT_VERSION_CHECK(5, 15, 3)) || \ (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 1))) #if MACOS_LAYER_BACKING_AFFECTED diff --git a/src/libs/vmisc/defglobal.h b/src/libs/vmisc/defglobal.h index 3a7ee1585..216f9e0a4 100644 --- a/src/libs/vmisc/defglobal.h +++ b/src/libs/vmisc/defglobal.h @@ -32,16 +32,6 @@ constexpr qreal PrintDPI = 96.0; -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -// this adds const to non-const objects (like std::as_const) -template Q_DECL_CONSTEXPR typename std::add_const::type &qAsConst(T &t) noexcept -{ - return t; -} -// prevent rvalue arguments: -template void qAsConst(const T &&) Q_DECL_EQ_DELETE; -#endif - #if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0) // Since Qt 6.0 minimal requirement is C++17. There is no longer need for qAsConst. #define qAsConst std::as_const @@ -51,13 +41,6 @@ template void qAsConst(const T &&) Q_DECL_EQ_DELETE; #define Q_DISABLE_ASSIGN(Class) Class &operator=(const Class &) = delete; #endif -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#define Q_DISABLE_COPY_MOVE(Class) \ - Q_DISABLE_COPY(Class) \ - Class(Class &&) = delete; \ - Class &operator=(Class &&) = delete; -#endif - #ifndef Q_DISABLE_ASSIGN_MOVE #define Q_DISABLE_ASSIGN_MOVE(Class) \ Q_DISABLE_ASSIGN(Class) \ @@ -65,65 +48,6 @@ template void qAsConst(const T &&) Q_DECL_EQ_DELETE; Class &operator=(Class &&) = delete; #endif -#define SUFFIX_APPEND(x, y) x##y // NOLINT(cppcoreguidelines-macro-usage) - -#define HOURS_INT(x) ((x)*3600000) // NOLINT(cppcoreguidelines-macro-usage) -#define MINUTES_INT(x) ((x)*60000) // NOLINT(cppcoreguidelines-macro-usage) -#define SECONDS_INT(x) ((x)*1000) // NOLINT(cppcoreguidelines-macro-usage) -#define MSECONDS_INT(x) (x) // NOLINT(cppcoreguidelines-macro-usage) -#define MICSECONDS_INT(x) (x) // NOLINT(cppcoreguidelines-macro-usage) -#define NANOSECONDS_INT(x) (x) // NOLINT(cppcoreguidelines-macro-usage) - -#if (defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) -#define HOURS(x) HOURS_INT(x) // NOLINT(cppcoreguidelines-macro-usage) -#define MINUTES(x) MINUTES_INT(x) // NOLINT(cppcoreguidelines-macro-usage) -#define SECONDS(x) SECONDS_INT(x) // NOLINT(cppcoreguidelines-macro-usage) -#define MSECONDS(x) MSECONDS_INT(x) // NOLINT(cppcoreguidelines-macro-usage) -#define MICSECONDS(x) MICSECONDS_INT(x) // NOLINT(cppcoreguidelines-macro-usage) -#define NANOSECONDS(x) NANOSECONDS_INT(x) // NOLINT(cppcoreguidelines-macro-usage) -#else -#if __cplusplus >= 201402L -#define HOURS(x) SUFFIX_APPEND(x, h) // NOLINT(cppcoreguidelines-macro-usage) -#define MINUTES(x) SUFFIX_APPEND(x, min) // NOLINT(cppcoreguidelines-macro-usage) -#define SECONDS(x) SUFFIX_APPEND(x, s) // NOLINT(cppcoreguidelines-macro-usage) -#define MSECONDS(x) SUFFIX_APPEND(x, ms) // NOLINT(cppcoreguidelines-macro-usage) -#define MICSECONDS(x) SUFFIX_APPEND(x, us) // NOLINT(cppcoreguidelines-macro-usage) -#define NANOSECONDS(x) SUFFIX_APPEND(x, ns) // NOLINT(cppcoreguidelines-macro-usage) -#else -#define HOURS(x) SUFFIX_APPEND(x, _h) // NOLINT(cppcoreguidelines-macro-usage) -#define MINUTES(x) SUFFIX_APPEND(x, _min) // NOLINT(cppcoreguidelines-macro-usage) -#define SECONDS(x) SUFFIX_APPEND(x, _s) // NOLINT(cppcoreguidelines-macro-usage) -#define MSECONDS(x) SUFFIX_APPEND(x, _ms) // NOLINT(cppcoreguidelines-macro-usage) -#define MICSECONDS(x) SUFFIX_APPEND(x, _us) // NOLINT(cppcoreguidelines-macro-usage) -#define NANOSECONDS(x) SUFFIX_APPEND(x, _ns) // NOLINT(cppcoreguidelines-macro-usage) -#endif // __cplusplus >= 201402L -#endif // (defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) - -#if (defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) -#define V_HOURS(x) HOURS(x) // NOLINT(cppcoreguidelines-macro-usage) -#define V_MINUTES(x) MINUTES(x) // NOLINT(cppcoreguidelines-macro-usage) -#define V_SECONDS(x) SECONDS(x) // NOLINT(cppcoreguidelines-macro-usage) -#define V_MSECONDS(x) MSECONDS(x) // NOLINT(cppcoreguidelines-macro-usage) -#define V_MICSECONDS(x) MICSECONDS(x) // NOLINT(cppcoreguidelines-macro-usage) -#define V_NANOSECONDS(x) NANOSECONDS(x) // NOLINT(cppcoreguidelines-macro-usage) -#else -#if QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) -#define V_HOURS(x) HOURS(x) // NOLINT(cppcoreguidelines-macro-usage) -#define V_MINUTES(x) MINUTES(x) // NOLINT(cppcoreguidelines-macro-usage) -#define V_SECONDS(x) SECONDS(x) // NOLINT(cppcoreguidelines-macro-usage) -#define V_MSECONDS(x) MSECONDS(x) // NOLINT(cppcoreguidelines-macro-usage) -#define V_MICSECONDS(x) MICSECONDS(x) // NOLINT(cppcoreguidelines-macro-usage) -#define V_NANOSECONDS(x) NANOSECONDS(x) // NOLINT(cppcoreguidelines-macro-usage) -#else -#define V_HOURS(x) HOURS_INT(x) // NOLINT(cppcoreguidelines-macro-usage) -#define V_MINUTES(x) MINUTES_INT(x) // NOLINT(cppcoreguidelines-macro-usage) -#define V_SECONDS(x) SECONDS_INT(x) // NOLINT(cppcoreguidelines-macro-usage) -#define V_MSECONDS(x) MSECONDS_INT(x) // NOLINT(cppcoreguidelines-macro-usage) -#define V_MICSECONDS(x) MICSECONDS_INT(x) // NOLINT(cppcoreguidelines-macro-usage) -#define V_NANOSECONDS(x) NANOSECONDS_INT(x) // NOLINT(cppcoreguidelines-macro-usage) -#endif // QT_VERSION >= QT_VERSION_CHECK(5, 8, 0) -#endif // (defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) - #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) using vsizetype = qsizetype; #else diff --git a/src/libs/vmisc/dialogs/dialogaskcollectstatistic.h b/src/libs/vmisc/dialogs/dialogaskcollectstatistic.h index 7b7520121..a848954e1 100644 --- a/src/libs/vmisc/dialogs/dialogaskcollectstatistic.h +++ b/src/libs/vmisc/dialogs/dialogaskcollectstatistic.h @@ -30,9 +30,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../defglobal.h" -#endif namespace Ui { diff --git a/src/libs/vmisc/dialogs/dialogexporttocsv.cpp b/src/libs/vmisc/dialogs/dialogexporttocsv.cpp index 42c361243..294f6613d 100644 --- a/src/libs/vmisc/dialogs/dialogexporttocsv.cpp +++ b/src/libs/vmisc/dialogs/dialogexporttocsv.cpp @@ -43,10 +43,6 @@ #include #endif -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - #if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) #include "../compatibility.h" #endif @@ -100,11 +96,7 @@ DialogExportToCSV::DialogExportToCSV(QWidget *parent) connect(ui->comboBoxCodec, QOverload::of(&QComboBox::currentIndexChanged), this, [this]() { ShowPreview(); }); connect(ui->checkBoxWithHeader, &QCheckBox::stateChanged, this, [this]() { ShowPreview(); }); -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - connect(ui->buttonGroup, QOverload::of(&QButtonGroup::buttonClicked), this, [this]() { ShowPreview(); }); -#else connect(ui->buttonGroup, &QButtonGroup::idClicked, this, [this]() { ShowPreview(); }); -#endif } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vmisc/dialogs/dialogexporttocsv.h b/src/libs/vmisc/dialogs/dialogexporttocsv.h index d5d7e5b81..4066d01f4 100644 --- a/src/libs/vmisc/dialogs/dialogexporttocsv.h +++ b/src/libs/vmisc/dialogs/dialogexporttocsv.h @@ -31,10 +31,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../defglobal.h" -#endif - namespace Ui { class DialogExportToCSV; diff --git a/src/libs/vmisc/dialogs/dialogselectlanguage.h b/src/libs/vmisc/dialogs/dialogselectlanguage.h index 6a4df3fb3..fc7fb0c34 100644 --- a/src/libs/vmisc/dialogs/dialogselectlanguage.h +++ b/src/libs/vmisc/dialogs/dialogselectlanguage.h @@ -30,10 +30,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../defglobal.h" -#endif - namespace Ui { class DialogSelectLanguage; diff --git a/src/libs/vmisc/qxtcsvmodel.cpp b/src/libs/vmisc/qxtcsvmodel.cpp index e804eeb68..f4fac9326 100644 --- a/src/libs/vmisc/qxtcsvmodel.cpp +++ b/src/libs/vmisc/qxtcsvmodel.cpp @@ -46,10 +46,6 @@ #include #endif -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) -#include "backport/text.h" -#endif - #if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) #include "compatibility.h" #endif diff --git a/src/libs/vmisc/svgfont/svgdef.cpp b/src/libs/vmisc/svgfont/svgdef.cpp index f78a7d2a4..1b7d7978f 100644 --- a/src/libs/vmisc/svgfont/svgdef.cpp +++ b/src/libs/vmisc/svgfont/svgdef.cpp @@ -1491,7 +1491,6 @@ auto NkoWritingSystem(QChar c) -> bool //--------------------------------------------------------------------------------------------------------------------- auto WritingSystemSample(SVGFontWritingSystem writingSystem) -> QString { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return [&]() -> QStringView { switch (writingSystem) @@ -1569,222 +1568,4 @@ auto WritingSystemSample(SVGFontWritingSystem writingSystem) -> QString } }() .toString(); -#else - QString sample; - switch (writingSystem) - { - case SVGFontWritingSystem::Any: - case SVGFontWritingSystem::Symbol: - sample += "AaBbzZ"_L1; - break; - case SVGFontWritingSystem::Latin: - sample = "Aa"_L1; - sample += QChar(0x00C3); - sample += QChar(0x00E1); - sample += "Zz"_L1; - break; - case SVGFontWritingSystem::Greek: - sample += QChar(0x0393); - sample += QChar(0x03B1); - sample += QChar(0x03A9); - sample += QChar(0x03C9); - break; - case SVGFontWritingSystem::Cyrillic: - sample += QChar(0x0414); - sample += QChar(0x0434); - sample += QChar(0x0436); - sample += QChar(0x044f); - break; - case SVGFontWritingSystem::Armenian: - sample += QChar(0x053f); - sample += QChar(0x054f); - sample += QChar(0x056f); - sample += QChar(0x057f); - break; - case SVGFontWritingSystem::Hebrew: - sample += QChar(0x05D0); - sample += QChar(0x05D1); - sample += QChar(0x05D2); - sample += QChar(0x05D3); - break; - case SVGFontWritingSystem::Arabic: - sample += QChar(0x0623); - sample += QChar(0x0628); - sample += QChar(0x062C); - sample += QChar(0x062F); - sample += QChar(0x064A); - sample += QChar(0x0629); - sample += QChar(0x0020); - sample += QChar(0x0639); - sample += QChar(0x0631); - sample += QChar(0x0628); - sample += QChar(0x064A); - sample += QChar(0x0629); - break; - case SVGFontWritingSystem::Syriac: - sample += QChar(0x0715); - sample += QChar(0x0725); - sample += QChar(0x0716); - sample += QChar(0x0726); - break; - case SVGFontWritingSystem::Thaana: - sample += QChar(0x0784); - sample += QChar(0x0794); - sample += QChar(0x078c); - sample += QChar(0x078d); - break; - case SVGFontWritingSystem::Devanagari: - sample += QChar(0x0905); - sample += QChar(0x0915); - sample += QChar(0x0925); - sample += QChar(0x0935); - break; - case SVGFontWritingSystem::Bengali: - sample += QChar(0x0986); - sample += QChar(0x0996); - sample += QChar(0x09a6); - sample += QChar(0x09b6); - break; - case SVGFontWritingSystem::Gurmukhi: - sample += QChar(0x0a05); - sample += QChar(0x0a15); - sample += QChar(0x0a25); - sample += QChar(0x0a35); - break; - case SVGFontWritingSystem::Gujarati: - sample += QChar(0x0a85); - sample += QChar(0x0a95); - sample += QChar(0x0aa5); - sample += QChar(0x0ab5); - break; - case SVGFontWritingSystem::Oriya: - sample += QChar(0x0b06); - sample += QChar(0x0b16); - sample += QChar(0x0b2b); - sample += QChar(0x0b36); - break; - case SVGFontWritingSystem::Tamil: - sample += QChar(0x0b89); - sample += QChar(0x0b99); - sample += QChar(0x0ba9); - sample += QChar(0x0bb9); - break; - case SVGFontWritingSystem::Telugu: - sample += QChar(0x0c05); - sample += QChar(0x0c15); - sample += QChar(0x0c25); - sample += QChar(0x0c35); - break; - case SVGFontWritingSystem::Kannada: - sample += QChar(0x0c85); - sample += QChar(0x0c95); - sample += QChar(0x0ca5); - sample += QChar(0x0cb5); - break; - case SVGFontWritingSystem::Malayalam: - sample += QChar(0x0d05); - sample += QChar(0x0d15); - sample += QChar(0x0d25); - sample += QChar(0x0d35); - break; - case SVGFontWritingSystem::Sinhala: - sample += QChar(0x0d90); - sample += QChar(0x0da0); - sample += QChar(0x0db0); - sample += QChar(0x0dc0); - break; - case SVGFontWritingSystem::Thai: - sample += QChar(0x0e02); - sample += QChar(0x0e12); - sample += QChar(0x0e22); - sample += QChar(0x0e32); - break; - case SVGFontWritingSystem::Lao: - sample += QChar(0x0e8d); - sample += QChar(0x0e9d); - sample += QChar(0x0ead); - sample += QChar(0x0ebd); - break; - case SVGFontWritingSystem::Tibetan: - sample += QChar(0x0f00); - sample += QChar(0x0f01); - sample += QChar(0x0f02); - sample += QChar(0x0f03); - break; - case SVGFontWritingSystem::Myanmar: - sample += QChar(0x1000); - sample += QChar(0x1001); - sample += QChar(0x1002); - sample += QChar(0x1003); - break; - case SVGFontWritingSystem::Georgian: - sample += QChar(0x10a0); - sample += QChar(0x10b0); - sample += QChar(0x10c0); - sample += QChar(0x10d0); - break; - case SVGFontWritingSystem::Khmer: - sample += QChar(0x1780); - sample += QChar(0x1790); - sample += QChar(0x17b0); - sample += QChar(0x17c0); - break; - case SVGFontWritingSystem::SimplifiedChinese: - sample += QChar(0x4e2d); - sample += QChar(0x6587); - sample += QChar(0x8303); - sample += QChar(0x4f8b); - break; - case SVGFontWritingSystem::TraditionalChinese: - sample += QChar(0x4e2d); - sample += QChar(0x6587); - sample += QChar(0x7bc4); - sample += QChar(0x4f8b); - break; - case SVGFontWritingSystem::Japanese: - sample += QChar(0x30b5); - sample += QChar(0x30f3); - sample += QChar(0x30d7); - sample += QChar(0x30eb); - sample += QChar(0x3067); - sample += QChar(0x3059); - break; - case SVGFontWritingSystem::Korean: - sample += QChar(0xac00); - sample += QChar(0xac11); - sample += QChar(0xac1a); - sample += QChar(0xac2f); - break; - case SVGFontWritingSystem::Vietnamese: - { - static const char vietnameseUtf8[] = { - char(0xef), char(0xbb), char(0xbf), char(0xe1), char(0xbb), char(0x97), char(0xe1), char(0xbb), - char(0x99), char(0xe1), char(0xbb), char(0x91), char(0xe1), char(0xbb), char(0x93), - }; - sample += QString::fromUtf8(vietnameseUtf8, sizeof(vietnameseUtf8)); - break; - } - case SVGFontWritingSystem::Ogham: - sample += QChar(0x1681); - sample += QChar(0x1682); - sample += QChar(0x1683); - sample += QChar(0x1684); - break; - case SVGFontWritingSystem::Runic: - sample += QChar(0x16a0); - sample += QChar(0x16a1); - sample += QChar(0x16a2); - sample += QChar(0x16a3); - break; - case SVGFontWritingSystem::Nko: - sample += QChar(0x7ca); - sample += QChar(0x7cb); - sample += QChar(0x7cc); - sample += QChar(0x7cd); - break; - default: - break; - } - return sample; -#endif } diff --git a/src/libs/vmisc/svgfont/vsvgfontreader.h b/src/libs/vmisc/svgfont/vsvgfontreader.h index 5626f6867..3d2f6fd08 100644 --- a/src/libs/vmisc/svgfont/vsvgfontreader.h +++ b/src/libs/vmisc/svgfont/vsvgfontreader.h @@ -32,10 +32,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../defglobal.h" -#endif - class QFile; class VSvgFont; class VSvgFontEngine; diff --git a/src/libs/vmisc/svgfont/vsvgpathtokenizer.cpp b/src/libs/vmisc/svgfont/vsvgpathtokenizer.cpp index 2f71ab48a..523749fad 100644 --- a/src/libs/vmisc/svgfont/vsvgpathtokenizer.cpp +++ b/src/libs/vmisc/svgfont/vsvgpathtokenizer.cpp @@ -68,12 +68,12 @@ auto IsSeparator(const QString ¤tToken, const QChar &ch) -> bool return true; } - if (ch == '-'_L1 && !currentToken.isEmpty() && Back(currentToken) != 'e'_L1 && Back(currentToken) != 'E'_L1) + if (ch == '-'_L1 && !currentToken.isEmpty() && currentToken.back() != 'e'_L1 && currentToken.back() != 'E'_L1) { return true; } - if (ch == '+'_L1 && !currentToken.isEmpty() && Back(currentToken) != 'e'_L1 && Back(currentToken) != 'E'_L1) + if (ch == '+'_L1 && !currentToken.isEmpty() && currentToken.back() != 'e'_L1 && currentToken.back() != 'E'_L1) { return true; } diff --git a/src/libs/vmisc/svgfont/vsvgpathtokenizer.h b/src/libs/vmisc/svgfont/vsvgpathtokenizer.h index 8ea9c831a..bad9279ef 100644 --- a/src/libs/vmisc/svgfont/vsvgpathtokenizer.h +++ b/src/libs/vmisc/svgfont/vsvgpathtokenizer.h @@ -35,10 +35,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../defglobal.h" -#endif - class QPainterPath; struct VSVGPathCommand diff --git a/src/libs/vmisc/testpath.h b/src/libs/vmisc/testpath.h index 9bcac2067..416c99c02 100644 --- a/src/libs/vmisc/testpath.h +++ b/src/libs/vmisc/testpath.h @@ -61,14 +61,12 @@ template void DumpVector(const QVector &points, const QString &temp if (temp.open()) { #if defined(Q_OS_LINUX) -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) // On Linux, QTemporaryFile will attempt to create unnamed temporary // files. If that succeeds, open() will return true but exists() will be // false. If you call fileName() or any function that calls it, // QTemporaryFile will give the file a name, so most applications will // not see a difference. temp.fileName(); // call to create a file on disk -#endif #endif QJsonObject vectorObject; VectorToJson(points, vectorObject); diff --git a/src/libs/vmisc/theme/vapplicationstyle.cpp b/src/libs/vmisc/theme/vapplicationstyle.cpp index be267198e..c162b0be6 100644 --- a/src/libs/vmisc/theme/vapplicationstyle.cpp +++ b/src/libs/vmisc/theme/vapplicationstyle.cpp @@ -118,7 +118,6 @@ auto StandardIconPaths() -> QHash {QStyle::SP_LineEditClearButton, "clear_text.svg"}, }; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) icons.insert(QStyle::SP_DialogYesToAllButton, QStringLiteral("dialog_yes_to_all.svg")); icons.insert(QStyle::SP_DialogNoToAllButton, QStringLiteral("dialog_no.svg")); icons.insert(QStyle::SP_DialogSaveAllButton, QStringLiteral("dialog_save_all.svg")); @@ -126,7 +125,6 @@ auto StandardIconPaths() -> QHash icons.insert(QStyle::SP_DialogRetryButton, QStringLiteral("dialog_retry.svg")); icons.insert(QStyle::SP_DialogIgnoreButton, QStringLiteral("dialog_ignore.svg")); icons.insert(QStyle::SP_RestoreDefaultsButton, QStringLiteral("restore_defaults.svg")); -#endif #if QT_VERSION >= QT_VERSION_CHECK(6, 3, 0) icons.insert(QStyle::SP_TabCloseButton, QStringLiteral("tab_close.svg")); diff --git a/src/libs/vmisc/theme/vapplicationstyle.h b/src/libs/vmisc/theme/vapplicationstyle.h index 6d6b1b085..7ca0b1de7 100644 --- a/src/libs/vmisc/theme/vapplicationstyle.h +++ b/src/libs/vmisc/theme/vapplicationstyle.h @@ -31,10 +31,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../defglobal.h" -#endif - class VApplicationStyle : public QStyle { Q_OBJECT // NOLINT diff --git a/src/libs/vmisc/theme/vscenestylesheet.h b/src/libs/vmisc/theme/vscenestylesheet.h index 145e557d7..a449a3fef 100644 --- a/src/libs/vmisc/theme/vscenestylesheet.h +++ b/src/libs/vmisc/theme/vscenestylesheet.h @@ -35,10 +35,6 @@ #include "vpatternpiecestyle.h" #include "vtoolstyle.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../defglobal.h" -#endif - class QGraphicsItem; class VSceneStylesheet diff --git a/src/libs/vmisc/theme/vtheme.cpp b/src/libs/vmisc/theme/vtheme.cpp index 520d4f8c9..523da9f05 100644 --- a/src/libs/vmisc/theme/vtheme.cpp +++ b/src/libs/vmisc/theme/vtheme.cpp @@ -29,6 +29,7 @@ #include "../vcommonsettings.h" #include +#include #include #include #include @@ -39,15 +40,6 @@ #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) -#include -#else -#if defined(Q_OS_WIN) -#include // Required for RtlGetVersion -#include -#endif // defined(Q_OS_WIN) -#endif // QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) - #if defined(Q_OS_MACX) #include "macutils.h" #endif @@ -56,18 +48,8 @@ #include #endif -#if (defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) -// DO NOT WORK WITH GCC 4.8 -#else -#if __cplusplus >= 201402L using namespace std::chrono_literals; -#else -#include "../bpstd/chrono.hpp" -using namespace bpstd::literals::chrono_literals; -#endif // __cplusplus >= 201402L -#endif //(defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) -#include "../defglobal.h" #include "../vabstractapplication.h" #include "vapplicationstyle.h" #include "vscenestylesheet.h" @@ -80,76 +62,12 @@ using namespace Qt::Literals::StringLiterals; namespace { -#if QT_VERSION < QT_VERSION_CHECK(5, 9, 0) -#if defined(Q_OS_WIN) -// Define the RtlGetVersion function -typedef NTSTATUS(WINAPI *RtlGetVersionFunc)(PRTL_OSVERSIONINFOW); - -// Function to get the OS version using RtlGetVersion if available, otherwise fallback to GetVersionEx -bool GetTrueWindowsVersion(RTL_OSVERSIONINFOW &osVersionInfo) -{ - // Function pointer to driver function - RtlGetVersionFunc pRtlGetVersion = nullptr; - - // Load the System-DLL - HMODULE hNTdllDll = LoadLibrary(L"ntdll.dll"); - - // Successfully loaded? - if (hNTdllDll != nullptr) - { - QT_WARNING_PUSH - QT_WARNING_DISABLE_MSVC(4191) - - // Get the function pointer to RtlGetVersion - pRtlGetVersion = reinterpret_cast(GetProcAddress(hNTdllDll, "RtlGetVersion")); - - QT_WARNING_POP - - // If successful then read the function - if (pRtlGetVersion != nullptr) - { - ZeroMemory(&osVersionInfo, sizeof(RTL_OSVERSIONINFOW)); - osVersionInfo.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOW); - - if (pRtlGetVersion(&osVersionInfo) == 0) - { - // Successfully obtained OS version using RtlGetVersion - FreeLibrary(hNTdllDll); - return true; - } - } - - // Free the library if RtlGetVersion failed - FreeLibrary(hNTdllDll); - } - - // Fallback to GetVersionEx if RtlGetVersion is not available - OSVERSIONINFOEX osVersionFallback; - ZeroMemory(&osVersionFallback, sizeof(OSVERSIONINFOEX)); - osVersionFallback.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - - if (GetVersionEx(reinterpret_cast(&osVersionFallback))) - { - // Successfully obtained OS version using GetVersionEx - osVersionInfo.dwMajorVersion = osVersionFallback.dwMajorVersion; - osVersionInfo.dwMinorVersion = osVersionFallback.dwMinorVersion; - osVersionInfo.dwBuildNumber = osVersionFallback.dwBuildNumber; - return true; - } - - // Failed to obtain OS version - return false; -} -#endif // defined(Q_OS_WIN) -#endif // QT_VERSION < QT_VERSION_CHECK(5, 9, 0) - //--------------------------------------------------------------------------------------------------------------------- #ifdef Q_OS_WIN auto NativeWindowsDarkThemeAvailable() -> bool { // dark mode supported Windows 10 1809 10.0.17763 onward // https://stackoverflow.com/questions/53501268/win10-dark-theme-how-to-use-in-winapi -#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) if (QOperatingSystemVersion::current().majorVersion() > 10) { return true; @@ -159,21 +77,6 @@ auto NativeWindowsDarkThemeAvailable() -> bool { return QOperatingSystemVersion::current().microVersion() >= 17763; } -#else - RTL_OSVERSIONINFOW osVersionInfo; - if (GetTrueWindowsVersion(osVersionInfo)) - { - if (osVersionInfo.dwMajorVersion > 10) - { - return true; - } - - if (osVersionInfo.dwMajorVersion == 10) - { - return osVersionInfo.dwBuildNumber >= 17763; - } - } -#endif // QT_VERSION >= QT_VERSION_CHECK(5, 9, 0) return false; } @@ -251,18 +154,7 @@ void ActivateDefaultThemeWin() #if defined(Q_OS_MACX) void ActivateDefaultThemeMac() { -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) qApp->setStyleSheet(QString()); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) -#else - if (VTheme::IsInDarkTheme()) - { - ActivateCustomDarkTheme(); - } - else - { - qApp->setStyleSheet(QString()); // NOLINT(cppcoreguidelines-pro-type-static-cast-downcast) - } -#endif // QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) } #endif // defined(Q_OS_MACX) @@ -717,7 +609,7 @@ VTheme::VTheme(QObject *parent) }; connect(m_themeTimer, &QTimer::timeout, this, colorSchemeTimeoutCheck); - m_themeTimer->start(V_SECONDS(5)); + m_themeTimer->start(5s); } #endif // QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) } diff --git a/src/libs/vmisc/theme/vtheme.h b/src/libs/vmisc/theme/vtheme.h index 8e00a1d00..b253de6cd 100644 --- a/src/libs/vmisc/theme/vtheme.h +++ b/src/libs/vmisc/theme/vtheme.h @@ -32,10 +32,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../defglobal.h" -#endif - enum class VColorSheme { Light, diff --git a/src/libs/vmisc/vabstractshortcutmanager.h b/src/libs/vmisc/vabstractshortcutmanager.h index a01589612..49e46e8d6 100644 --- a/src/libs/vmisc/vabstractshortcutmanager.h +++ b/src/libs/vmisc/vabstractshortcutmanager.h @@ -35,10 +35,6 @@ #include #endif -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "defglobal.h" -#endif - #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #define QKEY_SEQUENCE_OP | #else diff --git a/src/libs/vmisc/vdatastreamenum.h b/src/libs/vmisc/vdatastreamenum.h deleted file mode 100644 index bf712cd70..000000000 --- a/src/libs/vmisc/vdatastreamenum.h +++ /dev/null @@ -1,71 +0,0 @@ -/************************************************************************ - ** - ** @file vdatastreamenum.h - ** @author Roman Telezhynskyi - ** @date 21 12, 2018 - ** - ** @brief - ** @copyright - ** This source code is part of the Valentina project, a pattern making - ** program, whose allow create and modeling patterns of clothing. - ** Copyright (C) 2015 Valentina project - ** All Rights Reserved. - ** - ** Valentina is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** Valentina is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with Valentina. If not, see . - ** - *************************************************************************/ - -#ifndef DATASTREAM_ENUM_H -#define DATASTREAM_ENUM_H - -#include -#include - -// (de)serialize enums into QDataStream - -// It is very important to use exactly the same way across all Qt versions we need to support. Otherwise, it will break -// interchange between Valentina versions built on different Qt versions. - -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) -template -auto operator<<(QDataStream &s, const T &t) -> typename std::enable_if::value, QDataStream &>::type& -{ - return s << static_cast::type>(t); -} - -template -auto operator>>(QDataStream &s, T &t) -> typename std::enable_if::value, QDataStream &>::type& -{ - return s >> reinterpret_cast::type &>(t); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) -} - -#if QT_VERSION < QT_VERSION_CHECK(5, 9, 0) -template -inline QDataStream &operator<<(QDataStream &s, QFlags e) -{ - return s << static_cast(e); -} - -template -inline QDataStream &operator>>(QDataStream &s, QFlags &e) -{ - int v; - s >> v; - e = static_cast>(v); - return s; -} -#endif // QT_VERSION < QT_VERSION_CHECK(5, 9, 0) -#endif // QT_VERSION < QT_VERSION_CHECK(5, 14, 0) - -#endif // DATASTREAM_ENUM_H diff --git a/src/libs/vmisc/vlockguard.h b/src/libs/vmisc/vlockguard.h index 8d6a213d0..4895bd3bb 100644 --- a/src/libs/vmisc/vlockguard.h +++ b/src/libs/vmisc/vlockguard.h @@ -35,16 +35,11 @@ #include #endif /*Q_OS_WIN*/ -#include -#include - -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - #include #include #include +#include +#include /*@brief * This class creates Guarded object if and only if lock file taken. It keeps shared_ptr to object and lock-file. diff --git a/src/libs/vmisc/vmisc.pri b/src/libs/vmisc/vmisc.pri index f7333123f..2ee07e869 100644 --- a/src/libs/vmisc/vmisc.pri +++ b/src/libs/vmisc/vmisc.pri @@ -49,33 +49,6 @@ contains(DEFINES, APPIMAGE) { } HEADERS += \ - $$PWD/bpstd/any.hpp \ - $$PWD/bpstd/chrono.hpp \ - $$PWD/bpstd/complex.hpp \ - $$PWD/bpstd/cstddef.hpp \ - $$PWD/bpstd/detail/config.hpp \ - $$PWD/bpstd/detail/enable_overload.hpp \ - $$PWD/bpstd/detail/invoke.hpp \ - $$PWD/bpstd/detail/move.hpp \ - $$PWD/bpstd/detail/nth_type.hpp \ - $$PWD/bpstd/detail/proxy_iterator.hpp \ - $$PWD/bpstd/detail/variant_base.hpp \ - $$PWD/bpstd/detail/variant_fwds.hpp \ - $$PWD/bpstd/detail/variant_traits.hpp \ - $$PWD/bpstd/detail/variant_union.hpp \ - $$PWD/bpstd/detail/variant_visitors.hpp \ - $$PWD/bpstd/exception.hpp \ - $$PWD/bpstd/functional.hpp \ - $$PWD/bpstd/iterator.hpp \ - $$PWD/bpstd/memory.hpp \ - $$PWD/bpstd/optional.hpp \ - $$PWD/bpstd/span.hpp \ - $$PWD/bpstd/string.hpp \ - $$PWD/bpstd/string_view.hpp \ - $$PWD/bpstd/tuple.hpp \ - $$PWD/bpstd/type_traits.hpp \ - $$PWD/bpstd/utility.hpp \ - $$PWD/bpstd/variant.hpp \ $$PWD/compatibility.h \ $$PWD/dialogs/dialogaskcollectstatistic.h \ $$PWD/dialogs/vshortcutdialog.h \ @@ -116,15 +89,11 @@ HEADERS += \ $$PWD/dialogs/dialogexporttocsv.h \ $$PWD/customevents.h \ $$PWD/defglobal.h \ - $$PWD/backport/qoverload.h \ $$PWD/testvapplication.h \ $$PWD/literals.h \ $$PWD/qt_dispatch/qt_dispatch.h \ - $$PWD/vdatastreamenum.h \ $$PWD/vmodifierkey.h \ $$PWD/typedef.h \ - $$PWD/backport/qscopeguard.h \ - $$PWD/backport/text.h \ $$PWD/dialogs/dialogselectlanguage.h \ $$PWD/fpm/fixed.hpp \ $$PWD/fpm/math.hpp \ diff --git a/src/libs/vmisc/vmisc.qbs b/src/libs/vmisc/vmisc.qbs index f1fffe161..ec09ea070 100644 --- a/src/libs/vmisc/vmisc.qbs +++ b/src/libs/vmisc/vmisc.qbs @@ -39,7 +39,6 @@ VLib { "testvapplication.h", "literals.h", "qt_dispatch/qt_dispatch.h", - "vdatastreamenum.h", "vmodifierkey.h", "typedef.h", "vabstractshortcutmanager.h", @@ -85,50 +84,6 @@ VLib { ] } - Group { - name: "bpstd" - prefix: "bpstd/" - files: [ - "any.hpp", - "chrono.hpp", - "complex.hpp", - "cstddef.hpp", - "detail/config.hpp", - "detail/enable_overload.hpp", - "detail/invoke.hpp", - "detail/move.hpp", - "detail/nth_type.hpp", - "detail/proxy_iterator.hpp", - "detail/variant_base.hpp", - "detail/variant_fwds.hpp", - "detail/variant_traits.hpp", - "detail/variant_union.hpp", - "detail/variant_visitors.hpp", - "exception.hpp", - "functional.hpp", - "iterator.hpp", - "memory.hpp", - "optional.hpp", - "span.hpp", - "string.hpp", - "string_view.hpp", - "tuple.hpp", - "type_traits.hpp", - "utility.hpp", - "variant.hpp", - ] - } - - Group { - name: "backport" - prefix: "backport/" - files: [ - "qoverload.h", - "qscopeguard.h", - "text.h", - ] - } - Group { name: "fpm" prefix: "fpm/" diff --git a/src/libs/vobj/vobjengine.cpp b/src/libs/vobj/vobjengine.cpp index bc470229e..08370ed52 100644 --- a/src/libs/vobj/vobjengine.cpp +++ b/src/libs/vobj/vobjengine.cpp @@ -45,10 +45,6 @@ #include "../vmisc/defglobal.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) -#include "../vmisc/backport/text.h" -#endif - // Header is removed in C++20. #if __cplusplus <= 201703L #include // and, not, or diff --git a/src/libs/vobj/vobjengine.h b/src/libs/vobj/vobjengine.h index b469fa377..c82af9e24 100644 --- a/src/libs/vobj/vobjengine.h +++ b/src/libs/vobj/vobjengine.h @@ -37,9 +37,6 @@ #include #include "delaunay.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif class QTextStream; diff --git a/src/libs/vobj/vobjpaintdevice.h b/src/libs/vobj/vobjpaintdevice.h index 989aee12c..22425128f 100644 --- a/src/libs/vobj/vobjpaintdevice.h +++ b/src/libs/vobj/vobjpaintdevice.h @@ -35,10 +35,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class QIODevice; class VObjEngine; diff --git a/src/libs/vpatterndb/testpassmark.cpp b/src/libs/vpatterndb/testpassmark.cpp index 995f94430..1cf4d4bc0 100644 --- a/src/libs/vpatterndb/testpassmark.cpp +++ b/src/libs/vpatterndb/testpassmark.cpp @@ -44,10 +44,9 @@ namespace auto PassmarkShapeToJson(const QVector &shape) -> QJsonArray { QJsonArray shapeArray; - for (auto line: shape) + for (auto line : shape) { - QJsonObject lineObject - { + QJsonObject lineObject{ {"type", "QLineF"}, {"p1", PointToJson(line.p1())}, {"p2", PointToJson(line.p2())}, @@ -58,12 +57,12 @@ auto PassmarkShapeToJson(const QVector &shape) -> QJsonArray return shapeArray; } -} +} // namespace //--------------------------------------------------------------------------------------------------------------------- void DumpPassmarkData(const VPiecePassmarkData &data, const QString &templateName) { - QTemporaryFile temp; // Go to tmp folder to find dump + QTemporaryFile temp; // Go to tmp folder to find dump temp.setAutoRemove(false); // Remove dump manually if (not templateName.isEmpty()) @@ -74,17 +73,14 @@ void DumpPassmarkData(const VPiecePassmarkData &data, const QString &templateNam if (temp.open()) { #if defined(Q_OS_LINUX) - #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) -// On Linux, QTemporaryFile will attempt to create unnamed temporary -// files. If that succeeds, open() will return true but exists() will be -// false. If you call fileName() or any function that calls it, -// QTemporaryFile will give the file a name, so most applications will -// not see a difference. + // On Linux, QTemporaryFile will attempt to create unnamed temporary + // files. If that succeeds, open() will return true but exists() will be + // false. If you call fileName() or any function that calls it, + // QTemporaryFile will give the file a name, so most applications will + // not see a difference. temp.fileName(); // call to create a file on disk - #endif #endif - QJsonObject dataObject - { + QJsonObject dataObject{ {"data", data.toJson()}, }; QJsonDocument vector(dataObject); @@ -98,7 +94,7 @@ void DumpPassmarkData(const VPiecePassmarkData &data, const QString &templateNam //--------------------------------------------------------------------------------------------------------------------- void DumpPassmarkShape(const QVector &shape, const QString &templateName) { - QTemporaryFile temp; // Go to tmp folder to find dump + QTemporaryFile temp; // Go to tmp folder to find dump temp.setAutoRemove(false); // Remove dump manually if (not templateName.isEmpty()) @@ -109,17 +105,14 @@ void DumpPassmarkShape(const QVector &shape, const QString &templateName if (temp.open()) { #if defined(Q_OS_LINUX) - #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) -// On Linux, QTemporaryFile will attempt to create unnamed temporary -// files. If that succeeds, open() will return true but exists() will be -// false. If you call fileName() or any function that calls it, -// QTemporaryFile will give the file a name, so most applications will -// not see a difference. + // On Linux, QTemporaryFile will attempt to create unnamed temporary + // files. If that succeeds, open() will return true but exists() will be + // false. If you call fileName() or any function that calls it, + // QTemporaryFile will give the file a name, so most applications will + // not see a difference. temp.fileName(); // call to create a file on disk - #endif #endif - QJsonObject shapeObject - { + QJsonObject shapeObject{ {"shape", PassmarkShapeToJson(shape)}, }; QJsonDocument vector(shapeObject); diff --git a/src/libs/vpatterndb/vcontainer.cpp b/src/libs/vpatterndb/vcontainer.cpp index 4de9c7a37..9a5d80679 100644 --- a/src/libs/vpatterndb/vcontainer.cpp +++ b/src/libs/vpatterndb/vcontainer.cpp @@ -588,7 +588,7 @@ auto VContainer::DataMeasurementsWithSeparators() const -> const QMap> measurements = DataVar(VarType::Measurement); QMap> separators = DataVar(VarType::MeasurementSeparator); - Insert(measurements, separators); + measurements.insert(separators); return measurements; } @@ -605,7 +605,7 @@ auto VContainer::DataIncrementsWithSeparators() const -> const QMap> increments = DataVar(VarType::Increment); QMap> separators = DataVar(VarType::IncrementSeparator); - Insert(increments, separators); + increments.insert(separators); return increments; } @@ -652,7 +652,7 @@ auto VContainer::DataPieceArea() const -> const QMap> externalAreas = DataVar(VarType::PieceExternalArea); QMap> seamLineAreas = DataVar(VarType::PieceSeamLineArea); - Insert(externalAreas, seamLineAreas); + externalAreas.insert(seamLineAreas); return externalAreas; } @@ -795,11 +795,7 @@ VContainerData::VContainerData(const VTranslateVars *trVars, const Unit *pattern //--------------------------------------------------------------------------------------------------------------------- VContainerData::~VContainerData() { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) if (ref.loadRelaxed() == 0) -#else - if (ref.load() == 0) -#endif { --VContainer::copyCounter[nspace]; } diff --git a/src/libs/vpatterndb/vpassmark.cpp b/src/libs/vpatterndb/vpassmark.cpp index fb6c453a2..4233d3c17 100644 --- a/src/libs/vpatterndb/vpassmark.cpp +++ b/src/libs/vpatterndb/vpassmark.cpp @@ -367,7 +367,7 @@ auto CreateTMarkPassmark(const VPiecePassmarkData &passmarkData, const QLineF &l p2 = tmpLine.p2(); } - return {line, {LineCenter({p1, p2}), p2}, {p2, p1}}; + return {line, {QLineF(p1, p2).center(), p2}, {p2, p1}}; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vpatterndb/vpiece.cpp b/src/libs/vpatterndb/vpiece.cpp index 3daeac300..3612e74d8 100644 --- a/src/libs/vpatterndb/vpiece.cpp +++ b/src/libs/vpatterndb/vpiece.cpp @@ -1472,14 +1472,12 @@ void VPiece::DumpPiece(const VPiece &piece, const VContainer *data, const QStrin if (temp.open()) { #if defined(Q_OS_LINUX) -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) // On Linux, QTemporaryFile will attempt to create unnamed temporary // files. If that succeeds, open() will return true but exists() will be // false. If you call fileName() or any function that calls it, // QTemporaryFile will give the file a name, so most applications will // not see a difference. temp.fileName(); // call to create a file on disk -#endif #endif QJsonObject testCase{ {"bd", piece.DBToJson(data)}, @@ -1683,8 +1681,8 @@ auto VPiece::SeamAllowanceMirrorLine(const VContainer *data) const -> QLineF QRectF rec = QRectF(0, 0, INT_MAX, INT_MAX); rec.translate(-INT_MAX / 2.0, -INT_MAX / 2.0); - QLineF axis = QLineF(LineCenter(seamMirrorLine), - VGObject::BuildRay(LineCenter(seamMirrorLine), seamMirrorLine.angle() + 180, rec)); + QLineF axis = + QLineF(seamMirrorLine.center(), VGObject::BuildRay(seamMirrorLine.center(), seamMirrorLine.angle() + 180, rec)); QVector points; CastTo(SeamAllowancePoints(data), points); @@ -1698,8 +1696,7 @@ auto VPiece::SeamAllowanceMirrorLine(const VContainer *data) const -> QLineF const QPointF startPoint = intersections.constFirst(); std::reverse(points.begin(), points.end()); - axis = - QLineF(LineCenter(seamMirrorLine), VGObject::BuildRay(LineCenter(seamMirrorLine), seamMirrorLine.angle(), rec)); + axis = QLineF(seamMirrorLine.center(), VGObject::BuildRay(seamMirrorLine.center(), seamMirrorLine.angle(), rec)); intersections = VAbstractCurve::CurveIntersectLine(points, axis); if (intersections.isEmpty()) { diff --git a/src/libs/vpatterndb/vpiecenode_p.h b/src/libs/vpatterndb/vpiecenode_p.h index 50232a10d..d374efed4 100644 --- a/src/libs/vpatterndb/vpiecenode_p.h +++ b/src/libs/vpatterndb/vpiecenode_p.h @@ -35,9 +35,6 @@ #include "../ifc/exception/vexception.h" #include "../ifc/ifcdef.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) -#include "../vmisc/vdatastreamenum.h" -#endif QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Weffc++") @@ -107,12 +104,6 @@ private: static constexpr quint16 classVersion = 3; }; -// See https://stackoverflow.com/a/46719572/3045403 -#if __cplusplus < 201703L // C++17 -constexpr quint32 VPieceNodeData::streamHeader; // NOLINT(readability-redundant-declaration) -constexpr quint16 VPieceNodeData::classVersion; // NOLINT(readability-redundant-declaration) -#endif - //--------------------------------------------------------------------------------------------------------------------- inline VPieceNodeData::VPieceNodeData(quint32 id, Tool typeTool, bool reverse) : m_id(id), diff --git a/src/libs/vpatterndb/vtranslatevars.cpp b/src/libs/vpatterndb/vtranslatevars.cpp index 1154be62f..518b7428b 100644 --- a/src/libs/vpatterndb/vtranslatevars.cpp +++ b/src/libs/vpatterndb/vtranslatevars.cpp @@ -471,7 +471,7 @@ void VTranslateVars::TranslateNumbersToUser(QString &newFormula, QMap QPixmap { -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - if (const QPixmap *p = d->pixmapLabel->pixmap()) - { - return QPixmap(*p); - } - return QPixmap(); -#elif QT_VERSION < QT_VERSION_CHECK(6, 0, 0) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) return d->pixmapLabel->pixmap(Qt::ReturnByValue); #else return d->pixmapLabel->pixmap(); diff --git a/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp b/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp index 86556ef57..44f61c2e0 100644 --- a/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp +++ b/src/libs/vpropertyexplorer/plugins/vfilepropertyeditor.cpp @@ -32,16 +32,11 @@ #include #include #include +#include #include #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) -#include -#else -#include -#endif - VPE::VFileEditWidget::VFileEditWidget(QWidget *parent, bool is_directory) : QWidget(parent), CurrentFilePath(), @@ -256,14 +251,9 @@ auto VPE::VFileEditWidget::checkFileFilter(const QString &file) const -> bool return std::any_of(FilterList.begin(), FilterList.end(), [file](const QString &tmpFilter) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) const QString wildcardFilter = QRegularExpression::wildcardToRegularExpression(tmpFilter); QRegularExpression tmpRegExpFilter(QRegularExpression::anchoredPattern(wildcardFilter), QRegularExpression::CaseInsensitiveOption); return tmpRegExpFilter.match(file).hasMatch(); -#else - QRegExp tmpRegExpFilter(tmpFilter, Qt::CaseInsensitive, QRegExp::Wildcard); - return tmpRegExpFilter.exactMatch(file); -#endif }); } diff --git a/src/libs/vpropertyexplorer/plugins/vtextproperty.cpp b/src/libs/vpropertyexplorer/plugins/vtextproperty.cpp index 87387f1ba..895ba3762 100644 --- a/src/libs/vpropertyexplorer/plugins/vtextproperty.cpp +++ b/src/libs/vpropertyexplorer/plugins/vtextproperty.cpp @@ -18,8 +18,8 @@ ** *************************************************************************/ #include "vtextproperty.h" -#include "../vproperty_p.h" #include "../vmisc/compatibility.h" +#include "../vproperty_p.h" #include #include @@ -27,34 +27,28 @@ namespace { //--------------------------------------------------------------------------------------------------------------------- -void SetTabStopDistance(QPlainTextEdit *edit, int tabWidthChar=4); +void SetTabStopDistance(QPlainTextEdit *edit, int tabWidthChar = 4); void SetTabStopDistance(QPlainTextEdit *edit, int tabWidthChar) { const auto fontMetrics = edit->fontMetrics(); const QString testString(" "); -#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) - const int singleCharWidth = fontMetrics.width(testString); - edit->setTabStopWidth(tabWidthChar * singleCharWidth); -#else // compute the size of a char in double-precision static constexpr int bigNumber = 1000; // arbitrary big number. - const int many_char_width = TextWidth(fontMetrics, testString.repeated(bigNumber)); + const int many_char_width = fontMetrics.horizontalAdvance(testString.repeated(bigNumber)); const double singleCharWidthDouble = many_char_width / double(bigNumber); // set the tab stop with double precision edit->setTabStopDistance(tabWidthChar * singleCharWidthDouble); -#endif } -} - +} // namespace VPE::VTextProperty::VTextProperty(const QString &name, const QMap &settings) - : VProperty(name, + : VProperty(name, #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - QMetaType::QString), + QMetaType::QString), #else - QVariant::String), + QVariant::String), #endif readOnly(false) { @@ -68,7 +62,7 @@ VPE::VTextProperty::VTextProperty(const QString &name, const QMapVariantValue.setValue(QString()); @@ -85,7 +79,7 @@ auto VPE::VTextProperty::createEditor(QWidget *parent, const QStyleOptionViewIte Q_UNUSED(options) Q_UNUSED(delegate) - QPlainTextEdit* tmpEditor = new QPlainTextEdit(parent); + QPlainTextEdit *tmpEditor = new QPlainTextEdit(parent); tmpEditor->setLocale(parent->locale()); tmpEditor->setReadOnly(readOnly); tmpEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); @@ -98,7 +92,7 @@ auto VPE::VTextProperty::createEditor(QWidget *parent, const QStyleOptionViewIte auto VPE::VTextProperty::setEditorData(QWidget *editor) -> bool { - if (QPlainTextEdit* tmpWidget = qobject_cast(editor)) + if (QPlainTextEdit *tmpWidget = qobject_cast(editor)) { tmpWidget->setPlainText(d_ptr->VariantValue.toString()); return true; @@ -109,7 +103,7 @@ auto VPE::VTextProperty::setEditorData(QWidget *editor) -> bool auto VPE::VTextProperty::getEditorData(const QWidget *editor) const -> QVariant { - const QPlainTextEdit* tmpEditor = qobject_cast(editor); + const QPlainTextEdit *tmpEditor = qobject_cast(editor); if (tmpEditor) { return tmpEditor->toPlainText(); diff --git a/src/libs/vpropertyexplorer/vproperty.h b/src/libs/vpropertyexplorer/vproperty.h index 9e2a2f498..04ce63de2 100644 --- a/src/libs/vpropertyexplorer/vproperty.h +++ b/src/libs/vpropertyexplorer/vproperty.h @@ -35,9 +35,6 @@ #include #include "vpropertyexplorer_global.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) // Header is removed in C++20. #if __cplusplus <= 201703L diff --git a/src/libs/vpropertyexplorer/vpropertydef.cpp b/src/libs/vpropertyexplorer/vpropertydef.cpp index 8792aa8ef..84c473e84 100644 --- a/src/libs/vpropertyexplorer/vpropertydef.cpp +++ b/src/libs/vpropertyexplorer/vpropertydef.cpp @@ -69,11 +69,7 @@ auto VPELocaleSign0(const QLocale &locale) -> QChar const QString sign = locale.toString(0); if (sign.size() == 1) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return sign.front(); -#else - return sign.at(0); -#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -89,11 +85,7 @@ auto VPELocaleSign1(const QLocale &locale) -> QChar const QString sign = locale.toString(1); if (sign.size() == 1) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return sign.front(); -#else - return sign.at(0); -#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -109,11 +101,7 @@ auto VPELocaleSign2(const QLocale &locale) -> QChar const QString sign = locale.toString(2); if (sign.size() == 1) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return sign.front(); -#else - return sign.at(0); -#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -129,11 +117,7 @@ auto VPELocaleSign3(const QLocale &locale) -> QChar const QString sign = locale.toString(3); if (sign.size() == 1) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return sign.front(); -#else - return sign.at(0); -#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -149,11 +133,7 @@ auto VPELocaleSign4(const QLocale &locale) -> QChar const QString sign = locale.toString(4); if (sign.size() == 1) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return sign.front(); -#else - return sign.at(0); -#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -169,11 +149,7 @@ auto VPELocaleSign5(const QLocale &locale) -> QChar const QString sign = locale.toString(5); if (sign.size() == 1) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return sign.front(); -#else - return sign.at(0); -#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -189,11 +165,7 @@ auto VPELocaleSign6(const QLocale &locale) -> QChar const QString sign = locale.toString(6); if (sign.size() == 1) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return sign.front(); -#else - return sign.at(0); -#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -209,11 +181,7 @@ auto VPELocaleSign7(const QLocale &locale) -> QChar const QString sign = locale.toString(7); if (sign.size() == 1) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return sign.front(); -#else - return sign.at(0); -#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -229,11 +197,7 @@ auto VPELocaleSign8(const QLocale &locale) -> QChar const QString sign = locale.toString(8); if (sign.size() == 1) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return sign.front(); -#else - return sign.at(0); -#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) @@ -249,11 +213,7 @@ auto VPELocaleSign9(const QLocale &locale) -> QChar const QString sign = locale.toString(9); if (sign.size() == 1) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) return sign.front(); -#else - return sign.at(0); -#endif } #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) diff --git a/src/libs/vpropertyexplorer/vpropertyexplorer_global.h b/src/libs/vpropertyexplorer/vpropertyexplorer_global.h index 597b23967..9ec6be3a4 100644 --- a/src/libs/vpropertyexplorer/vpropertyexplorer_global.h +++ b/src/libs/vpropertyexplorer/vpropertyexplorer_global.h @@ -24,27 +24,19 @@ #include #if defined(VPROPERTYEXPLORER_LIBRARY) -# define VPROPERTYEXPLORERSHARED_EXPORT Q_DECL_EXPORT +#define VPROPERTYEXPLORERSHARED_EXPORT Q_DECL_EXPORT #else -# define VPROPERTYEXPLORERSHARED_EXPORT Q_DECL_IMPORT +#define VPROPERTYEXPLORERSHARED_EXPORT Q_DECL_IMPORT #endif #ifndef Q_DISABLE_ASSIGN -#define Q_DISABLE_ASSIGN(Class) \ - Class &operator=(const Class &) = delete; -#endif - -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#define Q_DISABLE_COPY_MOVE(Class) \ - Q_DISABLE_COPY(Class) \ - Class(Class &&) = delete; \ - Class &operator=(Class &&) = delete; +#define Q_DISABLE_ASSIGN(Class) Class &operator=(const Class &) = delete; #endif #ifndef Q_DISABLE_ASSIGN_MOVE -#define Q_DISABLE_ASSIGN_MOVE(Class) \ - Q_DISABLE_ASSIGN(Class) \ - Class(Class &&) = delete; \ +#define Q_DISABLE_ASSIGN_MOVE(Class) \ + Q_DISABLE_ASSIGN(Class) \ + Class(Class &&) = delete; \ Class &operator=(Class &&) = delete; #endif diff --git a/src/libs/vpropertyexplorer/vpropertyfactorymanager.h b/src/libs/vpropertyexplorer/vpropertyfactorymanager.h index 16cf728a5..f4ae6f418 100644 --- a/src/libs/vpropertyexplorer/vpropertyfactorymanager.h +++ b/src/libs/vpropertyexplorer/vpropertyfactorymanager.h @@ -28,10 +28,6 @@ #include "vpropertyexplorer_global.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace VPE { diff --git a/src/libs/vpropertyexplorer/vpropertytreeview.h b/src/libs/vpropertyexplorer/vpropertytreeview.h index 962b59b91..aaae10ba7 100644 --- a/src/libs/vpropertyexplorer/vpropertytreeview.h +++ b/src/libs/vpropertyexplorer/vpropertytreeview.h @@ -29,10 +29,6 @@ #include "vpropertyexplorer_global.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace VPE { diff --git a/src/libs/vtest/abstracttest.cpp b/src/libs/vtest/abstracttest.cpp index 02b52c1bb..383267ada 100644 --- a/src/libs/vtest/abstracttest.cpp +++ b/src/libs/vtest/abstracttest.cpp @@ -393,15 +393,7 @@ auto AbstractTest::TranslationsPath() -> QString //--------------------------------------------------------------------------------------------------------------------- auto AbstractTest::RunTimeout(int defMsecs) -> int { -#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) - QString timeout = QString::fromLocal8Bit(qgetenv("VTEST_RUN_TIMEOUT")); - if (timeout.isEmpty()) - { - return defMsecs; - } -#else QString timeout = qEnvironmentVariable("VTEST_RUN_TIMEOUT", QString::number(defMsecs)); -#endif bool ok = false; int msecs = timeout.toInt(&ok); diff --git a/src/libs/vtools/dialogs/dialogtoolbox.cpp b/src/libs/vtools/dialogs/dialogtoolbox.cpp index 172364c0b..980f8b10f 100644 --- a/src/libs/vtools/dialogs/dialogtoolbox.cpp +++ b/src/libs/vtools/dialogs/dialogtoolbox.cpp @@ -656,17 +656,12 @@ void SetTabStopDistance(QPlainTextEdit *edit, int tabWidthChar) const QString testString(" "); -#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) - const int single_char_width = fontMetrics.width(testString); - edit->setTabStopWidth(tabWidthChar * single_char_width); -#else // compute the size of a char in double-precision static constexpr int bigNumber = 1000; // arbitrary big number. - const int many_char_width = TextWidth(fontMetrics, testString.repeated(bigNumber)); + const int many_char_width = fontMetrics.horizontalAdvance(testString.repeated(bigNumber)); const double singleCharWidthDouble = many_char_width / double(bigNumber); // set the tab stop with double precision edit->setTabStopDistance(tabWidthChar * singleCharWidthDouble); -#endif } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index d226a1f96..ba30d16d2 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -45,10 +45,6 @@ #include "vabstractvalapplication.h" #include "vvalentinasettings.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - #include #include #include diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.h b/src/libs/vtools/dialogs/support/dialogeditlabel.h index d2ed13ad2..35fc0ea2d 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.h +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.h @@ -32,10 +32,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace Ui { class DialogEditLabel; diff --git a/src/libs/vtools/dialogs/support/dialogeditwrongformula.h b/src/libs/vtools/dialogs/support/dialogeditwrongformula.h index 20d022c73..fa5ce8efd 100644 --- a/src/libs/vtools/dialogs/support/dialogeditwrongformula.h +++ b/src/libs/vtools/dialogs/support/dialogeditwrongformula.h @@ -37,10 +37,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class VMeasurement; struct FormulaData; class VContainer; diff --git a/src/libs/vtools/dialogs/support/dialogundo.h b/src/libs/vtools/dialogs/support/dialogundo.h index cc56b239d..f7bc1e85f 100644 --- a/src/libs/vtools/dialogs/support/dialogundo.h +++ b/src/libs/vtools/dialogs/support/dialogundo.h @@ -35,10 +35,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace Ui { class DialogUndo; diff --git a/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp b/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp index f030c2471..053a46989 100644 --- a/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogcubicbezierpath.cpp @@ -41,16 +41,12 @@ #include #include #include -#include #include "../../visualization/path/vistoolcubicbezierpath.h" #include "../../visualization/visualization.h" #include "../ifc/ifcdef.h" -#include "../vmisc/vabstractapplication.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../qmuparser/qmudef.h" +#include "../vmisc/vabstractapplication.h" #include "../vpatterndb/vcontainer.h" #include "../vwidgets/vabstractmainwindow.h" #include "dialogtool.h" diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp index d4b4574b1..74f0fe0b9 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyaxis.cpp @@ -42,17 +42,12 @@ #include #include #include -#include +#include "../../tools/drawTools/operation/vabstractoperation.h" #include "../../visualization/line/operation/vistoolflippingbyaxis.h" #include "../../visualization/visualization.h" #include "../ifc/xml/vabstractpattern.h" -#include "../ifc/xml/vdomdocument.h" #include "../qmuparser/qmudef.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../../tools/drawTools/operation/vabstractoperation.h" #include "../vpatterndb/vcontainer.h" #include "../vwidgets/vmaingraphicsscene.h" #include "../vwidgets/vmaingraphicsview.h" diff --git a/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp b/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp index ecaa69e6a..1f85f692f 100644 --- a/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp +++ b/src/libs/vtools/dialogs/tools/dialogflippingbyline.cpp @@ -42,16 +42,12 @@ #include #include #include -#include +#include "../../tools/drawTools/operation/vabstractoperation.h" #include "../../visualization/line/operation/vistoolflippingbyline.h" #include "../../visualization/visualization.h" #include "../ifc/xml/vabstractpattern.h" #include "../qmuparser/qmudef.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../../tools/drawTools/operation/vabstractoperation.h" #include "../vpatterndb/vcontainer.h" #include "../vwidgets/vmaingraphicsscene.h" #include "../vwidgets/vmaingraphicsview.h" diff --git a/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp b/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp index 19253e59e..241a020bd 100644 --- a/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp +++ b/src/libs/vtools/dialogs/tools/dialoglineintersect.cpp @@ -39,16 +39,12 @@ #include #include #include -#include #include "../../visualization/line/vistoollineintersect.h" #include "../../visualization/visualization.h" #include "../ifc/xml/vabstractpattern.h" #include "../vgeometry/vpointf.h" #include "../vmisc/compatibility.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../vpatterndb/vcontainer.h" #include "dialogtool.h" #include "ui_dialoglineintersect.h" @@ -243,7 +239,7 @@ void DialogLineIntersect::PointNameChanged() QLineF line1(static_cast(*p1Line1), static_cast(*p2Line1)); QLineF line2(static_cast(*p1Line2), static_cast(*p2Line2)); QPointF fPoint; - QLineF::IntersectType intersect = Intersects(line1, line2, &fPoint); + QLineF::IntersectType intersect = line1.intersects(line2, &fPoint); flagError = not(set.size() < 3 || intersect == QLineF::NoIntersection); color = flagError ? OkColor(this) : errorColor; @@ -284,7 +280,7 @@ auto DialogLineIntersect::CheckIntersecion() -> bool QLineF line1(static_cast(*p1L1), static_cast(*p2L1)); QLineF line2(static_cast(*p1L2), static_cast(*p2L2)); QPointF fPoint; - QLineF::IntersectType intersect = Intersects(line1, line2, &fPoint); + QLineF::IntersectType intersect = line1.intersects(line2, &fPoint); return intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection; } catch (const VExceptionBadId &) diff --git a/src/libs/vtools/dialogs/tools/dialogmove.cpp b/src/libs/vtools/dialogs/tools/dialogmove.cpp index 28daf3d5a..2b9b45f73 100644 --- a/src/libs/vtools/dialogs/tools/dialogmove.cpp +++ b/src/libs/vtools/dialogs/tools/dialogmove.cpp @@ -63,10 +63,6 @@ #include "../vwidgets/vmaingraphicsview.h" #include "ui_dialogmove.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - //--------------------------------------------------------------------------------------------------------------------- DialogMove::DialogMove(const VContainer *data, VAbstractPattern *doc, quint32 toolId, QWidget *parent) : DialogTool(data, doc, toolId, parent), diff --git a/src/libs/vtools/dialogs/tools/dialogrotation.cpp b/src/libs/vtools/dialogs/tools/dialogrotation.cpp index 0daf0ce61..16ed9cb0a 100644 --- a/src/libs/vtools/dialogs/tools/dialogrotation.cpp +++ b/src/libs/vtools/dialogs/tools/dialogrotation.cpp @@ -65,10 +65,6 @@ #include "../vwidgets/vmaingraphicsview.h" #include "ui_dialogrotation.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - //--------------------------------------------------------------------------------------------------------------------- DialogRotation::DialogRotation(const VContainer *data, VAbstractPattern *doc, quint32 toolId, QWidget *parent) : DialogTool(data, doc, toolId, parent), diff --git a/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp b/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp index 4015db86b..f81131098 100644 --- a/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp +++ b/src/libs/vtools/dialogs/tools/dialogsplinepath.cpp @@ -44,7 +44,6 @@ #include #include #include -#include #include "../../visualization/path/vistoolsplinepath.h" #include "../../visualization/visualization.h" @@ -62,10 +61,6 @@ #include "../vwidgets/vmaingraphicsscene.h" #include "ui_dialogsplinepath.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - #if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) #include "../vmisc/compatibility.h" #endif diff --git a/src/libs/vtools/dialogs/tools/piece/dialoginsertnode.cpp b/src/libs/vtools/dialogs/tools/piece/dialoginsertnode.cpp index 6bc2e1fad..6cfc5daae 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialoginsertnode.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialoginsertnode.cpp @@ -29,9 +29,6 @@ #include "dialoginsertnode.h" #include "../vpatterndb/vcontainer.h" #include "ui_dialoginsertnode.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.h b/src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.h index 6771a3909..7ff22207b 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.h +++ b/src/libs/vtools/dialogs/tools/piece/dialogpatternmaterials.h @@ -31,10 +31,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - namespace Ui { class DialogPatternMaterials; diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp index b134cc130..fc4d754d3 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogpiecepath.cpp @@ -36,17 +36,8 @@ #include "../vpatterndb/vpiecenode.h" #include "ui_dialogpiecepath.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - -#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) -#include "../vmisc/backport/qscopeguard.h" -#else -#include -#endif - #include +#include #include namespace @@ -1337,16 +1328,8 @@ void DialogPiecePath::InitPassmarksTab() connect(ui->comboBoxPassmarks, QOverload::of(&QComboBox::currentIndexChanged), this, &DialogPiecePath::PassmarkChanged); -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - connect(ui->buttonGroupMarkType, QOverload::of(&QButtonGroup::buttonClicked), this, - &DialogPiecePath::PassmarkLineTypeChanged); - connect(ui->buttonGroupAngleType, QOverload::of(&QButtonGroup::buttonClicked), this, - &DialogPiecePath::PassmarkAngleTypeChanged); -#else connect(ui->buttonGroupMarkType, &QButtonGroup::idClicked, this, &DialogPiecePath::PassmarkLineTypeChanged); connect(ui->buttonGroupAngleType, &QButtonGroup::idClicked, this, &DialogPiecePath::PassmarkAngleTypeChanged); -#endif - connect(ui->checkBoxShowSecondPassmark, &QCheckBox::stateChanged, this, &DialogPiecePath::PassmarkShowSecondChanged); connect(ui->checkBoxClockwiseOpening, &QCheckBox::stateChanged, this, diff --git a/src/libs/vtools/dialogs/tools/piece/dialogpin.cpp b/src/libs/vtools/dialogs/tools/piece/dialogpin.cpp index 61c905224..b2e8b7428 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogpin.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogpin.cpp @@ -28,11 +28,8 @@ #include "dialogpin.h" #include "../../../visualization/line/vistoolspecialpoint.h" -#include "ui_dialogpin.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #include "../vpatterndb/vcontainer.h" +#include "ui_dialogpin.h" //--------------------------------------------------------------------------------------------------------------------- DialogPin::DialogPin(const VContainer *data, VAbstractPattern *doc, quint32 toolId, QWidget *parent) diff --git a/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp b/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp index faf986ead..613c00ee6 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogplacelabel.cpp @@ -33,10 +33,6 @@ #include "../vmisc/theme/vtheme.h" #include "../vpatterndb/vcontainer.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - #include //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp index 81c01de54..9794fa627 100644 --- a/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp +++ b/src/libs/vtools/dialogs/tools/piece/dialogseamallowance.cpp @@ -62,18 +62,9 @@ #include "ui_tabpins.h" #include "ui_tabplacelabels.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - -#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) -#include "../vmisc/backport/qscopeguard.h" -#else -#include -#endif - #include #include +#include #include #include #include @@ -4324,17 +4315,10 @@ void DialogSeamAllowance::InitPassmarksTab() connect(uiTabPassmarks->comboBoxPassmarks, QOverload::of(&QComboBox::currentIndexChanged), this, &DialogSeamAllowance::PassmarkChanged); -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - connect(uiTabPassmarks->buttonGroupLineType, QOverload::of(&QButtonGroup::buttonClicked), this, - &DialogSeamAllowance::PassmarkLineTypeChanged); - connect(uiTabPassmarks->buttonGroupAngleType, QOverload::of(&QButtonGroup::buttonClicked), this, - &DialogSeamAllowance::PassmarkAngleTypeChanged); -#else connect(uiTabPassmarks->buttonGroupLineType, &QButtonGroup::idClicked, this, &DialogSeamAllowance::PassmarkLineTypeChanged); connect(uiTabPassmarks->buttonGroupAngleType, &QButtonGroup::idClicked, this, &DialogSeamAllowance::PassmarkAngleTypeChanged); -#endif connect(uiTabPassmarks->checkBoxShowSecondPassmark, &QCheckBox::stateChanged, this, &DialogSeamAllowance::PassmarkShowSecondChanged); connect(uiTabPassmarks->checkBoxClockwiseOpening, &QCheckBox::stateChanged, this, diff --git a/src/libs/vtools/tools/backgroundimage/vbackgroundimagecontrols.h b/src/libs/vtools/tools/backgroundimage/vbackgroundimagecontrols.h index c4d85ae6e..d68be9a08 100644 --- a/src/libs/vtools/tools/backgroundimage/vbackgroundimagecontrols.h +++ b/src/libs/vtools/tools/backgroundimage/vbackgroundimagecontrols.h @@ -31,17 +31,18 @@ #include #include -#include "../vmisc/def.h" #include "../ifc/xml/vbackgroundpatternimage.h" - -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) +#include "../vmisc/def.h" class VAbstractPattern; class QScreen; -enum class BITransformationType {Scale, Rotate, Unknown}; +enum class BITransformationType +{ + Scale, + Rotate, + Unknown +}; enum class BIHandleCorner : int { @@ -71,12 +72,16 @@ enum class BIHandleCornerType class VBackgroundImageControls : public QGraphicsObject { Q_OBJECT // NOLINT + public: - explicit VBackgroundImageControls(VAbstractPattern *doc, QGraphicsItem * parent = nullptr); + explicit VBackgroundImageControls(VAbstractPattern *doc, QGraphicsItem *parent = nullptr); ~VBackgroundImageControls() override = default; - auto type() const -> int override {return Type;} - enum { Type = UserType + static_cast(Tool::BackgroundImageControls)}; + auto type() const -> int override { return Type; } + enum + { + Type = UserType + static_cast(Tool::BackgroundImageControls) + }; auto Id() const -> const QUuid &; @@ -85,7 +90,7 @@ signals: public slots: void ActivateControls(const QUuid &id); - void DeactivateControls(QGraphicsItem* item); + void DeactivateControls(QGraphicsItem *item); void UpdateControls(); protected: @@ -93,8 +98,8 @@ protected: auto shape() const -> QPainterPath override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; - void mousePressEvent(QGraphicsSceneMouseEvent * event) override; - void mouseMoveEvent(QGraphicsSceneMouseEvent * event) override; + void mousePressEvent(QGraphicsSceneMouseEvent *event) override; + void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override; @@ -167,14 +172,14 @@ private: auto RotateBottomRightControl() const -> QPainterPath; auto RotateBottomLeftControl() const -> QPainterPath; - auto ScaleByTopLeft(QGraphicsSceneMouseEvent * event) const -> QTransform; - auto ScaleByTop(QGraphicsSceneMouseEvent * event) const -> QTransform; - auto ScaleByTopRight(QGraphicsSceneMouseEvent * event) const -> QTransform; - auto ScaleByRight(QGraphicsSceneMouseEvent * event) const -> QTransform; - auto ScaleByBottomRight(QGraphicsSceneMouseEvent * event) const -> QTransform; - auto ScaleByBottom(QGraphicsSceneMouseEvent * event) const -> QTransform; - auto ScaleByBottomLeft(QGraphicsSceneMouseEvent * event) const -> QTransform; - auto ScaleByLeft(QGraphicsSceneMouseEvent * event) const -> QTransform; + auto ScaleByTopLeft(QGraphicsSceneMouseEvent *event) const -> QTransform; + auto ScaleByTop(QGraphicsSceneMouseEvent *event) const -> QTransform; + auto ScaleByTopRight(QGraphicsSceneMouseEvent *event) const -> QTransform; + auto ScaleByRight(QGraphicsSceneMouseEvent *event) const -> QTransform; + auto ScaleByBottomRight(QGraphicsSceneMouseEvent *event) const -> QTransform; + auto ScaleByBottom(QGraphicsSceneMouseEvent *event) const -> QTransform; + auto ScaleByBottomLeft(QGraphicsSceneMouseEvent *event) const -> QTransform; + auto ScaleByLeft(QGraphicsSceneMouseEvent *event) const -> QTransform; auto Handles() const -> QPainterPath; auto ControllersRect() const -> QRectF; @@ -188,8 +193,8 @@ private: auto OriginCircle2() const -> QPainterPath; auto OriginPath() const -> QPainterPath; - void ScaleImage(QGraphicsSceneMouseEvent * event); - void RotateImage(QGraphicsSceneMouseEvent * event); + void ScaleImage(QGraphicsSceneMouseEvent *event); + void RotateImage(QGraphicsSceneMouseEvent *event); void UpdateCursor(BIHandleCorner corner); }; diff --git a/src/libs/vtools/tools/backgroundimage/vbackgroundimageitem.h b/src/libs/vtools/tools/backgroundimage/vbackgroundimageitem.h index d23e4d4f5..cb4aebb2e 100644 --- a/src/libs/vtools/tools/backgroundimage/vbackgroundimageitem.h +++ b/src/libs/vtools/tools/backgroundimage/vbackgroundimageitem.h @@ -33,21 +33,21 @@ #include "../ifc/xml/vbackgroundpatternimage.h" #include "../vmisc/def.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - class VAbstractPattern; class VBackgroundImageItem : public QGraphicsObject { Q_OBJECT // NOLINT + public: VBackgroundImageItem(const VBackgroundPatternImage &image, VAbstractPattern *doc, QGraphicsItem *parent = nullptr); ~VBackgroundImageItem() override = default; - auto type() const -> int override {return Type;} - enum {Type = UserType + static_cast(Tool::BackgroundImage)}; + auto type() const -> int override { return Type; } + enum + { + Type = UserType + static_cast(Tool::BackgroundImage) + }; auto Image() const -> const VBackgroundPatternImage &; void SetImage(const VBackgroundPatternImage &newImage); @@ -88,15 +88,15 @@ public slots: protected: auto itemChange(GraphicsItemChange change, const QVariant &value) -> QVariant override; - void mousePressEvent( QGraphicsSceneMouseEvent * event) override; - void mouseMoveEvent ( QGraphicsSceneMouseEvent * event ) override; - void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) override; - void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) override; - void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ) override; + void mousePressEvent(QGraphicsSceneMouseEvent *event) override; + void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; + void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; + void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; + void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override; void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; - void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ) override; + void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override; void keyPressEvent(QKeyEvent *event) override; - void keyReleaseEvent(QKeyEvent * event) override; + void keyReleaseEvent(QKeyEvent *event) override; auto Stale() const -> bool; void MakeFresh() const; diff --git a/src/libs/vtools/tools/backgroundimage/vbackgroundpixmapitem.h b/src/libs/vtools/tools/backgroundimage/vbackgroundpixmapitem.h index 9da80e05d..b61d2acff 100644 --- a/src/libs/vtools/tools/backgroundimage/vbackgroundpixmapitem.h +++ b/src/libs/vtools/tools/backgroundimage/vbackgroundpixmapitem.h @@ -30,10 +30,6 @@ #include "vbackgroundimageitem.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - enum class ShapeMode { MaskShape, @@ -41,14 +37,18 @@ enum class ShapeMode HeuristicMaskShape }; -class VBackgroundPixmapItem : public VBackgroundImageItem // clazy:exclude=ctor-missing-parent-argument,missing-qobject-macro +class VBackgroundPixmapItem + : public VBackgroundImageItem // clazy:exclude=ctor-missing-parent-argument,missing-qobject-macro { public: VBackgroundPixmapItem(const VBackgroundPatternImage &image, VAbstractPattern *doc, QGraphicsItem *parent = nullptr); ~VBackgroundPixmapItem() override = default; - auto type() const -> int override {return Type;} - enum {Type = UserType + static_cast(Tool::BackgroundPixmapImage)}; + auto type() const -> int override { return Type; } + enum + { + Type = UserType + static_cast(Tool::BackgroundPixmapImage) + }; auto boundingRect() const -> QRectF override; auto shape() const -> QPainterPath override; diff --git a/src/libs/vtools/tools/backgroundimage/vbackgroundsvgitem.h b/src/libs/vtools/tools/backgroundimage/vbackgroundsvgitem.h index 6feea2281..bf9ebe5fa 100644 --- a/src/libs/vtools/tools/backgroundimage/vbackgroundsvgitem.h +++ b/src/libs/vtools/tools/backgroundimage/vbackgroundsvgitem.h @@ -30,21 +30,21 @@ #include "vbackgroundimageitem.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - class QSvgRenderer; class VBackgroundSVGItem : public VBackgroundImageItem { Q_OBJECT // NOLINT + public: VBackgroundSVGItem(const VBackgroundPatternImage &image, VAbstractPattern *doc, QGraphicsItem *parent = nullptr); ~VBackgroundSVGItem() override; - auto type() const -> int override {return Type;} - enum {Type = UserType + static_cast(Tool::BackgroundSVGImage)}; + auto type() const -> int override { return Type; } + enum + { + Type = UserType + static_cast(Tool::BackgroundSVGImage) + }; auto boundingRect() const -> QRectF override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp index d4f85351a..daec8de1f 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooltruedarts.cpp @@ -75,7 +75,7 @@ void VToolTrueDarts::FindPoint(const QPointF &baseLineP1, const QPointF &baseLin QLineF d2blP2(dartP2, baseLineP2); d2blP2.setAngle(d2blP2.angle() + degrees); - if (Intersects(QLineF(baseLineP1, d2blP2.p2()), d2d1, &p1) == QLineF::NoIntersection) + if (QLineF(baseLineP1, d2blP2.p2()).intersects(d2d1, &p1) == QLineF::NoIntersection) { p1 = QPointF(0, 0); p2 = QPointF(0, 0); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp index c3476b6f6..495b73879 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoollineintersectaxis.cpp @@ -184,7 +184,7 @@ auto VToolLineIntersectAxis::FindPoint(const QLineF &axis, const QLineF &line, Q SCASSERT(intersectionPoint != nullptr) QPointF fPoint; - QLineF::IntersectType intersect = Intersects(axis, line, &fPoint); + QLineF::IntersectType intersect = axis.intersects(line, &fPoint); if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp index 96689e25d..d20a18708 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoollineintersect.cpp @@ -143,7 +143,7 @@ auto VToolLineIntersect::Create(VToolLineIntersectInitData initData) -> VToolLin QLineF line1(static_cast(*p1Line1), static_cast(*p2Line1)); QLineF line2(static_cast(*p1Line2), static_cast(*p2Line2)); QPointF fPoint; - const QLineF::IntersectType intersect = Intersects(line1, line2, &fPoint); + const QLineF::IntersectType intersect = line1.intersects(line2, &fPoint); if (intersect == QLineF::NoIntersection) { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp index c96e5d951..85d65133a 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtooltriangle.cpp @@ -201,7 +201,7 @@ auto VToolTriangle::FindPoint(const QPointF &axisP1, const QPointF &axisP2, cons QLineF hypotenuse(firstPoint, secondPoint); QPointF startPoint; - QLineF::IntersectType intersect = Intersects(axis, hypotenuse, &startPoint); + QLineF::IntersectType intersect = axis.intersects(hypotenuse, &startPoint); if (intersect != QLineF::UnboundedIntersection && intersect != QLineF::BoundedIntersection) { diff --git a/src/libs/vtools/tools/vtoolseamallowance.cpp b/src/libs/vtools/tools/vtoolseamallowance.cpp index b679ddf71..0ebe70a82 100644 --- a/src/libs/vtools/tools/vtoolseamallowance.cpp +++ b/src/libs/vtools/tools/vtoolseamallowance.cpp @@ -75,10 +75,6 @@ #include "qpainterpath.h" #include "toolsdef.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) -#include "../vmisc/backport/qoverload.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) - #include #include #include @@ -93,16 +89,7 @@ #include #include -#if (defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) -// DO NOT WORK WITH GCC 4.8 -#else -#if __cplusplus >= 201402L using namespace std::chrono_literals; -#else -#include "../vmisc/bpstd/chrono.hpp" -using namespace bpstd::literals::chrono_literals; -#endif // __cplusplus >= 201402L -#endif //(defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) // Current version of seam allowance tag need for backward compatibility const quint8 VToolSeamAllowance::pieceVersion = 2; @@ -1862,7 +1849,7 @@ void VToolSeamAllowance::RefreshGeometry(bool updateChildren) if (VAbstractApplication::VApp()->IsAppInGUIMode()) { - QTimer::singleShot(V_MSECONDS(100), Qt::CoarseTimer, this, + QTimer::singleShot(100ms, Qt::CoarseTimer, this, [this, updateChildren]() { this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); diff --git a/src/libs/vtools/undocommands/image/addbackgroundimage.h b/src/libs/vtools/undocommands/image/addbackgroundimage.h index 0492e3c32..8a1506814 100644 --- a/src/libs/vtools/undocommands/image/addbackgroundimage.h +++ b/src/libs/vtools/undocommands/image/addbackgroundimage.h @@ -28,24 +28,22 @@ #ifndef ADDBACKGROUNDIMAGE_H #define ADDBACKGROUNDIMAGE_H -#include "../vundocommand.h" #include "../ifc/xml/vbackgroundpatternimage.h" - -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) +#include "../vundocommand.h" class AddBackgroundImage : public VUndoCommand { Q_OBJECT // NOLINT + public: - AddBackgroundImage(const VBackgroundPatternImage& image, VAbstractPattern *doc, QUndoCommand *parent = nullptr); - ~AddBackgroundImage() override =default; + AddBackgroundImage(const VBackgroundPatternImage &image, VAbstractPattern *doc, QUndoCommand *parent = nullptr); + ~AddBackgroundImage() override = default; void undo() override; void redo() override; signals: void AddItem(const QUuid &id); void DeleteItem(const QUuid &id); + private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(AddBackgroundImage) // NOLINT diff --git a/src/libs/vtools/undocommands/image/deletebackgroundimage.h b/src/libs/vtools/undocommands/image/deletebackgroundimage.h index 47d724ea8..3f2a07b4a 100644 --- a/src/libs/vtools/undocommands/image/deletebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/deletebackgroundimage.h @@ -28,25 +28,22 @@ #ifndef DELETEBACKGROUNDIMAGE_H #define DELETEBACKGROUNDIMAGE_H -#include "../vundocommand.h" #include "../ifc/xml/vbackgroundpatternimage.h" - -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - +#include "../vundocommand.h" class DeleteBackgroundImage : public VUndoCommand { Q_OBJECT // NOLINT + public: - DeleteBackgroundImage(const VBackgroundPatternImage& image, VAbstractPattern *doc, QUndoCommand *parent = nullptr); - ~DeleteBackgroundImage() override =default; + DeleteBackgroundImage(const VBackgroundPatternImage &image, VAbstractPattern *doc, QUndoCommand *parent = nullptr); + ~DeleteBackgroundImage() override = default; void undo() override; void redo() override; signals: void AddItem(const QUuid &id); void DeleteItem(const QUuid &id); + private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(DeleteBackgroundImage) // NOLINT diff --git a/src/libs/vtools/undocommands/image/hideallbackgroundimages.h b/src/libs/vtools/undocommands/image/hideallbackgroundimages.h index ec02153ae..04d3bf030 100644 --- a/src/libs/vtools/undocommands/image/hideallbackgroundimages.h +++ b/src/libs/vtools/undocommands/image/hideallbackgroundimages.h @@ -30,19 +30,16 @@ #include "../vundocommand.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - - class HideAllBackgroundImages : public VUndoCommand { Q_OBJECT // NOLINT + public: HideAllBackgroundImages(bool hide, VAbstractPattern *doc, QUndoCommand *parent = nullptr); - ~HideAllBackgroundImages() override =default; + ~HideAllBackgroundImages() override = default; void undo() override; void redo() override; + private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(HideAllBackgroundImages) // NOLINT diff --git a/src/libs/vtools/undocommands/image/hidebackgroundimage.h b/src/libs/vtools/undocommands/image/hidebackgroundimage.h index d9ebd27a3..64d22322d 100644 --- a/src/libs/vtools/undocommands/image/hidebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/hidebackgroundimage.h @@ -30,19 +30,16 @@ #include "../vundocommand.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - - class HideBackgroundImage : public VUndoCommand { Q_OBJECT // NOLINT + public: HideBackgroundImage(QUuid id, bool hide, VAbstractPattern *doc, QUndoCommand *parent = nullptr); - ~HideBackgroundImage() override =default; + ~HideBackgroundImage() override = default; void undo() override; void redo() override; + private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(HideBackgroundImage) // NOLINT diff --git a/src/libs/vtools/undocommands/image/holdallbackgroundimages.h b/src/libs/vtools/undocommands/image/holdallbackgroundimages.h index 93a455cf9..b6da2a8e3 100644 --- a/src/libs/vtools/undocommands/image/holdallbackgroundimages.h +++ b/src/libs/vtools/undocommands/image/holdallbackgroundimages.h @@ -30,18 +30,16 @@ #include "../vundocommand.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - class HoldAllBackgroundImages : public VUndoCommand { Q_OBJECT // NOLINT + public: HoldAllBackgroundImages(bool hold, VAbstractPattern *doc, QUndoCommand *parent = nullptr); - ~HoldAllBackgroundImages() override =default; + ~HoldAllBackgroundImages() override = default; void undo() override; void redo() override; + private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(HoldAllBackgroundImages) // NOLINT diff --git a/src/libs/vtools/undocommands/image/holdbackgroundimage.h b/src/libs/vtools/undocommands/image/holdbackgroundimage.h index 7a60f3228..c412d8950 100644 --- a/src/libs/vtools/undocommands/image/holdbackgroundimage.h +++ b/src/libs/vtools/undocommands/image/holdbackgroundimage.h @@ -30,19 +30,16 @@ #include "../vundocommand.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - - class HoldBackgroundImage : public VUndoCommand { Q_OBJECT // NOLINT + public: HoldBackgroundImage(QUuid id, bool hold, VAbstractPattern *doc, QUndoCommand *parent = nullptr); - ~HoldBackgroundImage() override =default; + ~HoldBackgroundImage() override = default; void undo() override; - void redo() override; + void redo() override; + private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(HoldBackgroundImage) // NOLINT diff --git a/src/libs/vtools/undocommands/image/movebackgroundimage.h b/src/libs/vtools/undocommands/image/movebackgroundimage.h index 1ba14395a..a873a180b 100644 --- a/src/libs/vtools/undocommands/image/movebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/movebackgroundimage.h @@ -33,13 +33,10 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - class MoveBackgroundImage : public VUndoCommand { Q_OBJECT // NOLINT + public: MoveBackgroundImage(QUuid id, qreal dx, qreal dy, VAbstractPattern *doc, bool allowMerge = false, QUndoCommand *parent = nullptr); diff --git a/src/libs/vtools/undocommands/image/opaquebackgroundimage.h b/src/libs/vtools/undocommands/image/opaquebackgroundimage.h index f483bbabb..315758ff8 100644 --- a/src/libs/vtools/undocommands/image/opaquebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/opaquebackgroundimage.h @@ -30,18 +30,16 @@ #include "../vundocommand.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - class OpaqueBackgroundImage : public VUndoCommand { Q_OBJECT // NOLINT + public: OpaqueBackgroundImage(QUuid id, qreal opacity, VAbstractPattern *doc, QUndoCommand *parent = nullptr); - ~OpaqueBackgroundImage() override =default; + ~OpaqueBackgroundImage() override = default; void undo() override; void redo() override; + private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(OpaqueBackgroundImage) // NOLINT diff --git a/src/libs/vtools/undocommands/image/renamebackgroundimage.h b/src/libs/vtools/undocommands/image/renamebackgroundimage.h index 74b2b053b..fd53b25c9 100644 --- a/src/libs/vtools/undocommands/image/renamebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/renamebackgroundimage.h @@ -30,19 +30,16 @@ #include "../vundocommand.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - - class RenameBackgroundImage : public VUndoCommand { Q_OBJECT // NOLINT + public: RenameBackgroundImage(QUuid id, const QString &name, VAbstractPattern *doc, QUndoCommand *parent = nullptr); - ~RenameBackgroundImage() override =default; + ~RenameBackgroundImage() override = default; void undo() override; void redo() override; + private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(RenameBackgroundImage) // NOLINT diff --git a/src/libs/vtools/undocommands/image/resetbackgroundimage.h b/src/libs/vtools/undocommands/image/resetbackgroundimage.h index 027cad5a9..5be105e52 100644 --- a/src/libs/vtools/undocommands/image/resetbackgroundimage.h +++ b/src/libs/vtools/undocommands/image/resetbackgroundimage.h @@ -33,13 +33,10 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - class ResetBackgroundImage : public VUndoCommand { Q_OBJECT // NOLINT + public: ResetBackgroundImage(QUuid id, VAbstractPattern *doc, QUndoCommand *parent = nullptr); ~ResetBackgroundImage() override = default; diff --git a/src/libs/vtools/undocommands/image/rotatebackgroundimage.h b/src/libs/vtools/undocommands/image/rotatebackgroundimage.h index 2188c49bd..30b5cfff3 100644 --- a/src/libs/vtools/undocommands/image/rotatebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/rotatebackgroundimage.h @@ -33,14 +33,10 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - - class RotateBackgroundImage : public VUndoCommand { Q_OBJECT // NOLINT + public: RotateBackgroundImage(QUuid id, const QTransform &matrix, VAbstractPattern *doc, bool allowMerge = false, QUndoCommand *parent = nullptr); diff --git a/src/libs/vtools/undocommands/image/scalebackgroundimage.h b/src/libs/vtools/undocommands/image/scalebackgroundimage.h index 8c869dd80..aed0a5bdd 100644 --- a/src/libs/vtools/undocommands/image/scalebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/scalebackgroundimage.h @@ -33,14 +33,10 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - - class ScaleBackgroundImage : public VUndoCommand { Q_OBJECT // NOLINT + public: ScaleBackgroundImage(QUuid id, const QTransform &matrix, VAbstractPattern *doc, bool allowMerge = false, QUndoCommand *parent = nullptr); diff --git a/src/libs/vtools/undocommands/image/zvaluemovebackgroundimage.h b/src/libs/vtools/undocommands/image/zvaluemovebackgroundimage.h index e685bb330..99dc0031d 100644 --- a/src/libs/vtools/undocommands/image/zvaluemovebackgroundimage.h +++ b/src/libs/vtools/undocommands/image/zvaluemovebackgroundimage.h @@ -30,10 +30,6 @@ #include "../vundocommand.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - enum class ZValueMoveType { Top, @@ -45,11 +41,13 @@ enum class ZValueMoveType class ZValueMoveBackgroundImage : public VUndoCommand { Q_OBJECT // NOLINT + public: ZValueMoveBackgroundImage(QUuid id, ZValueMoveType move, VAbstractPattern *doc, QUndoCommand *parent = nullptr); - ~ZValueMoveBackgroundImage() override =default; + ~ZValueMoveBackgroundImage() override = default; void undo() override; void redo() override; + private: // cppcheck-suppress unknownMacro Q_DISABLE_COPY_MOVE(ZValueMoveBackgroundImage) // NOLINT diff --git a/src/libs/vtools/visualization/line/vistoolheight.cpp b/src/libs/vtools/visualization/line/vistoolheight.cpp index 0e956ca39..9053fb76e 100644 --- a/src/libs/vtools/visualization/line/vistoolheight.cpp +++ b/src/libs/vtools/visualization/line/vistoolheight.cpp @@ -109,7 +109,7 @@ void VisToolHeight::VisualMode(quint32 id) void VisToolHeight::ShowIntersection(const QLineF &height_line, const QLineF &base_line) { QPointF p; - QLineF::IntersectType intersect = Intersects(height_line, base_line, &p); + QLineF::IntersectType intersect = height_line.intersects(base_line, &p); if (intersect == QLineF::UnboundedIntersection) { diff --git a/src/libs/vtools/visualization/line/vistoollineintersect.cpp b/src/libs/vtools/visualization/line/vistoollineintersect.cpp index 3f14e90d9..9998234b9 100644 --- a/src/libs/vtools/visualization/line/vistoollineintersect.cpp +++ b/src/libs/vtools/visualization/line/vistoollineintersect.cpp @@ -88,7 +88,7 @@ void VisToolLineIntersect::RefreshGeometry() QLineF l1(static_cast(*first), static_cast(*second)); QLineF l2(static_cast(*third), ScenePos()); QPointF fPoint; - QLineF::IntersectType intersect = Intersects(l1, l2, &fPoint); + QLineF::IntersectType intersect = l1.intersects(l2, &fPoint); if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) { @@ -105,7 +105,7 @@ void VisToolLineIntersect::RefreshGeometry() QLineF l1(static_cast(*first), static_cast(*second)); QLineF l2(static_cast(*third), static_cast(*forth)); QPointF fPoint; - QLineF::IntersectType intersect = Intersects(l1, l2, &fPoint); + QLineF::IntersectType intersect = l1.intersects(l2, &fPoint); if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) { diff --git a/src/libs/vtools/visualization/line/vistoollineintersectaxis.cpp b/src/libs/vtools/visualization/line/vistoollineintersectaxis.cpp index 620d3171a..d4c8c88e2 100644 --- a/src/libs/vtools/visualization/line/vistoollineintersectaxis.cpp +++ b/src/libs/vtools/visualization/line/vistoollineintersectaxis.cpp @@ -143,7 +143,7 @@ void VisToolLineIntersectAxis::SetAngle(const QString &expression) void VisToolLineIntersectAxis::ShowIntersection(const QLineF &axis_line, const QLineF &base_line) { QPointF p; - QLineF::IntersectType intersect = Intersects(axis_line, base_line, &p); + QLineF::IntersectType intersect = axis_line.intersects(base_line, &p); if (intersect == QLineF::UnboundedIntersection) { diff --git a/src/libs/vtools/visualization/line/vistoolpointofintersection.cpp b/src/libs/vtools/visualization/line/vistoolpointofintersection.cpp index 92cc1550f..5130d39f1 100644 --- a/src/libs/vtools/visualization/line/vistoolpointofintersection.cpp +++ b/src/libs/vtools/visualization/line/vistoolpointofintersection.cpp @@ -99,7 +99,7 @@ void VisToolPointOfIntersection::VisualMode(quint32 id) void VisToolPointOfIntersection::ShowIntersection(const QLineF &axis1, const QLineF &axis2) { QPointF p; - QLineF::IntersectType intersect = Intersects(axis1, axis2, &p); + QLineF::IntersectType intersect = axis1.intersects(axis2, &p); if (intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection) { diff --git a/src/libs/vtools/visualization/path/vistoolarc.h b/src/libs/vtools/visualization/path/vistoolarc.h index 89e9a0ab9..e300680ff 100644 --- a/src/libs/vtools/visualization/path/vistoolarc.h +++ b/src/libs/vtools/visualization/path/vistoolarc.h @@ -36,9 +36,6 @@ #include #include "../vmisc/def.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif #include "vispath.h" class VisToolArc final : public VisPath diff --git a/src/libs/vtools/visualization/path/vistoolarcwithlength.h b/src/libs/vtools/visualization/path/vistoolarcwithlength.h index 004e4df05..a2a987c72 100644 --- a/src/libs/vtools/visualization/path/vistoolarcwithlength.h +++ b/src/libs/vtools/visualization/path/vistoolarcwithlength.h @@ -37,9 +37,6 @@ #include "../vmisc/def.h" #include "vispath.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif class VisToolArcWithLength final : public VisPath { diff --git a/src/libs/vtools/visualization/path/vistoolspline.h b/src/libs/vtools/visualization/path/vistoolspline.h index f17b5d134..4c476f179 100644 --- a/src/libs/vtools/visualization/path/vistoolspline.h +++ b/src/libs/vtools/visualization/path/vistoolspline.h @@ -29,7 +29,6 @@ #ifndef VISTOOLSPLINE_H #define VISTOOLSPLINE_H - #include #include #include @@ -41,15 +40,12 @@ #include "../vmisc/def.h" #include "vispath.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - class VControlPointSpline; class VisToolSpline : public VisPath // clazy:exclude=ctor-missing-parent-argument { Q_OBJECT // NOLINT + public: explicit VisToolSpline(const VContainer *data, QGraphicsItem *parent = nullptr); ~VisToolSpline() override; @@ -68,23 +64,26 @@ public: auto GetP2() const -> QPointF; auto GetP3() const -> QPointF; - auto type() const -> int override {return Type;} - enum {Type = UserType + static_cast(Vis::ToolSpline)}; + auto type() const -> int override { return Type; } + enum + { + Type = UserType + static_cast(Vis::ToolSpline) + }; public slots: void MouseLeftPressed(); void MouseLeftReleased(); private: Q_DISABLE_COPY_MOVE(VisToolSpline) // NOLINT - quint32 m_point1Id{NULL_ID}; - quint32 m_point4Id{NULL_ID}; + quint32 m_point1Id{NULL_ID}; + quint32 m_point4Id{NULL_ID}; VScaledEllipse *m_point1{nullptr}; VScaledEllipse *m_point4{nullptr}; - qreal m_angle1; - qreal m_angle2; - qreal m_kAsm1{1}; - qreal m_kAsm2{1}; - qreal m_kCurve{1}; + qreal m_angle1; + qreal m_angle2; + qreal m_kAsm1{1}; + qreal m_kAsm2{1}; + qreal m_kCurve{1}; bool m_isLeftMousePressed{false}; bool m_p2Selected{false}; diff --git a/src/libs/vtools/visualization/path/vistoolsplinepath.h b/src/libs/vtools/visualization/path/vistoolsplinepath.h index 483d98022..d2e48b7c5 100644 --- a/src/libs/vtools/visualization/path/vistoolsplinepath.h +++ b/src/libs/vtools/visualization/path/vistoolsplinepath.h @@ -29,7 +29,6 @@ #ifndef VISTOOLSPLINEPATH_H #define VISTOOLSPLINEPATH_H - #include #include #include @@ -42,15 +41,12 @@ #include "../vmisc/def.h" #include "vispath.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif // QT_VERSION < QT_VERSION_CHECK(5, 13, 0) - class VControlPointSpline; class VisToolSplinePath : public VisPath // clazy:exclude=ctor-missing-parent-argument { Q_OBJECT // NOLINT + public: explicit VisToolSplinePath(const VContainer *data, QGraphicsItem *parent = nullptr); ~VisToolSplinePath() override; @@ -61,8 +57,11 @@ public: void SetPath(const VSplinePath &value); auto GetPath() -> VSplinePath; - auto type() const -> int override {return Type;} - enum {Type = UserType + static_cast(Vis::ToolSplinePath)}; + auto type() const -> int override { return Type; } + enum + { + Type = UserType + static_cast(Vis::ToolSplinePath) + }; signals: void PathChanged(const VSplinePath &path); @@ -72,17 +71,17 @@ public slots: private: Q_DISABLE_COPY_MOVE(VisToolSplinePath) // NOLINT - QVector m_points{}; + QVector m_points{}; QVector m_ctrlPoints{}; - VCurvePathItem* m_newCurveSegment{nullptr}; - VSplinePath m_path{}; + VCurvePathItem *m_newCurveSegment{nullptr}; + VSplinePath m_path{}; bool m_isLeftMousePressed{false}; bool m_pointSelected{false}; QPointF m_ctrlPoint{}; - auto GetPoint(quint32 i) -> VScaledEllipse*; + auto GetPoint(quint32 i) -> VScaledEllipse *; void DragControlPoint(vsizetype lastPoint, vsizetype preLastPoint, const QPointF &pSpl, vsizetype size); void NewCurveSegment(const VSpline &spline, const QPointF &pSpl, vsizetype size); void Creating(const QPointF &pSpl, vsizetype size); diff --git a/src/libs/vwidgets/fancytabbar/fancytab.h b/src/libs/vwidgets/fancytabbar/fancytab.h index ed53d4f7e..5614133f2 100644 --- a/src/libs/vwidgets/fancytabbar/fancytab.h +++ b/src/libs/vwidgets/fancytabbar/fancytab.h @@ -33,10 +33,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class FancyTab final : public QObject { friend class FancyTabBar; diff --git a/src/libs/vwidgets/fancytabbar/fancytabbar.cpp b/src/libs/vwidgets/fancytabbar/fancytabbar.cpp index 374ff4e7c..49837ff9f 100644 --- a/src/libs/vwidgets/fancytabbar/fancytabbar.cpp +++ b/src/libs/vwidgets/fancytabbar/fancytabbar.cpp @@ -95,7 +95,7 @@ auto FancyTabBar::TabSizeHint(bool minimum) const -> QSize { sentence = sentence.isEmpty() ? sentence = word : sentence + ' '_L1 + word; - const int width = TextWidth(fm, sentence); + const int width = fm.horizontalAdvance(sentence); if (maxLabelwidth < width) { maxLabelwidth = width; @@ -105,7 +105,7 @@ auto FancyTabBar::TabSizeHint(bool minimum) const -> QSize } else { - const int width = TextWidth(fm, tabText); + const int width = fm.horizontalAdvance(tabText); if (width > maxLabelwidth) { maxLabelwidth = width; diff --git a/src/libs/vwidgets/qtcolorpicker.h b/src/libs/vwidgets/qtcolorpicker.h index f9306f30b..5d1533669 100644 --- a/src/libs/vwidgets/qtcolorpicker.h +++ b/src/libs/vwidgets/qtcolorpicker.h @@ -46,17 +46,13 @@ #ifndef QTCOLORPICKER_H #define QTCOLORPICKER_H -#include -#include -#include +#include #include #include +#include #include - -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif +#include class ColorPickerPopup; class ColorPickerItem; diff --git a/src/libs/vwidgets/vabstractmainwindow.cpp b/src/libs/vwidgets/vabstractmainwindow.cpp index f628bf6f7..fa4e7474a 100644 --- a/src/libs/vwidgets/vabstractmainwindow.cpp +++ b/src/libs/vwidgets/vabstractmainwindow.cpp @@ -414,7 +414,7 @@ void VAbstractMainWindow::ExportDataToCSV() //--------------------------------------------------------------------------------------------------------------------- void VAbstractMainWindow::AlwaysOnTop(bool state) { - SetWindowFlag(this, Qt::WindowStaysOnTopHint, state); + this->setWindowFlag(Qt::WindowStaysOnTopHint, state); destroy(); create(); setVisible(true); diff --git a/src/libs/vwidgets/vabstractmainwindow.h b/src/libs/vwidgets/vabstractmainwindow.h index 11708f931..ef4c671d5 100644 --- a/src/libs/vwidgets/vabstractmainwindow.h +++ b/src/libs/vwidgets/vabstractmainwindow.h @@ -34,10 +34,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - struct VFinalMeasurement; QT_WARNING_PUSH diff --git a/src/libs/vwidgets/vaspectratiopixmaplabel.h b/src/libs/vwidgets/vaspectratiopixmaplabel.h index 194bb0014..52e490b9b 100644 --- a/src/libs/vwidgets/vaspectratiopixmaplabel.h +++ b/src/libs/vwidgets/vaspectratiopixmaplabel.h @@ -31,10 +31,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class VAspectRatioPixmapLabel : public QLabel { Q_OBJECT // NOLINT diff --git a/src/libs/vwidgets/vcomboboxdelegate.h b/src/libs/vwidgets/vcomboboxdelegate.h index ff44f0072..da5867b68 100644 --- a/src/libs/vwidgets/vcomboboxdelegate.h +++ b/src/libs/vwidgets/vcomboboxdelegate.h @@ -30,10 +30,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class VComboBoxDelegate : public QItemDelegate { Q_OBJECT // NOLINT diff --git a/src/libs/vwidgets/vdecorationaligningdelegate.h b/src/libs/vwidgets/vdecorationaligningdelegate.h index aeb6a1788..36e60f0a1 100644 --- a/src/libs/vwidgets/vdecorationaligningdelegate.h +++ b/src/libs/vwidgets/vdecorationaligningdelegate.h @@ -30,10 +30,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class VDecorationAligningDelegate : public QStyledItemDelegate { Q_OBJECT // NOLINT diff --git a/src/libs/vwidgets/velidedlabel.h b/src/libs/vwidgets/velidedlabel.h index c574b2fc2..4b12d3555 100644 --- a/src/libs/vwidgets/velidedlabel.h +++ b/src/libs/vwidgets/velidedlabel.h @@ -30,10 +30,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class VElidedLabel : public QFrame { Q_OBJECT // NOLINT diff --git a/src/libs/vwidgets/vlineedit.cpp b/src/libs/vwidgets/vlineedit.cpp index 9d114b6e2..387670967 100644 --- a/src/libs/vwidgets/vlineedit.cpp +++ b/src/libs/vwidgets/vlineedit.cpp @@ -37,16 +37,7 @@ #include "../vmisc/defglobal.h" -#if (defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) -// DO NOT WORK WITH GCC 4.8 -#else -#if __cplusplus >= 201402L using namespace std::chrono_literals; -#else -#include "../vmisc/bpstd/chrono.hpp" -using namespace bpstd::literals::chrono_literals; -#endif // __cplusplus >= 201402L -#endif //(defined(Q_CC_GNU) && Q_CC_GNU < 409) && !defined(Q_CC_CLANG) #if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) #include "../vmisc/compatibility.h" @@ -193,7 +184,7 @@ void VCompleterLineEdit::ShowCompletion() if (text().isEmpty()) { // completion list will be hidden now; we will show it again after a delay - QTimer::singleShot(V_MSECONDS(100), this, &VCompleterLineEdit::CompletionPopup); + QTimer::singleShot(100ms, this, &VCompleterLineEdit::CompletionPopup); } } diff --git a/src/libs/vwidgets/vlineedit.h b/src/libs/vwidgets/vlineedit.h index 4c09023f2..d44b86e25 100644 --- a/src/libs/vwidgets/vlineedit.h +++ b/src/libs/vwidgets/vlineedit.h @@ -31,10 +31,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class QStringListModel; class VLineEdit : public QLineEdit diff --git a/src/libs/vwidgets/vmaingraphicsview.h b/src/libs/vwidgets/vmaingraphicsview.h index 18c146b4e..e4bd8fc12 100644 --- a/src/libs/vwidgets/vmaingraphicsview.h +++ b/src/libs/vwidgets/vmaingraphicsview.h @@ -38,10 +38,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - /*! * This class adds ability to zoom QGraphicsView using mouse wheel. The point under cursor * remains motionless while it's possible. diff --git a/src/libs/vwidgets/vpiecegrainline.cpp b/src/libs/vwidgets/vpiecegrainline.cpp index 767644555..a3f5c4578 100644 --- a/src/libs/vwidgets/vpiecegrainline.cpp +++ b/src/libs/vwidgets/vpiecegrainline.cpp @@ -140,7 +140,7 @@ void VPieceGrainline::SetEnabled(bool enabled) auto VPieceGrainline::SecondaryLine() const -> QLineF { const QLineF mainLine = GetMainLine(); - const QPointF center = LineCenter(mainLine); + const QPointF center = mainLine.center(); QTransform t; t.translate(center.x(), center.y()); t.rotate(90); diff --git a/src/libs/vwidgets/vpiecegrainline_p.h b/src/libs/vwidgets/vpiecegrainline_p.h index 4603e994c..12e41e4f7 100644 --- a/src/libs/vwidgets/vpiecegrainline_p.h +++ b/src/libs/vwidgets/vpiecegrainline_p.h @@ -34,10 +34,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) -#include "../vmisc/vdatastreamenum.h" -#endif - QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Weffc++") QT_WARNING_DISABLE_GCC("-Wnon-virtual-dtor") @@ -69,12 +65,6 @@ private: QT_WARNING_POP -// See https://stackoverflow.com/a/46719572/3045403 -#if __cplusplus < 201703L // C++17 -constexpr quint32 VPieceGrainlinePrivate::streamHeader; // NOLINT(readability-redundant-declaration) -constexpr quint16 VPieceGrainlinePrivate::classVersion; // NOLINT(readability-redundant-declaration) -#endif - //--------------------------------------------------------------------------------------------------------------------- inline VPieceGrainlinePrivate::VPieceGrainlinePrivate(const QLineF &mainLine, GrainlineArrowDirection arrowType) : m_mainLine(mainLine), diff --git a/src/libs/vwidgets/vtextgraphicsitem.cpp b/src/libs/vwidgets/vtextgraphicsitem.cpp index c5f8e770b..72169281b 100644 --- a/src/libs/vwidgets/vtextgraphicsitem.cpp +++ b/src/libs/vwidgets/vtextgraphicsitem.cpp @@ -796,11 +796,11 @@ void VTextGraphicsItem::PaintLabelOutlineFont(QPainter *painter) } else if ((tl.m_eAlign & Qt::AlignHCenter) > 0) { - dX = (boundingRect.width() - TextWidth(fm, qsText)) / 2; + dX = (boundingRect.width() - fm.horizontalAdvance(qsText)) / 2; } else if ((tl.m_eAlign & Qt::AlignRight) > 0) { - dX = boundingRect.width() - TextWidth(fm, qsText); + dX = boundingRect.width() - fm.horizontalAdvance(qsText); } VSingleLineOutlineChar const corrector(fnt); @@ -814,7 +814,7 @@ void VTextGraphicsItem::PaintLabelOutlineFont(QPainter *painter) for (auto c : qAsConst(qsText)) { path.addPath(corrector.DrawChar(w, static_cast(fm.ascent()), c)); - w += TextWidth(fm, c); + w += fm.horizontalAdvance(c); } QTransform matrix; diff --git a/src/libs/vwidgets/vtoolbuttonpopup.h b/src/libs/vwidgets/vtoolbuttonpopup.h index d4fb7b8aa..d4bd51a12 100644 --- a/src/libs/vwidgets/vtoolbuttonpopup.h +++ b/src/libs/vwidgets/vtoolbuttonpopup.h @@ -30,10 +30,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class VToolButtonPopup : public QToolButton { Q_OBJECT // NOLINT diff --git a/src/libs/vwidgets/vwidgetpopup.h b/src/libs/vwidgets/vwidgetpopup.h index 453eb08d8..f7f36d432 100644 --- a/src/libs/vwidgets/vwidgetpopup.h +++ b/src/libs/vwidgets/vwidgetpopup.h @@ -35,10 +35,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - /** \brief Class showing a widget as popup window. diff --git a/src/test/CollectionTest/tst_tapecommandline.h b/src/test/CollectionTest/tst_tapecommandline.h index b7317fe03..9f7fb1acc 100644 --- a/src/test/CollectionTest/tst_tapecommandline.h +++ b/src/test/CollectionTest/tst_tapecommandline.h @@ -30,9 +30,6 @@ #define TST_TAPECOMMANDLINE_H #include "../vtest/abstracttest.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif class TST_TapeCommandLine : public AbstractTest { diff --git a/src/test/CollectionTest/tst_valentinacommandline.cpp b/src/test/CollectionTest/tst_valentinacommandline.cpp index 763c84d07..1b5e4dcf1 100644 --- a/src/test/CollectionTest/tst_valentinacommandline.cpp +++ b/src/test/CollectionTest/tst_valentinacommandline.cpp @@ -231,10 +231,7 @@ void TST_ValentinaCommandLine::TestOpenCollection_data() const QTest::newRow("pantsM7") << "pantsM7.val" << testGOST << V_EX_OK; #endif -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) QTest::newRow("TShirt_test") << "TShirt_test.val" << keyTest << V_EX_OK; -#endif - QTest::newRow("TestDart") << "TestDart.val" << keyTest << V_EX_OK; QTest::newRow("MaleShirt") << "MaleShirt.val" << keyTest << V_EX_OK; QTest::newRow("Trousers") << "Trousers.val" << keyTest << V_EX_OK; diff --git a/src/test/CollectionTest/tst_valentinacommandline.h b/src/test/CollectionTest/tst_valentinacommandline.h index 4cc98f0f0..10a080db1 100644 --- a/src/test/CollectionTest/tst_valentinacommandline.h +++ b/src/test/CollectionTest/tst_valentinacommandline.h @@ -30,9 +30,6 @@ #define TST_VALENTINACOMMANDLINE_H #include "../vtest/abstracttest.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif class TST_ValentinaCommandLine : public AbstractTest { diff --git a/src/test/TranslationsTest/tst_abstractregexp.h b/src/test/TranslationsTest/tst_abstractregexp.h index 0ba145dde..617c5bffd 100644 --- a/src/test/TranslationsTest/tst_abstractregexp.h +++ b/src/test/TranslationsTest/tst_abstractregexp.h @@ -30,9 +30,6 @@ #define TST_ABSTRACTREGEXP_H #include "../vtest/abstracttest.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif #include diff --git a/src/test/TranslationsTest/tst_abstracttranslation.h b/src/test/TranslationsTest/tst_abstracttranslation.h index 79bd0128c..f28a864af 100644 --- a/src/test/TranslationsTest/tst_abstracttranslation.h +++ b/src/test/TranslationsTest/tst_abstracttranslation.h @@ -38,10 +38,6 @@ #include // and, not, or #endif -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class TST_AbstractTranslation : public QObject { Q_OBJECT // NOLINT diff --git a/src/test/ValentinaTest/tst_misc.h b/src/test/ValentinaTest/tst_misc.h index cde2aeb47..0f4c0320c 100644 --- a/src/test/ValentinaTest/tst_misc.h +++ b/src/test/ValentinaTest/tst_misc.h @@ -31,10 +31,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class TST_Misc : public QObject { Q_OBJECT // NOLINT diff --git a/src/test/ValentinaTest/tst_qmutokenparser.h b/src/test/ValentinaTest/tst_qmutokenparser.h index 628fce45e..f4e54ded8 100644 --- a/src/test/ValentinaTest/tst_qmutokenparser.h +++ b/src/test/ValentinaTest/tst_qmutokenparser.h @@ -32,10 +32,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class TST_QmuTokenParser : public QObject { Q_OBJECT // NOLINT diff --git a/src/test/ValentinaTest/tst_readval.cpp b/src/test/ValentinaTest/tst_readval.cpp index a2b27e4cd..c26ce4800 100644 --- a/src/test/ValentinaTest/tst_readval.cpp +++ b/src/test/ValentinaTest/tst_readval.cpp @@ -146,8 +146,8 @@ void TST_ReadVal::TestVal() qreal resVal = 0; QLocale::setDefault(locale); - const vsizetype resCount = ReadVal(formula, resVal, locale, VLocaleCharacter(LocaleDecimalPoint(locale)), - VLocaleCharacter(LocaleGroupSeparator(locale))); + const vsizetype resCount = + ReadVal(formula, resVal, locale, LocaleDecimalPoint(locale), LocaleGroupSeparator(locale)); // cppcheck-suppress unreadVariable QString errorMsg = QStringLiteral("Conversion failed. Locale: '%1'.").arg(locale.name()); diff --git a/src/test/ValentinaTest/tst_vcommandline.h b/src/test/ValentinaTest/tst_vcommandline.h index 3fb104771..2b80ffa23 100644 --- a/src/test/ValentinaTest/tst_vcommandline.h +++ b/src/test/ValentinaTest/tst_vcommandline.h @@ -31,10 +31,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class TST_VCommandLine : public QObject { Q_OBJECT // NOLINT diff --git a/src/test/ValentinaTest/tst_vcubicbezierpath.h b/src/test/ValentinaTest/tst_vcubicbezierpath.h index 6f04e5782..fff7bba39 100644 --- a/src/test/ValentinaTest/tst_vcubicbezierpath.h +++ b/src/test/ValentinaTest/tst_vcubicbezierpath.h @@ -31,10 +31,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class TST_VCubicBezierPath : public QObject { Q_OBJECT // NOLINT diff --git a/src/test/ValentinaTest/tst_vellipticalarc.h b/src/test/ValentinaTest/tst_vellipticalarc.h index c3d9dfe23..ac619adca 100644 --- a/src/test/ValentinaTest/tst_vellipticalarc.h +++ b/src/test/ValentinaTest/tst_vellipticalarc.h @@ -30,9 +30,6 @@ #define TST_VELLIPTICALARC_H #include "../vtest/abstracttest.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif class TST_VEllipticalArc : public AbstractTest { diff --git a/src/test/ValentinaTest/tst_vpiece.h b/src/test/ValentinaTest/tst_vpiece.h index 42797a766..e6c1d439d 100644 --- a/src/test/ValentinaTest/tst_vpiece.h +++ b/src/test/ValentinaTest/tst_vpiece.h @@ -30,9 +30,6 @@ #define TST_VDETAIL_H #include "../vtest/abstracttest.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif class TST_VPiece : public AbstractTest { diff --git a/src/test/ValentinaTest/tst_vpointf.h b/src/test/ValentinaTest/tst_vpointf.h index 2c8382eb5..2e307ce7b 100644 --- a/src/test/ValentinaTest/tst_vpointf.h +++ b/src/test/ValentinaTest/tst_vpointf.h @@ -32,10 +32,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class TST_VPointF : public QObject { Q_OBJECT // NOLINT diff --git a/src/test/ValentinaTest/tst_vspline.h b/src/test/ValentinaTest/tst_vspline.h index 0b6198b65..03c074296 100644 --- a/src/test/ValentinaTest/tst_vspline.h +++ b/src/test/ValentinaTest/tst_vspline.h @@ -30,9 +30,6 @@ #define TST_VSPLINE_H #include "../vtest/abstracttest.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif class VSpline; diff --git a/src/test/ValentinaTest/tst_vsplinepath.h b/src/test/ValentinaTest/tst_vsplinepath.h index 9f6907dd6..b4549f124 100644 --- a/src/test/ValentinaTest/tst_vsplinepath.h +++ b/src/test/ValentinaTest/tst_vsplinepath.h @@ -31,10 +31,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class TST_VSplinePath : public QObject { Q_OBJECT // NOLINT diff --git a/src/test/ValentinaTest/tst_vsvgpathtokenizer.h b/src/test/ValentinaTest/tst_vsvgpathtokenizer.h index ffa04ce63..cafaa76d0 100644 --- a/src/test/ValentinaTest/tst_vsvgpathtokenizer.h +++ b/src/test/ValentinaTest/tst_vsvgpathtokenizer.h @@ -30,10 +30,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class TST_VSVGPathTokenizer : public QObject { Q_OBJECT // NOLINT diff --git a/src/test/ValentinaTest/tst_vtooluniondetails.h b/src/test/ValentinaTest/tst_vtooluniondetails.h index 7ebbfeba2..11633b48a 100644 --- a/src/test/ValentinaTest/tst_vtooluniondetails.h +++ b/src/test/ValentinaTest/tst_vtooluniondetails.h @@ -31,10 +31,6 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class TST_VToolUnionDetails : public QObject { Q_OBJECT // NOLINT diff --git a/src/test/ValentinaTest/tst_vtranslatevars.cpp b/src/test/ValentinaTest/tst_vtranslatevars.cpp index 443612684..75922440d 100644 --- a/src/test/ValentinaTest/tst_vtranslatevars.cpp +++ b/src/test/ValentinaTest/tst_vtranslatevars.cpp @@ -151,7 +151,7 @@ void TST_VTranslateVars::PrepareValToUser(double d, const QLocale &locale) { const QString formulaFromSystem = QLocale::c().toString(d); QString formulaToUser = locale.toString(d); - if (VLocaleCharacter(LocaleGroupSeparator(locale)).isSpace()) + if (LocaleGroupSeparator(locale).isSpace()) { formulaToUser.replace(LocaleGroupSeparator(locale), QString()); } diff --git a/src/test/ValentinaTest/tst_vtranslatevars.h b/src/test/ValentinaTest/tst_vtranslatevars.h index 25cc506ba..3ab79950e 100644 --- a/src/test/ValentinaTest/tst_vtranslatevars.h +++ b/src/test/ValentinaTest/tst_vtranslatevars.h @@ -33,10 +33,6 @@ #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - class VTranslateVars; class TST_VTranslateVars : public QObject diff --git a/src/test/ValentinaTest/tst_xsdschema.h b/src/test/ValentinaTest/tst_xsdschema.h index ab59a5914..321f6686b 100644 --- a/src/test/ValentinaTest/tst_xsdschema.h +++ b/src/test/ValentinaTest/tst_xsdschema.h @@ -30,13 +30,10 @@ #include -#if QT_VERSION < QT_VERSION_CHECK(5, 13, 0) -#include "../vmisc/defglobal.h" -#endif - -class TST_XSDShema :public QObject +class TST_XSDShema : public QObject { Q_OBJECT // NOLINT + public: explicit TST_XSDShema(QObject *parent = nullptr); ~TST_XSDShema() override = default; diff --git a/valentina.qbs b/valentina.qbs index 65b2bc94f..e762fa5e0 100644 --- a/valentina.qbs +++ b/valentina.qbs @@ -9,7 +9,7 @@ Project { property bool enableConan: false property string minimumMacosVersion: undefined - property string minimumQtVersion: "5.6" + property string minimumQtVersion: "5.15" property stringList conanProfiles: [] property bool enableSigning: true