From 3917d50590bbc2328d97e925d48d56c4b1af5104 Mon Sep 17 00:00:00 2001 From: Andreas Fertig Date: Thu, 8 Feb 2024 14:18:28 +0100 Subject: [PATCH] Code for 2nd edition --- .github/workflows/ci.yml | 48 +++++----- 01.01-variadicTemplateSum2/CMakeLists.txt | 2 +- 01.02-variableTemplate0/CMakeLists.txt | 2 +- 01.05-variadicTemplateSum3/CMakeLists.txt | 2 +- 01.06-simpleRequirement0/CMakeLists.txt | 2 +- 01.06-simpleRequirement0/main.cpp | 9 +- 01.07-nestedRequirement0/CMakeLists.txt | 2 +- 01.08-compoundRequirement0/CMakeLists.txt | 2 +- 01.08-compoundRequirement0/main.cpp | 2 +- 01.09-typeRequirement0/CMakeLists.txt | 2 +- 01.09-typeRequirement0/main.cpp | 3 +- 01.10-compoundRequirement1/CMakeLists.txt | 2 +- 01.10-compoundRequirement1/main.cpp | 2 +- 01.11-compoundRequirement2/CMakeLists.txt | 2 +- 01.11-compoundRequirement2/main.cpp | 2 +- 01.12-testingRequirements0/CMakeLists.txt | 2 +- 01.12-testingRequirements0/main.cpp | 16 ++-- 01.14-invocable0/CMakeLists.txt | 2 +- 01.14-invocable0/main.cpp | 2 +- 01.15-invocable1/CMakeLists.txt | 2 +- 01.15-invocable1/main.cpp | 2 +- .../CMakeLists.txt | 2 +- 01.18-vectorsSize0/CMakeLists.txt | 2 +- 01.21-vectorsSize1/CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- 01.22-validateInDebugModeIfExists0/main.cpp | 5 +- 01.24-optional0/CMakeLists.txt | 2 +- 01.26-optional1/CMakeLists.txt | 2 +- 01.27-optional2/CMakeLists.txt | 2 +- 01.27-optional2/main.cpp | 8 +- 01.28-optional3/CMakeLists.txt | 2 +- 01.28-optional3/main.cpp | 11 +-- 01.29-optional4/CMakeLists.txt | 2 +- 01.29-optional4/main.cpp | 18 ++-- 01.32-optional5/CMakeLists.txt | 2 +- 01.32-optional5/main.cpp | 33 +++---- 01.33-optional6/CMakeLists.txt | 2 +- 01.33-optional6/main.cpp | 37 ++++---- 01.34-isSameConcept0/CMakeLists.txt | 2 +- 01.34-isSameConcept0/main.cpp | 4 +- 01.36-isSameConcept1/CMakeLists.txt | 2 +- 01.36-isSameConcept1/main.cpp | 4 +- 01.37-isSameConcept2/CMakeLists.txt | 2 +- 01.37-isSameConcept2/main.cpp | 4 +- 01.38-isSameConcept3/CMakeLists.txt | 2 +- 01.38-isSameConcept3/main.cpp | 8 +- 01.40-printSorted0/CMakeLists.txt | 2 +- 01.42-printSorted1/CMakeLists.txt | 2 +- 01.42-printSorted1/main.cpp | 10 +-- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- 02.08-parsingDataStream0/CMakeLists.txt | 2 +- 02.08-parsingDataStream0/main.cpp | 2 +- .../CMakeLists.txt | 2 +- 02.10-coroutineParsingDataStream0/main.cpp | 1 + .../CMakeLists.txt | 2 +- 02.18-coroutineParsingDataStream1/main.cpp | 1 + .../CMakeLists.txt | 2 +- .../main.cpp | 1 + .../CMakeLists.txt | 2 +- .../main.cpp | 1 + .../CMakeLists.txt | 2 +- .../main.cpp | 9 +- 03.01-rangesMotivation0/CMakeLists.txt | 2 +- 03.02-rangesMotivation1/CMakeLists.txt | 2 +- 03.03-rangesMotivation2/CMakeLists.txt | 2 +- 03.03-rangesMotivation2/main.cpp | 16 +--- 03.04-twoStepUsing0/CMakeLists.txt | 2 +- 03.04-twoStepUsing0/main.cpp | 4 +- 03.05-twoStepUsing1/CMakeLists.txt | 5 +- 03.06-twoStepUsing2/CMakeLists.txt | 5 +- 03.07-rangesSafety0/CMakeLists.txt | 2 +- 03.08-rangesSafety1/CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- 03.09-rangesMotivationComposability0/main.cpp | 4 +- .../CMakeLists.txt | 2 +- 03.10-rangesMotivationComposability1/main.cpp | 17 ++-- 03.11-aRange0/CMakeLists.txt | 2 +- 03.13-rangesCommonView1/CMakeLists.txt | 2 +- 03.14-rangesCommonView2/CMakeLists.txt | 2 +- 03.14-rangesCommonView2/main.cpp | 17 ++-- 03.15-rangesProjection0/CMakeLists.txt | 2 +- 03.17-rangesProjection1/CMakeLists.txt | 2 +- 03.17-rangesProjection1/main.cpp | 22 ++--- .../CMakeLists.txt | 2 +- 03.18-rangesMotivationComposability2/main.cpp | 19 ++-- 03.19-rangesCustomAdaptor0/CMakeLists.txt | 2 +- 03.19-rangesCustomAdaptor0/main.cpp | 22 ++--- 03.20-rangesCustomAdaptor1/CMakeLists.txt | 2 +- 03.20-rangesCustomAdaptor1/main.cpp | 22 ++--- 03.22-rangesNamespaces0/CMakeLists.txt | 2 +- 03.22-rangesNamespaces0/main.cpp | 8 +- 03.23-rangesCustomTakeView0/CMakeLists.txt | 2 +- 03.23-rangesCustomTakeView0/main.cpp | 32 +++---- 03.29-rangesCustomTakeView1/CMakeLists.txt | 2 +- 03.29-rangesCustomTakeView1/main.cpp | 26 ++---- 04.01-includeHell0/CMakeLists.txt | 2 +- 04.03-moduleSkeleton0/CMakeLists.txt | 2 +- 04.04-namespaceDetails0/CMakeLists.txt | 2 +- 04.05-namespaceDetails1/CMakeLists.txt | 2 +- 04.06-downWithDebug0/CMakeLists.txt | 2 +- 04.10-downWithDebug1/CMakeLists.txt | 2 +- 04.11-inClassMemberFunction0/CMakeLists.txt | 2 +- 04.12-assertImpl0/CMakeLists.txt | 2 +- 05.01-stdFmtStockIndex0/CMakeLists.txt | 2 +- 05.01-stdFmtStockIndex0/main.cpp | 24 ++--- 05.03-digitSeparator0/CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- 05.10-stdFmtEscape0/CMakeLists.txt | 2 +- 05.10-stdFmtEscape0/main.cpp | 13 +-- 05.11-stdFmtLocale0/CMakeLists.txt | 2 +- 05.11-stdFmtLocale0/main.cpp | 20 ++--- 05.12-stdFmtFloatFormatting0/CMakeLists.txt | 2 +- 05.12-stdFmtFloatFormatting0/main.cpp | 18 +--- .../CMakeLists.txt | 2 +- .../main.cpp | 29 ++---- .../CMakeLists.txt | 2 +- .../main.cpp | 28 +++--- .../CMakeLists.txt | 2 +- .../main.cpp | 28 +++--- 05.19-stdFmtFormattingShares0/CMakeLists.txt | 2 +- 05.19-stdFmtFormattingShares0/main.cpp | 22 ++--- 05.21-stdFmtFormatTo0/CMakeLists.txt | 2 +- 05.21-stdFmtFormatTo0/main.cpp | 20 ++--- 05.22-stdFmtFormatTo1/CMakeLists.txt | 2 +- 05.22-stdFmtFormatTo1/main.cpp | 20 ++--- 05.23-stdFmtFormatTo2/CMakeLists.txt | 2 +- 05.23-stdFmtFormatTo2/main.cpp | 20 ++--- 05.24-stdFmtFormatToN0/CMakeLists.txt | 2 +- 05.24-stdFmtFormatToN0/main.cpp | 18 ++-- 05.25-stdFmtCustomLogger0/CMakeLists.txt | 2 +- 05.25-stdFmtCustomLogger0/main.cpp | 42 ++++----- 05.27-stdFmtCustomLogger1/CMakeLists.txt | 2 +- 05.27-stdFmtCustomLogger1/main.cpp | 26 ++++-- 05.29-stdFmtCustomLogger2/CMakeLists.txt | 2 +- 05.29-stdFmtCustomLogger2/main.cpp | 45 +++++----- 05.32-stdFmtCustomLogger4/CMakeLists.txt | 2 +- 05.32-stdFmtCustomLogger4/main.cpp | 60 +++++++------ 06.01-equalComparOfMRN0/CMakeLists.txt | 2 +- 06.02-equalComparOfMRN1/CMakeLists.txt | 2 +- 06.04-equalComparOfMRN2/CMakeLists.txt | 2 +- 06.05-equalComparOfMRN3/CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- 06.06-orderingComparisonString0/main.cpp | 10 +-- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- 06.08-orderingComparisonString2/main.cpp | 2 +- .../CMakeLists.txt | 2 +- 06.09-orderingComparisonString4/main.cpp | 64 +++++++++++++ .../CMakeLists.txt | 2 +- .../main.cpp | 0 .../CMakeLists.txt | 2 +- .../main.cpp | 0 {06.12-bcd1 => 06.12-bcd0}/CMakeLists.txt | 2 +- {06.11-bcd0 => 06.12-bcd0}/main.cpp | 0 06.13-bcd1/CMakeLists.txt | 90 +++++++++++++++++++ {06.12-bcd1 => 06.13-bcd1}/main.cpp | 0 06.13-bcdConstexpr/CMakeLists.txt | 90 ------------------- 06.14-bcdConstexpr/CMakeLists.txt | 90 +++++++++++++++++++ .../main.cpp | 0 06.14-customOrdering0/CMakeLists.txt | 90 ------------------- 06.15-customOrdering0/CMakeLists.txt | 90 +++++++++++++++++++ .../main.cpp | 13 +-- 06.15-customOrdering1/CMakeLists.txt | 90 ------------------- 06.16-customOrdering1/CMakeLists.txt | 90 +++++++++++++++++++ .../main.cpp | 14 +-- 06.16-spaceshipWithLegacyCode0/CMakeLists.txt | 90 ------------------- 06.17-spaceshipWithLegacyCode0/CMakeLists.txt | 90 +++++++++++++++++++ .../main.cpp | 0 ...> 06.18-see-06.17-spaceshipWithLegacyCode0 | 0 .../CMakeLists.txt | 90 ------------------- .../CMakeLists.txt | 90 +++++++++++++++++++ .../main.cpp | 0 07.01-captureByCopy0/CMakeLists.txt | 2 +- 07.02-captureByCopy1/CMakeLists.txt | 2 +- 07.03-captureByCopy1Insights/CMakeLists.txt | 2 +- 07.04-captureByCopy2/CMakeLists.txt | 2 +- 07.05-mapSortBooksByIsbn0/CMakeLists.txt | 2 +- 07.07-mapSortBooksByIsbn1/CMakeLists.txt | 2 +- 07.08-mapSortBooksByIsbn2/CMakeLists.txt | 2 +- 07.09-mapSortBooksByIsbn3/CMakeLists.txt | 2 +- 07.09-mapSortBooksByIsbn3/main.cpp | 11 ++- 07.13-mapSortBooksByIsbn4/CMakeLists.txt | 2 +- 07.14-printWithOrigin0/CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- 07.19-lambdaInitCapture0/CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- 07.25-genericLambdaVarArgsForward7/main.cpp | 4 +- 08.01-aggregateInit0/CMakeLists.txt | 2 +- 08.02-userProvidedVsDeclared0/CMakeLists.txt | 2 +- 08.03-designatedInitializers0/CMakeLists.txt | 2 +- 08.04-designatedInitializers1/CMakeLists.txt | 2 +- 08.05-mostVertexingParse0/CMakeLists.txt | 2 +- 08.06-designatedInitializers2/CMakeLists.txt | 2 +- 08.07-designatedInitializers3/CMakeLists.txt | 2 +- 08.09-designatedInitializers4/CMakeLists.txt | 2 +- 08.10-guaranteedCopyElision0/CMakeLists.txt | 2 +- 08.11-designatedInitializers5/CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../main.cpp | 4 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- 08.21-initializationForms0/CMakeLists.txt | 2 +- 08.21-initializationForms0/main.cpp | 4 +- .../CMakeLists.txt | 2 +- 08.25-ctad0/CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- 09.01-stdArray0/CMakeLists.txt | 2 +- 09.02-floatingPointNTTP0/CMakeLists.txt | 2 +- 09.03-fixedString0/CMakeLists.txt | 2 +- 09.04-fixedString1/CMakeLists.txt | 2 +- 09.04-fixedString1/main.cpp | 9 +- 09.12-fixedString2/CMakeLists.txt | 2 +- 09.12-fixedString2/main.cpp | 9 +- 09.13-fixedString3/CMakeLists.txt | 2 +- 09.13-fixedString3/main.cpp | 19 +--- 10.01-bitCastFloatToInt0/CMakeLists.txt | 2 +- 10.02-bitCastFloatToInt1/CMakeLists.txt | 2 +- 10.03-byteSwap0/CMakeLists.txt | 2 +- 10.03-byteSwap0/main.cpp | 6 +- 10.04-stdArrayVsCArray0/CMakeLists.txt | 2 +- 10.05-stdArrayVsCArray1/CMakeLists.txt | 2 +- 10.06-stdArrayVsCArray2/CMakeLists.txt | 2 +- 10.07-lengthAndValue0/CMakeLists.txt | 2 +- 10.08-lengthAndValue1/CMakeLists.txt | 2 +- 10.09-lengthAndValue2/CMakeLists.txt | 2 +- 10.10-span0/CMakeLists.txt | 2 +- 10.11-assert0/CMakeLists.txt | 2 +- 10.13-assert1/CMakeLists.txt | 2 +- 10.13-assert1/main.cpp | 15 +--- 10.14-logFunction0/CMakeLists.txt | 2 +- 10.14-logFunction0/main.cpp | 22 ++--- 10.15-logFunction1/CMakeLists.txt | 2 +- 10.15-logFunction1/main.cpp | 27 ++---- 10.16-logFunction2/CMakeLists.txt | 2 +- 10.16-logFunction2/main.cpp | 21 ++--- 10.17-mapContains0/CMakeLists.txt | 2 +- 10.18-mapContains1/CMakeLists.txt | 2 +- 10.19-startsWith0/CMakeLists.txt | 2 +- 10.19-startsWith0/main.cpp | 2 +- 10.20-startsWith1/CMakeLists.txt | 2 +- 10.20-startsWith1/main.cpp | 4 +- 11.01-rangeBaseForWithInit0/CMakeLists.txt | 2 +- 11.02-rangeBaseForWithInit1/CMakeLists.txt | 2 +- 11.03-rangeBaseForWithInit2/CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../main.cpp | 13 ++- .../CMakeLists.txt | 2 +- 11.06-likely0/CMakeLists.txt | 2 +- 11.06-likely0/main.cpp | 6 +- 11.07-likely1/CMakeLists.txt | 2 +- 11.07-likely1/main.cpp | 6 +- 11.08-notCopyable0/CMakeLists.txt | 2 +- 11.09-notCopyable1/CMakeLists.txt | 2 +- 11.10-usingEnum0/CMakeLists.txt | 2 +- 11.11-usingEnum1/CMakeLists.txt | 2 +- 11.12-conditionalExplicit0/CMakeLists.txt | 2 +- 11.13-conditionalExplicit1/CMakeLists.txt | 2 +- 11.14-conditionalExplicit2/CMakeLists.txt | 2 +- 11.15-conditionalExplicit5/CMakeLists.txt | 2 +- 12.01-constexprStrlenCpp110/CMakeLists.txt | 2 +- 12.02-constexprStrlenCpp111/CMakeLists.txt | 2 +- 12.03-constexprPoint0/CMakeLists.txt | 2 +- 12.04-constexprThrow0/CMakeLists.txt | 2 +- 12.05-throwAtCompileTime0/CMakeLists.txt | 2 +- 12.06-logStatementInConstexpr0/CMakeLists.txt | 2 +- 12.08-byteSwap1/CMakeLists.txt | 2 +- 12.08-byteSwap1/main.cpp | 13 ++- .../CMakeLists.txt | 5 +- 12.10-constexprAllocation0/CMakeLists.txt | 2 +- 12.12-constexprAllocation1/CMakeLists.txt | 2 +- 12.14-constexprAllocation2/CMakeLists.txt | 4 +- 12.14-constexprAllocation2/main.cpp | 22 ++--- 12.15-asConstant0/CMakeLists.txt | 5 +- 12.16-asConstant1/CMakeLists.txt | 5 +- 12.16-asConstant1/main.cpp | 2 +- 12.18-constevalParmCheck0/CMakeLists.txt | 2 +- 12.19-constevalParmCheck1/CMakeLists.txt | 2 +- 12.19-constevalParmCheck1/main.cpp | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- .../CMakeLists.txt | 2 +- CMakeLists.txt | 2 +- LICENSE.txt | 2 +- Readme.md | 12 +-- 302 files changed, 1251 insertions(+), 1381 deletions(-) rename {06.09-orderingComparisonString3 => 06.09-orderingComparisonString4}/CMakeLists.txt (97%) create mode 100644 06.09-orderingComparisonString4/main.cpp rename {06.10-spaceshipResultingType0 => 06.10-orderingComparisonString3}/CMakeLists.txt (97%) rename {06.09-orderingComparisonString3 => 06.10-orderingComparisonString3}/main.cpp (100%) rename {06.11-bcd0 => 06.11-spaceshipResultingType0}/CMakeLists.txt (97%) rename {06.10-spaceshipResultingType0 => 06.11-spaceshipResultingType0}/main.cpp (100%) rename {06.12-bcd1 => 06.12-bcd0}/CMakeLists.txt (97%) rename {06.11-bcd0 => 06.12-bcd0}/main.cpp (100%) create mode 100644 06.13-bcd1/CMakeLists.txt rename {06.12-bcd1 => 06.13-bcd1}/main.cpp (100%) delete mode 100644 06.13-bcdConstexpr/CMakeLists.txt create mode 100644 06.14-bcdConstexpr/CMakeLists.txt rename {06.13-bcdConstexpr => 06.14-bcdConstexpr}/main.cpp (100%) delete mode 100644 06.14-customOrdering0/CMakeLists.txt create mode 100644 06.15-customOrdering0/CMakeLists.txt rename {06.14-customOrdering0 => 06.15-customOrdering0}/main.cpp (80%) delete mode 100644 06.15-customOrdering1/CMakeLists.txt create mode 100644 06.16-customOrdering1/CMakeLists.txt rename {06.15-customOrdering1 => 06.16-customOrdering1}/main.cpp (88%) delete mode 100644 06.16-spaceshipWithLegacyCode0/CMakeLists.txt create mode 100644 06.17-spaceshipWithLegacyCode0/CMakeLists.txt rename {06.16-spaceshipWithLegacyCode0 => 06.17-spaceshipWithLegacyCode0}/main.cpp (100%) rename 06.17-see-06.16-spaceshipWithLegacyCode0 => 06.18-see-06.17-spaceshipWithLegacyCode0 (100%) delete mode 100644 06.18-spaceshipEqualityRewrite2/CMakeLists.txt create mode 100644 06.19-spaceshipEqualityRewrite2/CMakeLists.txt rename {06.18-spaceshipEqualityRewrite2 => 06.19-spaceshipEqualityRewrite2}/main.cpp (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 747b0a1..b696cf0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,7 @@ name: ci on: [push, pull_request] env: - CMAKE_VERSION: 3.16.2 + CMAKE_VERSION: 3.28.2 NINJA_VERSION: 1.10.0 jobs: @@ -15,22 +15,22 @@ jobs: fail-fast: false matrix: config: - # GCC-10 + # GCC-13 - { - name: "Linux GCC 11", - os: ubuntu-20.04, + name: "Linux GCC 13", + os: ubuntu-22.04, build_type: Release, - cxx: "g++-11", - gcc_version: 11, + cxx: "g++-13", + gcc_version: 13, } - # Clang-14 + # Clang-17 - { - name: "Linux Clang 14", - os: ubuntu-20.04, + name: "Linux Clang 17", + os: ubuntu-22.04, build_type: Release, - cxx: "clang++-14", - clang_version: 14, + cxx: "clang++-17", + clang_version: 17, libcxx: true } @@ -52,7 +52,7 @@ jobs: } steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 2 @@ -67,16 +67,16 @@ jobs: if ("${{ runner.os }}" STREQUAL "Windows") set(ninja_suffix "win.zip") - set(cmake_suffix "win64-x64.zip") - set(cmake_dir "cmake-${cmake_version}-win64-x64/bin") + set(cmake_suffix "windows-x86_64.zip") + set(cmake_dir "cmake-${cmake_version}-windows-x86_64/bin") elseif ("${{ runner.os }}" STREQUAL "Linux") set(ninja_suffix "linux.zip") - set(cmake_suffix "Linux-x86_64.tar.gz") - set(cmake_dir "cmake-${cmake_version}-Linux-x86_64/bin") + set(cmake_suffix "linux-x86_64.tar.gz") + set(cmake_dir "cmake-${cmake_version}-linux-x86_64/bin") elseif ("${{ runner.os }}" STREQUAL "macOS") set(ninja_suffix "mac.zip") - set(cmake_suffix "Darwin-x86_64.tar.gz") - set(cmake_dir "cmake-${cmake_version}-Darwin-x86_64/CMake.app/Contents/bin") + set(cmake_suffix "macos-universal.tar.gz") + set(cmake_dir "cmake-${cmake_version}-macos-universal/CMake.app/Contents/bin") endif() set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}") @@ -98,8 +98,8 @@ jobs: ) endif() - - name: Install Clang 14 - id: install_clang_11 + - name: Install Clang 17 + id: install_clang_17 if: startsWith(matrix.config.os, 'ubuntu') && startsWith(matrix.config.cxx, 'clang++-') shell: bash working-directory: ${{ env.HOME }} @@ -109,9 +109,9 @@ jobs: sudo ./llvm.sh ${{ matrix.config.clang_version }} sudo apt-get install -y libunwind-${{ matrix.config.clang_version }}-dev libunwind-${{ matrix.config.clang_version }} - - name: Install g++ 11 - id: install_gcc_11 - if: startsWith(matrix.config.os, 'ubuntu') && ( matrix.config.cxx == 'g++-11' ) + - name: Install g++ 13 + id: install_gcc_13 + if: startsWith(matrix.config.os, 'ubuntu') && ( matrix.config.cxx == 'g++-13' ) shell: bash working-directory: ${{ env.HOME }} env: @@ -121,7 +121,7 @@ jobs: sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install g++-${{ matrix.config.gcc_version }} - sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 100 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 100 - name: Install libc++ id: install_libcxx diff --git a/01.01-variadicTemplateSum2/CMakeLists.txt b/01.01-variadicTemplateSum2/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/01.01-variadicTemplateSum2/CMakeLists.txt +++ b/01.01-variadicTemplateSum2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/01.02-variableTemplate0/CMakeLists.txt b/01.02-variableTemplate0/CMakeLists.txt index 14b1ad9..2811d7c 100644 --- a/01.02-variableTemplate0/CMakeLists.txt +++ b/01.02-variableTemplate0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 14) diff --git a/01.05-variadicTemplateSum3/CMakeLists.txt b/01.05-variadicTemplateSum3/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.05-variadicTemplateSum3/CMakeLists.txt +++ b/01.05-variadicTemplateSum3/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.06-simpleRequirement0/CMakeLists.txt b/01.06-simpleRequirement0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.06-simpleRequirement0/CMakeLists.txt +++ b/01.06-simpleRequirement0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.06-simpleRequirement0/main.cpp b/01.06-simpleRequirement0/main.cpp index 97c4631..6b2e375 100644 --- a/01.06-simpleRequirement0/main.cpp +++ b/01.06-simpleRequirement0/main.cpp @@ -8,12 +8,11 @@ template constexpr bool are_same_v = std::conjunction_v...>; template -requires + requires - requires(Args... args) -{ - (... + args); // #C SR: args provides + -} + requires(Args... args) { + (... + args); // #C SR: args provides + + } auto add(const Args&... args) { diff --git a/01.07-nestedRequirement0/CMakeLists.txt b/01.07-nestedRequirement0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.07-nestedRequirement0/CMakeLists.txt +++ b/01.07-nestedRequirement0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.08-compoundRequirement0/CMakeLists.txt b/01.08-compoundRequirement0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.08-compoundRequirement0/CMakeLists.txt +++ b/01.08-compoundRequirement0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.08-compoundRequirement0/main.cpp b/01.08-compoundRequirement0/main.cpp index 28a0f78..6c0d85e 100644 --- a/01.08-compoundRequirement0/main.cpp +++ b/01.08-compoundRequirement0/main.cpp @@ -34,7 +34,7 @@ requires(Args... args) } -auto add(Args&&... args) +auto add(Args&&... args) noexcept { return (... + args); } diff --git a/01.09-typeRequirement0/CMakeLists.txt b/01.09-typeRequirement0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.09-typeRequirement0/CMakeLists.txt +++ b/01.09-typeRequirement0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.09-typeRequirement0/main.cpp b/01.09-typeRequirement0/main.cpp index 490bf54..a1c7cd3 100644 --- a/01.09-typeRequirement0/main.cpp +++ b/01.09-typeRequirement0/main.cpp @@ -5,8 +5,7 @@ #include template -concept containerTypes = requires(T t) -{ // #A Testing for various types in T +concept containerTypes = requires(T t) { // #A Testing for various types in T typename T::value_type; typename T::size_type; typename T::allocator_type; diff --git a/01.10-compoundRequirement1/CMakeLists.txt b/01.10-compoundRequirement1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.10-compoundRequirement1/CMakeLists.txt +++ b/01.10-compoundRequirement1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.10-compoundRequirement1/main.cpp b/01.10-compoundRequirement1/main.cpp index 103acbf..475f89f 100644 --- a/01.10-compoundRequirement1/main.cpp +++ b/01.10-compoundRequirement1/main.cpp @@ -27,7 +27,7 @@ requires requires(Args... args) requires sizeof...(Args) > 1; { (... + args) } noexcept -> same_as>; } -auto Add(Args&&... args) +auto Add(Args&&... args) noexcept { return (... + args); } diff --git a/01.11-compoundRequirement2/CMakeLists.txt b/01.11-compoundRequirement2/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.11-compoundRequirement2/CMakeLists.txt +++ b/01.11-compoundRequirement2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.11-compoundRequirement2/main.cpp b/01.11-compoundRequirement2/main.cpp index f168835..4eb9897 100644 --- a/01.11-compoundRequirement2/main.cpp +++ b/01.11-compoundRequirement2/main.cpp @@ -30,7 +30,7 @@ concept Addable = requires(Args... args) template requires Addable -auto Add(Args&&... args) +auto Add(Args&&... args) noexcept { return (... + args); } diff --git a/01.12-testingRequirements0/CMakeLists.txt b/01.12-testingRequirements0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.12-testingRequirements0/CMakeLists.txt +++ b/01.12-testingRequirements0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.12-testingRequirements0/main.cpp b/01.12-testingRequirements0/main.cpp index 0762fc2..5c3d4cc 100644 --- a/01.12-testingRequirements0/main.cpp +++ b/01.12-testingRequirements0/main.cpp @@ -21,19 +21,17 @@ template using first_arg_t = typename first_arg::type; template -concept Addable = requires(Args... args) -{ +concept Addable = requires(Args... args) { (... + args); requires are_same_v; requires sizeof...(Args) > 1; { (... + args) - } - noexcept->same_as>; + } noexcept -> same_as>; }; template -requires Addable + requires Addable auto Add(Args&&... args) { return (... + args); @@ -44,15 +42,15 @@ auto Add(Args&&... args) template struct Stub { // #B Operator plus with controlled noexcept can be enabled - Stub& operator+(const Stub& rhs) noexcept(nexcept) requires( - operatorPlus&& validReturnType) + Stub& operator+(const Stub& rhs) noexcept(nexcept) + requires(operatorPlus && validReturnType) { return *this; } // #C Operator plus with invalid return type - int operator+(const Stub& rhs) noexcept(nexcept) requires( - operatorPlus && not validReturnType) + int operator+(const Stub& rhs) noexcept(nexcept) + requires(operatorPlus && not validReturnType) { return {}; } diff --git a/01.14-invocable0/CMakeLists.txt b/01.14-invocable0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.14-invocable0/CMakeLists.txt +++ b/01.14-invocable0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.14-invocable0/main.cpp b/01.14-invocable0/main.cpp index a55fed1..e54a854 100644 --- a/01.14-invocable0/main.cpp +++ b/01.14-invocable0/main.cpp @@ -18,5 +18,5 @@ void DoLocked(T&& f) int main() { - DoLocked([] { printf("hello\n"); }); + DoLocked([] { puts("hello"); }); } \ No newline at end of file diff --git a/01.15-invocable1/CMakeLists.txt b/01.15-invocable1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.15-invocable1/CMakeLists.txt +++ b/01.15-invocable1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.15-invocable1/main.cpp b/01.15-invocable1/main.cpp index f0d173f..c4776f5 100644 --- a/01.15-invocable1/main.cpp +++ b/01.15-invocable1/main.cpp @@ -19,5 +19,5 @@ void DoLocked(std::invocable auto&& f) int main() { - DoLocked([] { printf("hello\n"); }); + DoLocked([] { puts("hello"); }); } \ No newline at end of file diff --git a/01.16-constexprFunctionInConcept0/CMakeLists.txt b/01.16-constexprFunctionInConcept0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.16-constexprFunctionInConcept0/CMakeLists.txt +++ b/01.16-constexprFunctionInConcept0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.18-vectorsSize0/CMakeLists.txt b/01.18-vectorsSize0/CMakeLists.txt index 9566747..47b1d42 100644 --- a/01.18-vectorsSize0/CMakeLists.txt +++ b/01.18-vectorsSize0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 11) diff --git a/01.21-vectorsSize1/CMakeLists.txt b/01.21-vectorsSize1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.21-vectorsSize1/CMakeLists.txt +++ b/01.21-vectorsSize1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.22-validateInDebugModeIfExists0/CMakeLists.txt b/01.22-validateInDebugModeIfExists0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.22-validateInDebugModeIfExists0/CMakeLists.txt +++ b/01.22-validateInDebugModeIfExists0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.22-validateInDebugModeIfExists0/main.cpp b/01.22-validateInDebugModeIfExists0/main.cpp index 7768dd4..33590b6 100644 --- a/01.22-validateInDebugModeIfExists0/main.cpp +++ b/01.22-validateInDebugModeIfExists0/main.cpp @@ -4,10 +4,7 @@ #include template -concept SupportsValidation = requires(T t) -{ - t.validate(); -}; +concept SupportsValidation = requires(T t) { t.validate(); }; template void Send(const T& data) diff --git a/01.24-optional0/CMakeLists.txt b/01.24-optional0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/01.24-optional0/CMakeLists.txt +++ b/01.24-optional0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/01.26-optional1/CMakeLists.txt b/01.26-optional1/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/01.26-optional1/CMakeLists.txt +++ b/01.26-optional1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/01.27-optional2/CMakeLists.txt b/01.27-optional2/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.27-optional2/CMakeLists.txt +++ b/01.27-optional2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.27-optional2/main.cpp b/01.27-optional2/main.cpp index 0849dff..eb8c108 100644 --- a/01.27-optional2/main.cpp +++ b/01.27-optional2/main.cpp @@ -8,13 +8,13 @@ class optional { public: optional() = default; - optional( - const optional&) requires std::is_copy_constructible_v; + optional(const optional&) + requires std::is_copy_constructible_v; }; template -optional::optional( - const optional&) requires std::is_copy_constructible_v +optional::optional(const optional&) + requires std::is_copy_constructible_v {} struct NotCopyable { diff --git a/01.28-optional3/CMakeLists.txt b/01.28-optional3/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.28-optional3/CMakeLists.txt +++ b/01.28-optional3/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.28-optional3/main.cpp b/01.28-optional3/main.cpp index 4b9f957..cc6dde0 100644 --- a/01.28-optional3/main.cpp +++ b/01.28-optional3/main.cpp @@ -23,15 +23,16 @@ class optional { // The real constructor is omitted here because it // doesn't matter - ~optional() requires(not std::is_trivially_destructible_v) + ~optional() + requires(not std::is_trivially_destructible_v) { if(has_value) { value.as()->~T(); } } ~optional() = default; - optional( - const optional&) requires std::is_copy_constructible_v + optional(const optional&) + requires std::is_copy_constructible_v = default; private: @@ -56,7 +57,6 @@ static_assert(std::is_trivially_destructible_v>); int main() { -#if not defined(__clang__) static_assert( not std::is_copy_constructible_v>); static_assert(std::is_copy_constructible_v>); @@ -65,7 +65,4 @@ int main() optional>); static_assert( std::is_trivially_destructible_v>); -#else -# pragma message("not supported") -#endif } \ No newline at end of file diff --git a/01.29-optional4/CMakeLists.txt b/01.29-optional4/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.29-optional4/CMakeLists.txt +++ b/01.29-optional4/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.29-optional4/main.cpp b/01.29-optional4/main.cpp index 787807a..ba01251 100644 --- a/01.29-optional4/main.cpp +++ b/01.29-optional4/main.cpp @@ -13,14 +13,11 @@ struct COMLike { void COMLike::Release() { - printf("release\n"); + puts("release"); } template -concept HasRelease = requires(T t) -{ - t.Release(); -}; +concept HasRelease = requires(T t) { t.Release(); }; #if not defined(_MSC_VER) && not defined(__clang__) template @@ -29,14 +26,16 @@ class optional { optional() = default; // #A Only if not trivially destructible - ~optional() requires(not std::is_trivially_destructible_v) + ~optional() + requires(not std::is_trivially_destructible_v) { if(has_value) { value.as()->~T(); } } // #B If not trivially destructible and has Release method - ~optional() requires(not std::is_trivially_destructible_v and - HasRelease) + ~optional() + requires(not std::is_trivially_destructible_v and + HasRelease) { if(has_value) { value.as()->Release(); @@ -46,7 +45,8 @@ class optional { ~optional() = default; - optional(const optional&) requires std::is_copy_constructible_v + optional(const optional&) + requires std::is_copy_constructible_v = default; private: diff --git a/01.32-optional5/CMakeLists.txt b/01.32-optional5/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.32-optional5/CMakeLists.txt +++ b/01.32-optional5/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.32-optional5/main.cpp b/01.32-optional5/main.cpp index b8ca6ac..1116cc1 100644 --- a/01.32-optional5/main.cpp +++ b/01.32-optional5/main.cpp @@ -13,16 +13,12 @@ struct COMLike { void COMLike::Release() { - printf("release\n"); + puts("release"); } template -concept HasRelease = requires(T t) -{ - t.Release(); -}; +concept HasRelease = requires(T t) { t.Release(); }; -#if not defined(__clang__) template concept NotTriviallyDestructible = not std::is_trivially_destructible_v; @@ -33,16 +29,17 @@ class optional { optional() = default; // #A Only if not trivially destructible - ~optional() requires NotTriviallyDestructible; + ~optional() + requires NotTriviallyDestructible; // #B If not trivially destructible and has Release method - ~optional() requires NotTriviallyDestructible and - HasRelease; + ~optional() + requires NotTriviallyDestructible and HasRelease; ~optional() = default; - optional( - const optional&) requires std::is_copy_constructible_v + optional(const optional&) + requires std::is_copy_constructible_v = default; private: @@ -66,14 +63,15 @@ class optional { }; template -optional::~optional() requires NotTriviallyDestructible +optional::~optional() + requires NotTriviallyDestructible { if(has_value) { value.as()->~T(); } } template -optional::~optional() requires NotTriviallyDestructible && - HasRelease +optional::~optional() + requires NotTriviallyDestructible && HasRelease { if(has_value) { value.as()->Release(); @@ -81,8 +79,6 @@ optional::~optional() requires NotTriviallyDestructible && } } -#endif - struct NotCopyable { NotCopyable(const NotCopyable&) = delete; NotCopyable& operator=(const NotCopyable&) = delete; @@ -97,7 +93,6 @@ static_assert(not std::is_trivially_destructible_v< int main() { -#if not defined(__clang__) static_assert( not std::is_copy_constructible_v>); static_assert(std::is_copy_constructible_v>); @@ -109,8 +104,4 @@ int main() optional no{}; optional o{}; - -#else -# pragma message("not supported") -#endif } \ No newline at end of file diff --git a/01.33-optional6/CMakeLists.txt b/01.33-optional6/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.33-optional6/CMakeLists.txt +++ b/01.33-optional6/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.33-optional6/main.cpp b/01.33-optional6/main.cpp index 2ade93c..a6487e3 100644 --- a/01.33-optional6/main.cpp +++ b/01.33-optional6/main.cpp @@ -13,7 +13,7 @@ struct COMLike { void COMLike::Release() { - printf("release\n"); + puts("release"); } struct COMLikeTrivial { @@ -24,16 +24,12 @@ struct COMLikeTrivial { void COMLikeTrivial::Release() { - printf("release trivial\n"); + puts("release trivial"); } template -concept HasRelease = requires(T t) -{ - t.Release(); -}; +concept HasRelease = requires(T t) { t.Release(); }; -#if not defined(__clang__) template concept NotTriviallyDestructible = not std::is_trivially_destructible_v; @@ -44,22 +40,24 @@ class optional { optional() = default; // #A Only if not trivially destructible - ~optional() requires NotTriviallyDestructible; + ~optional() + requires NotTriviallyDestructible; // #B If not trivially destructible and has Release method - ~optional() requires NotTriviallyDestructible and - HasRelease; + ~optional() + requires NotTriviallyDestructible and HasRelease; // #C Trivial and has Release method - ~optional() requires HasRelease + ~optional() + requires HasRelease { if(has_value) { value.as()->Release(); } } ~optional() = default; - optional( - const optional&) requires std::is_copy_constructible_v + optional(const optional&) + requires std::is_copy_constructible_v = default; private: @@ -83,21 +81,21 @@ class optional { }; template -optional::~optional() requires NotTriviallyDestructible +optional::~optional() + requires NotTriviallyDestructible { if(has_value) { value.as()->~T(); } } template -optional::~optional() requires NotTriviallyDestructible && - HasRelease +optional::~optional() + requires NotTriviallyDestructible && HasRelease { if(has_value) { value.as()->Release(); value.as()->~T(); } } -#endif struct NotCopyable { NotCopyable(const NotCopyable&) = delete; @@ -115,7 +113,6 @@ static_assert(not std::is_trivially_destructible_v< int main() { -#if not defined(__clang__) static_assert( not std::is_copy_constructible_v>); static_assert(std::is_copy_constructible_v>); @@ -131,8 +128,4 @@ int main() optional o{}; optional ot{}; optional otd{}; - -#else -# pragma message("not supported") -#endif } \ No newline at end of file diff --git a/01.34-isSameConcept0/CMakeLists.txt b/01.34-isSameConcept0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.34-isSameConcept0/CMakeLists.txt +++ b/01.34-isSameConcept0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.34-isSameConcept0/main.cpp b/01.34-isSameConcept0/main.cpp index 088fb98..256f1df 100644 --- a/01.34-isSameConcept0/main.cpp +++ b/01.34-isSameConcept0/main.cpp @@ -10,14 +10,14 @@ template concept AlwaysTrue = true; template -requires IsSame + requires IsSame auto add(const T& t, const U& u) { return t + u; } template -requires IsSame and AlwaysTrue + requires IsSame and AlwaysTrue auto add(const T& t, const U& u) { return t + u; diff --git a/01.36-isSameConcept1/CMakeLists.txt b/01.36-isSameConcept1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.36-isSameConcept1/CMakeLists.txt +++ b/01.36-isSameConcept1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.36-isSameConcept1/main.cpp b/01.36-isSameConcept1/main.cpp index 88bfe13..9bfc3ca 100644 --- a/01.36-isSameConcept1/main.cpp +++ b/01.36-isSameConcept1/main.cpp @@ -11,7 +11,7 @@ concept AlwaysTrue = true; template // #A The arguments are swapped T, U vs U, T -requires IsSame + requires IsSame auto add(const T& t, const U& u) { return t + u; @@ -19,7 +19,7 @@ auto add(const T& t, const U& u) template // #B The arguments remain unchanged -requires IsSame and AlwaysTrue + requires IsSame and AlwaysTrue auto add(const T& t, const U& u) { return t + u; diff --git a/01.37-isSameConcept2/CMakeLists.txt b/01.37-isSameConcept2/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.37-isSameConcept2/CMakeLists.txt +++ b/01.37-isSameConcept2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.37-isSameConcept2/main.cpp b/01.37-isSameConcept2/main.cpp index b5493b2..f8c1dd8 100644 --- a/01.37-isSameConcept2/main.cpp +++ b/01.37-isSameConcept2/main.cpp @@ -14,7 +14,7 @@ concept AlwaysTrue = true; template // #A The arguments are swapped T, U vs U, T -requires IsSame + requires IsSame auto add(const T& t, const U& u) { return t + u; @@ -22,7 +22,7 @@ auto add(const T& t, const U& u) template // #B The arguments remain unchanged -requires IsSame and AlwaysTrue + requires IsSame and AlwaysTrue auto add(const T& t, const U& u) { return t + u; diff --git a/01.38-isSameConcept3/CMakeLists.txt b/01.38-isSameConcept3/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.38-isSameConcept3/CMakeLists.txt +++ b/01.38-isSameConcept3/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.38-isSameConcept3/main.cpp b/01.38-isSameConcept3/main.cpp index b04e0bc..8a8473b 100644 --- a/01.38-isSameConcept3/main.cpp +++ b/01.38-isSameConcept3/main.cpp @@ -14,16 +14,16 @@ concept AlwaysTrue = true; template // #A Inverting IsSame with not -requires(not IsSame) auto add(const T& t, const U& u) + requires(not IsSame) +auto add(const T& t, const U& u) { return t + u; } template // #B Inverting IsSame with not -requires((not IsSame)and AlwaysTrue) auto add( - const T& t, - const U& u) + requires((not IsSame) and AlwaysTrue) +auto add(const T& t, const U& u) { return t + u; } diff --git a/01.40-printSorted0/CMakeLists.txt b/01.40-printSorted0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/01.40-printSorted0/CMakeLists.txt +++ b/01.40-printSorted0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/01.42-printSorted1/CMakeLists.txt b/01.42-printSorted1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/01.42-printSorted1/CMakeLists.txt +++ b/01.42-printSorted1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/01.42-printSorted1/main.cpp b/01.42-printSorted1/main.cpp index 2476be7..ee09499 100644 --- a/01.42-printSorted1/main.cpp +++ b/01.42-printSorted1/main.cpp @@ -9,10 +9,7 @@ #include template -concept random_access_iterator = not requires(I t) -{ - t.sort(); -}; +concept random_access_iterator = not requires(I t) { t.sort(); }; template void PrintSorted(T c) @@ -32,10 +29,7 @@ void sortedVector() } template -concept HasSortMethod = requires(T t) -{ - t.sort(); -}; +concept HasSortMethod = requires(T t) { t.sort(); }; template void PrintSorted(T c) diff --git a/02.01-limitlessSequenceWithoutCoroutines0/CMakeLists.txt b/02.01-limitlessSequenceWithoutCoroutines0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/02.01-limitlessSequenceWithoutCoroutines0/CMakeLists.txt +++ b/02.01-limitlessSequenceWithoutCoroutines0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/02.03-limitlessSequenceWithFunctionTemplate0/CMakeLists.txt b/02.03-limitlessSequenceWithFunctionTemplate0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/02.03-limitlessSequenceWithFunctionTemplate0/CMakeLists.txt +++ b/02.03-limitlessSequenceWithFunctionTemplate0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/02.04-coroutineLimitlessSequence0/CMakeLists.txt b/02.04-coroutineLimitlessSequence0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/02.04-coroutineLimitlessSequence0/CMakeLists.txt +++ b/02.04-coroutineLimitlessSequence0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/02.08-parsingDataStream0/CMakeLists.txt b/02.08-parsingDataStream0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/02.08-parsingDataStream0/CMakeLists.txt +++ b/02.08-parsingDataStream0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/02.08-parsingDataStream0/main.cpp b/02.08-parsingDataStream0/main.cpp index 248107c..947d1ad 100644 --- a/02.08-parsingDataStream0/main.cpp +++ b/02.08-parsingDataStream0/main.cpp @@ -68,7 +68,7 @@ int main() auto frameCompleteHandler = [](std::string& res) { printf("CCCB: %s\n", res.c_str()); }; for(const auto& b : fakeBytes1) { ProcessNextByte(b, frameCompleteHandler); } - printf("----------\n"); + puts("----------"); const std::vector fakeBytes2{ byte{'W'}, byte{'o'}, byte{'r'}, byte{'l'}, byte{'d'}, ESC, SOF, byte{0x99}}; diff --git a/02.10-coroutineParsingDataStream0/CMakeLists.txt b/02.10-coroutineParsingDataStream0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/02.10-coroutineParsingDataStream0/CMakeLists.txt +++ b/02.10-coroutineParsingDataStream0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/02.10-coroutineParsingDataStream0/main.cpp b/02.10-coroutineParsingDataStream0/main.cpp index 2581a1c..45f9fb0 100644 --- a/02.10-coroutineParsingDataStream0/main.cpp +++ b/02.10-coroutineParsingDataStream0/main.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/02.18-coroutineParsingDataStream1/CMakeLists.txt b/02.18-coroutineParsingDataStream1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/02.18-coroutineParsingDataStream1/CMakeLists.txt +++ b/02.18-coroutineParsingDataStream1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/02.18-coroutineParsingDataStream1/main.cpp b/02.18-coroutineParsingDataStream1/main.cpp index 32b435c..8ecf8c2 100644 --- a/02.18-coroutineParsingDataStream1/main.cpp +++ b/02.18-coroutineParsingDataStream1/main.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/02.24-coroutineParsingDataStreamCustomAllocator0/CMakeLists.txt b/02.24-coroutineParsingDataStreamCustomAllocator0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/02.24-coroutineParsingDataStreamCustomAllocator0/CMakeLists.txt +++ b/02.24-coroutineParsingDataStreamCustomAllocator0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/02.24-coroutineParsingDataStreamCustomAllocator0/main.cpp b/02.24-coroutineParsingDataStreamCustomAllocator0/main.cpp index 7c8ee00..b9d6344 100644 --- a/02.24-coroutineParsingDataStreamCustomAllocator0/main.cpp +++ b/02.24-coroutineParsingDataStreamCustomAllocator0/main.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/02.25-coroutineParsingDataStreamCustomAllocator1/CMakeLists.txt b/02.25-coroutineParsingDataStreamCustomAllocator1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/02.25-coroutineParsingDataStreamCustomAllocator1/CMakeLists.txt +++ b/02.25-coroutineParsingDataStreamCustomAllocator1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/02.25-coroutineParsingDataStreamCustomAllocator1/main.cpp b/02.25-coroutineParsingDataStreamCustomAllocator1/main.cpp index 186f5e0..3116467 100644 --- a/02.25-coroutineParsingDataStreamCustomAllocator1/main.cpp +++ b/02.25-coroutineParsingDataStreamCustomAllocator1/main.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/02.27-coroutineParsingDataStreamException0/CMakeLists.txt b/02.27-coroutineParsingDataStreamException0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/02.27-coroutineParsingDataStreamException0/CMakeLists.txt +++ b/02.27-coroutineParsingDataStreamException0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/02.27-coroutineParsingDataStreamException0/main.cpp b/02.27-coroutineParsingDataStreamException0/main.cpp index f42dc33..2208195 100644 --- a/02.27-coroutineParsingDataStreamException0/main.cpp +++ b/02.27-coroutineParsingDataStreamException0/main.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -64,12 +65,12 @@ struct promise_type_base { std::suspend_always final_suspend() noexcept { - printf("final_suspend\n"); + puts("final_suspend"); return {}; } G get_return_object() { - printf("get_return_object\n"); + puts("get_return_object"); ThrowIf(Ex::GetReturnObject, "get_return_object"); return G{this}; @@ -77,7 +78,7 @@ struct promise_type_base { void unhandled_exception() { - printf("unhandled_exception\n"); + puts("unhandled_exception"); if(rethrow) { if(2 == rethrow) { auto exceptionPtr = std::current_exception(); @@ -93,7 +94,7 @@ struct promise_type_base { throw; } } else { - printf("do nothing\n"); + puts("do nothing"); } } diff --git a/03.01-rangesMotivation0/CMakeLists.txt b/03.01-rangesMotivation0/CMakeLists.txt index 9566747..47b1d42 100644 --- a/03.01-rangesMotivation0/CMakeLists.txt +++ b/03.01-rangesMotivation0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 11) diff --git a/03.02-rangesMotivation1/CMakeLists.txt b/03.02-rangesMotivation1/CMakeLists.txt index 9566747..47b1d42 100644 --- a/03.02-rangesMotivation1/CMakeLists.txt +++ b/03.02-rangesMotivation1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 11) diff --git a/03.03-rangesMotivation2/CMakeLists.txt b/03.03-rangesMotivation2/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/03.03-rangesMotivation2/CMakeLists.txt +++ b/03.03-rangesMotivation2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/03.03-rangesMotivation2/main.cpp b/03.03-rangesMotivation2/main.cpp index e156fec..39ac2a8 100644 --- a/03.03-rangesMotivation2/main.cpp +++ b/03.03-rangesMotivation2/main.cpp @@ -1,10 +1,9 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include +#include +#include +#include int main() { @@ -12,11 +11,4 @@ int main() const std::string secondText{"Bello"}; const bool equal = std::ranges::equal(firstText, secondText); -} -#else -int main() -{ - -# pragma message("not supported") -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/03.04-twoStepUsing0/CMakeLists.txt b/03.04-twoStepUsing0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/03.04-twoStepUsing0/CMakeLists.txt +++ b/03.04-twoStepUsing0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/03.04-twoStepUsing0/main.cpp b/03.04-twoStepUsing0/main.cpp index 8f0f616..f87a5ef 100644 --- a/03.04-twoStepUsing0/main.cpp +++ b/03.04-twoStepUsing0/main.cpp @@ -4,8 +4,8 @@ #include #ifdef WILL_NOT_COMPILE -struct Container {}; // #A Container without begin -int* begin(Container); // #B Free-function begin for Container +struct Container {}; // #A Container without begin +int* begin(Container); // #B Free-function begin for Container struct OtherContainer { // #C Container with begin int* begin(); diff --git a/03.05-twoStepUsing1/CMakeLists.txt b/03.05-twoStepUsing1/CMakeLists.txt index 6c3ef8c..7a3382d 100644 --- a/03.05-twoStepUsing1/CMakeLists.txt +++ b/03.05-twoStepUsing1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) @@ -83,7 +83,8 @@ else() else() add_definitions(-fcoroutines) # required for GCC-10 - + add_definitions(-Wno-unused-result) + endif() endif() diff --git a/03.06-twoStepUsing2/CMakeLists.txt b/03.06-twoStepUsing2/CMakeLists.txt index 6c3ef8c..7a3382d 100644 --- a/03.06-twoStepUsing2/CMakeLists.txt +++ b/03.06-twoStepUsing2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) @@ -83,7 +83,8 @@ else() else() add_definitions(-fcoroutines) # required for GCC-10 - + add_definitions(-Wno-unused-result) + endif() endif() diff --git a/03.07-rangesSafety0/CMakeLists.txt b/03.07-rangesSafety0/CMakeLists.txt index 6c1466a..9a169de 100644 --- a/03.07-rangesSafety0/CMakeLists.txt +++ b/03.07-rangesSafety0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/03.08-rangesSafety1/CMakeLists.txt b/03.08-rangesSafety1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/03.08-rangesSafety1/CMakeLists.txt +++ b/03.08-rangesSafety1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/03.09-rangesMotivationComposability0/CMakeLists.txt b/03.09-rangesMotivationComposability0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/03.09-rangesMotivationComposability0/CMakeLists.txt +++ b/03.09-rangesMotivationComposability0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/03.09-rangesMotivationComposability0/main.cpp b/03.09-rangesMotivationComposability0/main.cpp index 971478f..4f9e1a6 100644 --- a/03.09-rangesMotivationComposability0/main.cpp +++ b/03.09-rangesMotivationComposability0/main.cpp @@ -14,8 +14,8 @@ void stl() { std::vector numbers{2, 3, 4, 5, 6}; // #A - std::vector oddNumbers{}; // #B - std::copy_if(begin(numbers), // #C + std::vector oddNumbers{}; // #B + std::copy_if(begin(numbers), // #C end(numbers), std::back_inserter(oddNumbers), is_odd); diff --git a/03.10-rangesMotivationComposability1/CMakeLists.txt b/03.10-rangesMotivationComposability1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/03.10-rangesMotivationComposability1/CMakeLists.txt +++ b/03.10-rangesMotivationComposability1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/03.10-rangesMotivationComposability1/main.cpp b/03.10-rangesMotivationComposability1/main.cpp index eb869da..3666680 100644 --- a/03.10-rangesMotivationComposability1/main.cpp +++ b/03.10-rangesMotivationComposability1/main.cpp @@ -1,11 +1,10 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include -# include +#include +#include +#include +#include bool is_odd(int num) { @@ -30,10 +29,4 @@ void ranges() int main() { ranges(); -} -#else -int main() -{ -# pragma message("not supported") -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/03.11-aRange0/CMakeLists.txt b/03.11-aRange0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/03.11-aRange0/CMakeLists.txt +++ b/03.11-aRange0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/03.13-rangesCommonView1/CMakeLists.txt b/03.13-rangesCommonView1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/03.13-rangesCommonView1/CMakeLists.txt +++ b/03.13-rangesCommonView1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/03.14-rangesCommonView2/CMakeLists.txt b/03.14-rangesCommonView2/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/03.14-rangesCommonView2/CMakeLists.txt +++ b/03.14-rangesCommonView2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/03.14-rangesCommonView2/main.cpp b/03.14-rangesCommonView2/main.cpp index 1c2a341..076ec98 100644 --- a/03.14-rangesCommonView2/main.cpp +++ b/03.14-rangesCommonView2/main.cpp @@ -1,11 +1,10 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include -# include +#include +#include +#include +#include int main() { @@ -17,10 +16,4 @@ int main() auto res = std::accumulate(rng.begin(), rng.end(), 0); std::cout << res << '\n'; -} -#else -int main() -{ -# pragma message("not supported") -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/03.15-rangesProjection0/CMakeLists.txt b/03.15-rangesProjection0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/03.15-rangesProjection0/CMakeLists.txt +++ b/03.15-rangesProjection0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/03.17-rangesProjection1/CMakeLists.txt b/03.17-rangesProjection1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/03.17-rangesProjection1/CMakeLists.txt +++ b/03.17-rangesProjection1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/03.17-rangesProjection1/main.cpp b/03.17-rangesProjection1/main.cpp index 16b2372..53c9348 100644 --- a/03.17-rangesProjection1/main.cpp +++ b/03.17-rangesProjection1/main.cpp @@ -1,12 +1,11 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include int main() { @@ -22,13 +21,4 @@ int main() std::ranges::sort(books, {}, &Book::title); for(const auto& book : books) { std::cout << book.title << '\n'; } -} - -#else - -int main() -{ -# pragma message("not supported") -} - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/03.18-rangesMotivationComposability2/CMakeLists.txt b/03.18-rangesMotivationComposability2/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/03.18-rangesMotivationComposability2/CMakeLists.txt +++ b/03.18-rangesMotivationComposability2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/03.18-rangesMotivationComposability2/main.cpp b/03.18-rangesMotivationComposability2/main.cpp index 197c28c..7465b24 100644 --- a/03.18-rangesMotivationComposability2/main.cpp +++ b/03.18-rangesMotivationComposability2/main.cpp @@ -1,11 +1,10 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include -# include +#include +#include +#include +#include bool is_odd(int num) { @@ -14,7 +13,7 @@ bool is_odd(int num) void ranges() { - std::vector numbers{2, 3, 4, 5, 6}; // #A + std::vector numbers{2, 3, 4, 5, 6}; // #A auto filter = std::views::filter(numbers, is_odd); // #A @@ -33,10 +32,4 @@ void ranges() int main() { ranges(); -} -#else -int main() -{ -# pragma message("not supported") -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/03.19-rangesCustomAdaptor0/CMakeLists.txt b/03.19-rangesCustomAdaptor0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/03.19-rangesCustomAdaptor0/CMakeLists.txt +++ b/03.19-rangesCustomAdaptor0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/03.19-rangesCustomAdaptor0/main.cpp b/03.19-rangesCustomAdaptor0/main.cpp index 9c434d4..f411657 100644 --- a/03.19-rangesCustomAdaptor0/main.cpp +++ b/03.19-rangesCustomAdaptor0/main.cpp @@ -1,12 +1,11 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include int main() { @@ -20,13 +19,4 @@ int main() [suffix](auto i) { return std::to_string(i) + suffix; }); for(const auto& e : subView) { std::cout << e << '\n'; } -} - -#else - -int main() -{ -# pragma message("not supported") -} - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/03.20-rangesCustomAdaptor1/CMakeLists.txt b/03.20-rangesCustomAdaptor1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/03.20-rangesCustomAdaptor1/CMakeLists.txt +++ b/03.20-rangesCustomAdaptor1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/03.20-rangesCustomAdaptor1/main.cpp b/03.20-rangesCustomAdaptor1/main.cpp index d21fb6d..a1a482f 100644 --- a/03.20-rangesCustomAdaptor1/main.cpp +++ b/03.20-rangesCustomAdaptor1/main.cpp @@ -1,12 +1,11 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include // #B A function returning a callable auto addCurrency(const std::string& suffix) @@ -27,13 +26,4 @@ int main() | addCurrency(" €"); for(const auto& e : subView) { std::cout << e << '\n'; } -} - -#else - -int main() -{ -# pragma message("not supported") -} - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/03.22-rangesNamespaces0/CMakeLists.txt b/03.22-rangesNamespaces0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/03.22-rangesNamespaces0/CMakeLists.txt +++ b/03.22-rangesNamespaces0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/03.22-rangesNamespaces0/main.cpp b/03.22-rangesNamespaces0/main.cpp index 87dc431..90f771a 100644 --- a/03.22-rangesNamespaces0/main.cpp +++ b/03.22-rangesNamespaces0/main.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: MIT namespace std { - namespace ranges { /* ... */ // improved algorithms and views - namespace views { /* ... */ - } // namespace views - } // namespace ranges + namespace ranges { /* ... */ // improved algorithms and views + namespace views { /* ... */ + } // namespace views + } // namespace ranges namespace views = ranges::views; // shortcut for the adaptors } // namespace std diff --git a/03.23-rangesCustomTakeView0/CMakeLists.txt b/03.23-rangesCustomTakeView0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/03.23-rangesCustomTakeView0/CMakeLists.txt +++ b/03.23-rangesCustomTakeView0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/03.23-rangesCustomTakeView0/main.cpp b/03.23-rangesCustomTakeView0/main.cpp index 270ed7b..c31b807 100644 --- a/03.23-rangesCustomTakeView0/main.cpp +++ b/03.23-rangesCustomTakeView0/main.cpp @@ -1,16 +1,15 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include +#include +#include +#include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include namespace rv = std::ranges::views; @@ -47,12 +46,12 @@ class custom_take_view template // #G Deduction guide custom_take_view(R&& base, std::ranges::range_difference_t) - ->custom_take_view>; + -> custom_take_view>; namespace details { template // #A Only integrals struct custom_take_range_adaptor_closure { - T count_; // #B Store the count + T count_; // #B Store the count constexpr custom_take_range_adaptor_closure(T count) : count_{count} {} @@ -99,13 +98,4 @@ int main() auto v = n | rv::filter(is_even) | views::custom_take(2); std::ranges::copy(v, std::ostream_iterator(std::cout, " ")); -} - -#else - -int main() -{ -# pragma message("not supported") -} - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/03.29-rangesCustomTakeView1/CMakeLists.txt b/03.29-rangesCustomTakeView1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/03.29-rangesCustomTakeView1/CMakeLists.txt +++ b/03.29-rangesCustomTakeView1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/03.29-rangesCustomTakeView1/main.cpp b/03.29-rangesCustomTakeView1/main.cpp index 4ea09a1..ade2236 100644 --- a/03.29-rangesCustomTakeView1/main.cpp +++ b/03.29-rangesCustomTakeView1/main.cpp @@ -1,18 +1,17 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include namespace rv = std::ranges::views; template -requires std::ranges::view + requires std::ranges::view class custom_take_view : public std::ranges::view_interface> { private: @@ -91,13 +90,4 @@ int main() auto v = n | rv::filter(is_even) | views::custom_take(2); std::ranges::copy(v, std::ostream_iterator(std::cout, " ")); -} - -#else - -int main() -{ -# pragma message("not supported") -} - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/04.01-includeHell0/CMakeLists.txt b/04.01-includeHell0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/04.01-includeHell0/CMakeLists.txt +++ b/04.01-includeHell0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/04.03-moduleSkeleton0/CMakeLists.txt b/04.03-moduleSkeleton0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/04.03-moduleSkeleton0/CMakeLists.txt +++ b/04.03-moduleSkeleton0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/04.04-namespaceDetails0/CMakeLists.txt b/04.04-namespaceDetails0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/04.04-namespaceDetails0/CMakeLists.txt +++ b/04.04-namespaceDetails0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/04.05-namespaceDetails1/CMakeLists.txt b/04.05-namespaceDetails1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/04.05-namespaceDetails1/CMakeLists.txt +++ b/04.05-namespaceDetails1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/04.06-downWithDebug0/CMakeLists.txt b/04.06-downWithDebug0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/04.06-downWithDebug0/CMakeLists.txt +++ b/04.06-downWithDebug0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/04.10-downWithDebug1/CMakeLists.txt b/04.10-downWithDebug1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/04.10-downWithDebug1/CMakeLists.txt +++ b/04.10-downWithDebug1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/04.11-inClassMemberFunction0/CMakeLists.txt b/04.11-inClassMemberFunction0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/04.11-inClassMemberFunction0/CMakeLists.txt +++ b/04.11-inClassMemberFunction0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/04.12-assertImpl0/CMakeLists.txt b/04.12-assertImpl0/CMakeLists.txt index 9566747..47b1d42 100644 --- a/04.12-assertImpl0/CMakeLists.txt +++ b/04.12-assertImpl0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 11) diff --git a/05.01-stdFmtStockIndex0/CMakeLists.txt b/05.01-stdFmtStockIndex0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/05.01-stdFmtStockIndex0/CMakeLists.txt +++ b/05.01-stdFmtStockIndex0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/05.01-stdFmtStockIndex0/main.cpp b/05.01-stdFmtStockIndex0/main.cpp index eea7ff1..0976c70 100644 --- a/05.01-stdFmtStockIndex0/main.cpp +++ b/05.01-stdFmtStockIndex0/main.cpp @@ -1,13 +1,12 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include class StockIndex { std::string mName{}; @@ -101,7 +100,7 @@ void WithIostreamOperator() } namespace withLocale { - //# include "withIostreamOperatorLocale.cpp" + // # include "withIostreamOperatorLocale.cpp" } void WithStdFormat() @@ -130,11 +129,4 @@ int main() std::cout << '\n'; WithStdFormat(); -} - -#else -int main() -{ -# pragma message("not supported") -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/05.03-digitSeparator0/CMakeLists.txt b/05.03-digitSeparator0/CMakeLists.txt index 14b1ad9..2811d7c 100644 --- a/05.03-digitSeparator0/CMakeLists.txt +++ b/05.03-digitSeparator0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 14) diff --git a/05.04-stdFmtStockIndexIostream0/CMakeLists.txt b/05.04-stdFmtStockIndexIostream0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/05.04-stdFmtStockIndexIostream0/CMakeLists.txt +++ b/05.04-stdFmtStockIndexIostream0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/05.07-stdFmtStockIndexIostreamLocalized0/CMakeLists.txt b/05.07-stdFmtStockIndexIostreamLocalized0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/05.07-stdFmtStockIndexIostreamLocalized0/CMakeLists.txt +++ b/05.07-stdFmtStockIndexIostreamLocalized0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/05.10-stdFmtEscape0/CMakeLists.txt b/05.10-stdFmtEscape0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/05.10-stdFmtEscape0/CMakeLists.txt +++ b/05.10-stdFmtEscape0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/05.10-stdFmtEscape0/main.cpp b/05.10-stdFmtEscape0/main.cpp index f5770b5..d962051 100644 --- a/05.10-stdFmtEscape0/main.cpp +++ b/05.10-stdFmtEscape0/main.cpp @@ -1,18 +1,13 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include +#include +#include +#include int main() { std::cout << std::format("Having the }} in a {}.", "string"); std::cout << '\n'; -} - -#else -int main() {} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/05.11-stdFmtLocale0/CMakeLists.txt b/05.11-stdFmtLocale0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/05.11-stdFmtLocale0/CMakeLists.txt +++ b/05.11-stdFmtLocale0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/05.11-stdFmtLocale0/main.cpp b/05.11-stdFmtLocale0/main.cpp index 8017fde..8a770a0 100644 --- a/05.11-stdFmtLocale0/main.cpp +++ b/05.11-stdFmtLocale0/main.cpp @@ -1,18 +1,16 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include using namespace std::literals; int main() { -# if not(defined(__GNUC__) && !defined(__clang__)) const double pi = 3.14; const int i = 1'024; @@ -34,10 +32,4 @@ int main() std::cout << "\nint with format(...) after setting global loc\n"; std::cout << std::format("1'024 in US: {:L}\n", i); - -# endif -} - -#else -int main() {} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/05.12-stdFmtFloatFormatting0/CMakeLists.txt b/05.12-stdFmtFloatFormatting0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/05.12-stdFmtFloatFormatting0/CMakeLists.txt +++ b/05.12-stdFmtFloatFormatting0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/05.12-stdFmtFloatFormatting0/main.cpp b/05.12-stdFmtFloatFormatting0/main.cpp index df65e9f..d889249 100644 --- a/05.12-stdFmtFloatFormatting0/main.cpp +++ b/05.12-stdFmtFloatFormatting0/main.cpp @@ -1,10 +1,9 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include +#include +#include +#include std::string Use() { @@ -21,13 +20,4 @@ int main() auto s = Use(); std::cout << s << '\n'; -} - -#else - -int main() -{ -# pragma message("not supported") -} - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/05.13-stdFmtStockIndexCustomFormatter0/CMakeLists.txt b/05.13-stdFmtStockIndexCustomFormatter0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/05.13-stdFmtStockIndexCustomFormatter0/CMakeLists.txt +++ b/05.13-stdFmtStockIndexCustomFormatter0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/05.13-stdFmtStockIndexCustomFormatter0/main.cpp b/05.13-stdFmtStockIndexCustomFormatter0/main.cpp index def06db..7514247 100644 --- a/05.13-stdFmtStockIndexCustomFormatter0/main.cpp +++ b/05.13-stdFmtStockIndexCustomFormatter0/main.cpp @@ -1,13 +1,12 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include class StockIndex { std::string mName{}; @@ -57,12 +56,9 @@ std::vector GetIndices() template<> struct std::formatter { - constexpr auto parse(std::format_parse_context& ctx) - { - return ctx.begin(); - } + constexpr auto parse(auto& ctx) { return ctx.begin(); } - auto format(const StockIndex& index, std::format_context& ctx) + auto format(const StockIndex& index, auto& ctx) const { return std::format_to(ctx.out(), "{:10} {:>8.2f} {:>6.2f} {:.2f}%", @@ -78,11 +74,4 @@ int main() for(const auto& index : GetIndices()) { std::cout << std::format("{}\n", index); } -} - -#else -int main() -{ -# pragma message("not supported") -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/05.15-stdFmtStockIndexCustomFormatter1/CMakeLists.txt b/05.15-stdFmtStockIndexCustomFormatter1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/05.15-stdFmtStockIndexCustomFormatter1/CMakeLists.txt +++ b/05.15-stdFmtStockIndexCustomFormatter1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/05.15-stdFmtStockIndexCustomFormatter1/main.cpp b/05.15-stdFmtStockIndexCustomFormatter1/main.cpp index 22301a2..35d94dc 100644 --- a/05.15-stdFmtStockIndexCustomFormatter1/main.cpp +++ b/05.15-stdFmtStockIndexCustomFormatter1/main.cpp @@ -1,14 +1,13 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include +#include using namespace std::literals; @@ -64,7 +63,7 @@ struct std::formatter { IndexFormat indexFormat{IndexFormat::Normal}; - constexpr auto parse(format_parse_context& ctx) + constexpr auto parse(auto& ctx) { auto it = ctx.begin(); auto end = ctx.end(); @@ -86,7 +85,7 @@ struct std::formatter { return it; } - auto format(const StockIndex& index, std::format_context& ctx) + auto format(const StockIndex& index, auto& ctx) const { if(IndexFormat::Short == indexFormat) { return std::format_to(ctx.out(), @@ -123,11 +122,4 @@ int main() for(const auto& index : GetIndices()) { std::cout << std::format("{:p}\n", index); } -} - -#else -int main() -{ -# pragma message("not supported") -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/05.17-stdFmtStockIndexCustomFormatter2/CMakeLists.txt b/05.17-stdFmtStockIndexCustomFormatter2/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/05.17-stdFmtStockIndexCustomFormatter2/CMakeLists.txt +++ b/05.17-stdFmtStockIndexCustomFormatter2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/05.17-stdFmtStockIndexCustomFormatter2/main.cpp b/05.17-stdFmtStockIndexCustomFormatter2/main.cpp index 5e43431..eff51bc 100644 --- a/05.17-stdFmtStockIndexCustomFormatter2/main.cpp +++ b/05.17-stdFmtStockIndexCustomFormatter2/main.cpp @@ -3,14 +3,13 @@ // use with LC_ALL=de_DE.UTF-8 ./a.out -#if __has_include() and not defined(__clang__) -# include -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include +#include using namespace std::literals; @@ -67,7 +66,7 @@ struct std::formatter { // #A New member to track whether the formatting is localized bool localized = false; - constexpr auto parse(std::format_parse_context& ctx) + constexpr auto parse(auto& ctx) { auto it = ctx.begin(); @@ -97,7 +96,7 @@ struct std::formatter { return it; } - auto format(const StockIndex& index, std::format_context& ctx) + auto format(const StockIndex& index, auto& ctx) const { // #D Add localized const auto locFloat{localized ? "L"s : ""s}; @@ -140,11 +139,4 @@ int main() for(const auto& index : GetIndices()) { std::cout << std::format("{:Lp}\n", index); } -} - -#else -int main() -{ -# pragma message("not supported") -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/05.19-stdFmtFormattingShares0/CMakeLists.txt b/05.19-stdFmtFormattingShares0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/05.19-stdFmtFormattingShares0/CMakeLists.txt +++ b/05.19-stdFmtFormattingShares0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/05.19-stdFmtFormattingShares0/main.cpp b/05.19-stdFmtFormattingShares0/main.cpp index a2930ea..5b3ec92 100644 --- a/05.19-stdFmtFormattingShares0/main.cpp +++ b/05.19-stdFmtFormattingShares0/main.cpp @@ -1,13 +1,12 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include +#include class Share { std::string mName; @@ -60,11 +59,4 @@ int main() { WithStdFormat(); WithStdFormatUseArgumentIndex(); -} - -#else -int main() -{ -# pragma message("not supported") -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/05.21-stdFmtFormatTo0/CMakeLists.txt b/05.21-stdFmtFormatTo0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/05.21-stdFmtFormatTo0/CMakeLists.txt +++ b/05.21-stdFmtFormatTo0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/05.21-stdFmtFormatTo0/main.cpp b/05.21-stdFmtFormatTo0/main.cpp index 6141b45..858de3f 100644 --- a/05.21-stdFmtFormatTo0/main.cpp +++ b/05.21-stdFmtFormatTo0/main.cpp @@ -1,12 +1,11 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include int main() { @@ -17,11 +16,4 @@ int main() for(const auto& c : buffer) { std::cout << c; } std::cout << '\n'; -} - -#else -int main() -{ -# pragma message("not supported") -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/05.22-stdFmtFormatTo1/CMakeLists.txt b/05.22-stdFmtFormatTo1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/05.22-stdFmtFormatTo1/CMakeLists.txt +++ b/05.22-stdFmtFormatTo1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/05.22-stdFmtFormatTo1/main.cpp b/05.22-stdFmtFormatTo1/main.cpp index 096395e..117f12c 100644 --- a/05.22-stdFmtFormatTo1/main.cpp +++ b/05.22-stdFmtFormatTo1/main.cpp @@ -1,12 +1,11 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include using namespace std::literals; @@ -23,11 +22,4 @@ int main() for(const auto& c : buffer) { std::cout << c; } std::cout << '\n'; -} - -#else -int main() -{ -# pragma message("not supported") -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/05.23-stdFmtFormatTo2/CMakeLists.txt b/05.23-stdFmtFormatTo2/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/05.23-stdFmtFormatTo2/CMakeLists.txt +++ b/05.23-stdFmtFormatTo2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/05.23-stdFmtFormatTo2/main.cpp b/05.23-stdFmtFormatTo2/main.cpp index 7b3e1ee..5b40804 100644 --- a/05.23-stdFmtFormatTo2/main.cpp +++ b/05.23-stdFmtFormatTo2/main.cpp @@ -1,12 +1,11 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include int main() { @@ -16,11 +15,4 @@ int main() for(const auto& c : buffer) { std::cout << c; } std::cout << '\n'; -} - -#else -int main() -{ -# pragma message("not supported") -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/05.24-stdFmtFormatToN0/CMakeLists.txt b/05.24-stdFmtFormatToN0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/05.24-stdFmtFormatToN0/CMakeLists.txt +++ b/05.24-stdFmtFormatToN0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/05.24-stdFmtFormatToN0/main.cpp b/05.24-stdFmtFormatToN0/main.cpp index 870853f..763eb41 100644 --- a/05.24-stdFmtFormatToN0/main.cpp +++ b/05.24-stdFmtFormatToN0/main.cpp @@ -1,11 +1,10 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include -# include +#include +#include +#include +#include int main() { @@ -14,11 +13,4 @@ int main() buffer.data(), buffer.size() - 1, "{}, {}", "Hello", "World"); std::cout << buffer.data() << '\n'; -} - -#else -int main() -{ -# pragma message("not supported") -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/05.25-stdFmtCustomLogger0/CMakeLists.txt b/05.25-stdFmtCustomLogger0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/05.25-stdFmtCustomLogger0/CMakeLists.txt +++ b/05.25-stdFmtCustomLogger0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/05.25-stdFmtCustomLogger0/main.cpp b/05.25-stdFmtCustomLogger0/main.cpp index b7b0814..82cd85c 100644 --- a/05.25-stdFmtCustomLogger0/main.cpp +++ b/05.25-stdFmtCustomLogger0/main.cpp @@ -1,26 +1,33 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include -# include +#include +#include +#include +#include using namespace std::literals; -enum LogLevel { Info, Warning, Error }; +enum class LogLevel { Info, Warning, Error }; + +// Part of C++23's STL +template +constexpr std::underlying_type_t to_underlying(T value) +{ + return static_cast>(value); +} template<> -struct std::formatter : std::formatter { - inline static const char* LEVEL_NAMES[] = {"Info", - "Warning", - "Error"}; +struct std::formatter +: std::formatter { + inline static std::array levelNames{"Info"sv, + "Warning"sv, + "Error"sv}; - auto format(LogLevel c, format_context& ctx) + auto format(LogLevel c, auto& ctx) const { - return std::formatter::format(LEVEL_NAMES[c], - ctx); + return std::formatter::format( + levelNames.at(to_underlying(c)), ctx); } }; @@ -43,11 +50,4 @@ int main() errno = 4; log(LogLevel::Error, "Unknown stock, errno {}", errno); -} - -#else -int main() -{ -# pragma message("not supported") -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/05.27-stdFmtCustomLogger1/CMakeLists.txt b/05.27-stdFmtCustomLogger1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/05.27-stdFmtCustomLogger1/CMakeLists.txt +++ b/05.27-stdFmtCustomLogger1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/05.27-stdFmtCustomLogger1/main.cpp b/05.27-stdFmtCustomLogger1/main.cpp index 3a227d7..02c0812 100644 --- a/05.27-stdFmtCustomLogger1/main.cpp +++ b/05.27-stdFmtCustomLogger1/main.cpp @@ -1,24 +1,32 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) +#if __has_include() # include # include # include # include +// Part of C++23's STL +template +constexpr std::underlying_type_t to_underlying(T value) +{ + return static_cast>(value); +} + enum LogLevel { Info, Warning, Error }; template<> -struct std::formatter : std::formatter { - inline static const char* LEVEL_NAMES[] = {"Info", - "Warning", - "Error"}; +struct std::formatter +: std::formatter { + inline static std::array levelNames{"Info"sv, + "Warning"sv, + "Error"sv}; - auto format(LogLevel c, format_context& ctx) + auto format(LogLevel c, auto& ctx) const { - return std::formatter::format(LEVEL_NAMES[c], - ctx); + return std::formatter::format( + levelNames.at(to_underlying(c)), ctx); } }; @@ -51,8 +59,10 @@ int main() } #else + int main() { # pragma message("not supported") } + #endif \ No newline at end of file diff --git a/05.29-stdFmtCustomLogger2/CMakeLists.txt b/05.29-stdFmtCustomLogger2/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/05.29-stdFmtCustomLogger2/CMakeLists.txt +++ b/05.29-stdFmtCustomLogger2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/05.29-stdFmtCustomLogger2/main.cpp b/05.29-stdFmtCustomLogger2/main.cpp index a7f2804..217e666 100644 --- a/05.29-stdFmtCustomLogger2/main.cpp +++ b/05.29-stdFmtCustomLogger2/main.cpp @@ -1,26 +1,32 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include( \ - ) and not defined(__clang__) && not (defined(__GNUC__) && !defined(__clang__)) -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include + +// Part of C++23's STL +template +constexpr std::underlying_type_t to_underlying(T value) +{ + return static_cast>(value); +} enum LogLevel { Info, Warning, Error }; template<> -struct std::formatter : std::formatter { - inline static const char* level_names[] = {"Info", - "Warning", - "Error"}; +struct std::formatter +: std::formatter { + inline static std::array levelNames{"Info"sv, + "Warning"sv, + "Error"sv}; - auto format(LogLevel c, format_context& ctx) + auto format(LogLevel c, auto& ctx) const { - return std::formatter::format(level_names[c], - ctx); + return std::formatter::format( + levelNames.at(to_underlying(c)), ctx); } }; @@ -81,13 +87,4 @@ int main() errno = 4; log(LogLevel::Error, "Unknown stock, errno:", errno); -} - -#else - -int main() -{ -# pragma message("not supported") -} - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/05.32-stdFmtCustomLogger4/CMakeLists.txt b/05.32-stdFmtCustomLogger4/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/05.32-stdFmtCustomLogger4/CMakeLists.txt +++ b/05.32-stdFmtCustomLogger4/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/05.32-stdFmtCustomLogger4/main.cpp b/05.32-stdFmtCustomLogger4/main.cpp index 6aa4258..d1ab8a7 100644 --- a/05.32-stdFmtCustomLogger4/main.cpp +++ b/05.32-stdFmtCustomLogger4/main.cpp @@ -1,25 +1,34 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include( \ - ) and not defined(__clang__) && not defined(_MSC_VER) -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include + +using namespace std::string_view_literals; +using namespace std::string_literals; + +// Part of C++23's STL +template +constexpr std::underlying_type_t to_underlying(T value) +{ + return static_cast>(value); +} enum LogLevel { Info, Warning, Error }; template<> -struct std::formatter : std::formatter { - inline static const char* level_names[] = {"Info", - "Warning", - "Error"}; +struct std::formatter : std::formatter { + inline static std::array levelNames{"Info"sv, + "Warning"sv, + "Error"sv}; - auto format(LogLevel c, format_context& ctx) + auto format(LogLevel c, auto& ctx) const { - return std::formatter::format(level_names[c], ctx); + return std::formatter::format( + levelNames.at(to_underlying(c)), ctx); } }; @@ -38,17 +47,17 @@ constexpr auto makeBraces() return braces; } -std::time_t GetTime() +std::chrono::time_point GetTime() { // return std::time(nullptr); - return 1605722947; + // return 1605722947; + return std::chrono::system_clock::now(); } void vlog(std::string_view fmt, std::format_args&& args) { - const std::time_t t = GetTime(); - std::clog << std::format("[{:%Y-%m-%d-%H:%M:%S}] ", - *std::localtime(&t)) + const auto t = GetTime(); + std::clog << std::format("[{:%Y-%m-%d-%H:%M:%S}] "sv, t) << std::vformat(fmt, args); } @@ -64,18 +73,11 @@ constexpr void log(LogLevel level, const auto&... args) int main() { int x{4}; - std::string share{"Amazon"}; + std::string share{"Amazon"s}; double d{3'117.02}; - log(LogLevel::Info, "Share price", share, "very high:", d); + log(LogLevel::Info, "Share price"sv, share, "very high:"sv, d); errno = 4; - log(LogLevel::Error, "Unknown stock, errno", errno); -} - -#else -int main() -{ -# pragma message("not supported") -} -#endif \ No newline at end of file + log(LogLevel::Error, "Unknown stock, errno"sv, errno); +} \ No newline at end of file diff --git a/06.01-equalComparOfMRN0/CMakeLists.txt b/06.01-equalComparOfMRN0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/06.01-equalComparOfMRN0/CMakeLists.txt +++ b/06.01-equalComparOfMRN0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/06.02-equalComparOfMRN1/CMakeLists.txt b/06.02-equalComparOfMRN1/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/06.02-equalComparOfMRN1/CMakeLists.txt +++ b/06.02-equalComparOfMRN1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/06.04-equalComparOfMRN2/CMakeLists.txt b/06.04-equalComparOfMRN2/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/06.04-equalComparOfMRN2/CMakeLists.txt +++ b/06.04-equalComparOfMRN2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/06.05-equalComparOfMRN3/CMakeLists.txt b/06.05-equalComparOfMRN3/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/06.05-equalComparOfMRN3/CMakeLists.txt +++ b/06.05-equalComparOfMRN3/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/06.06-orderingComparisonString0/CMakeLists.txt b/06.06-orderingComparisonString0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/06.06-orderingComparisonString0/CMakeLists.txt +++ b/06.06-orderingComparisonString0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/06.06-orderingComparisonString0/main.cpp b/06.06-orderingComparisonString0/main.cpp index aea2088..88556c9 100644 --- a/06.06-orderingComparisonString0/main.cpp +++ b/06.06-orderingComparisonString0/main.cpp @@ -41,22 +41,22 @@ class String { friend bool operator>(const String& a, const String& b) { - return Ordering::GreaterThan == Compare(a, b); + return (b < a); } friend bool operator<=(const String& a, const String& b) { - return Ordering::GreaterThan != Compare(a, b); + return !(b < a); } friend bool operator>=(const String& a, const String& b) { - return Ordering::LessThan != Compare(a, b); + return !(a < b); } private: - const char* mData; - const size_t mLen; + const char* mData{}; + const size_t mLen{}; // #E The compare function which does the actual comparison. static Ordering Compare(const String& a, const String& b); diff --git a/06.07-orderingComparisonString1/CMakeLists.txt b/06.07-orderingComparisonString1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/06.07-orderingComparisonString1/CMakeLists.txt +++ b/06.07-orderingComparisonString1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/06.08-orderingComparisonString2/CMakeLists.txt b/06.08-orderingComparisonString2/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/06.08-orderingComparisonString2/CMakeLists.txt +++ b/06.08-orderingComparisonString2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/06.08-orderingComparisonString2/main.cpp b/06.08-orderingComparisonString2/main.cpp index 6380a81..c9b59d2 100644 --- a/06.08-orderingComparisonString2/main.cpp +++ b/06.08-orderingComparisonString2/main.cpp @@ -25,7 +25,7 @@ class String { { if(mLen != other.mLen) { return false; } // #B We already had this - return Compare(*this, other) == 0; // #C Compare does the work + return Compare(*this, other) == 0; // #C Compare does the work } private: diff --git a/06.09-orderingComparisonString3/CMakeLists.txt b/06.09-orderingComparisonString4/CMakeLists.txt similarity index 97% rename from 06.09-orderingComparisonString3/CMakeLists.txt rename to 06.09-orderingComparisonString4/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/06.09-orderingComparisonString3/CMakeLists.txt +++ b/06.09-orderingComparisonString4/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/06.09-orderingComparisonString4/main.cpp b/06.09-orderingComparisonString4/main.cpp new file mode 100644 index 0000000..7bae787 --- /dev/null +++ b/06.09-orderingComparisonString4/main.cpp @@ -0,0 +1,64 @@ +// Copyright (c) Andreas Fertig. +// SPDX-License-Identifier: MIT + +#include +#include +#include +#include + +class String { +public: + template + explicit String(const char (&src)[N]) + : mData{src} + , mLen{N} + {} + + const char* begin() const { return mData; } + const char* end() const { return mData + mLen; } + + auto operator<=>(const String& other) const + { + return std::lexicographical_compare_three_way( + begin(), end(), other.begin(), other.end()); + } + + bool operator==(const String& other) const + { + return std::strong_ordering::equal == operator<=>(other); + } + +private: + const char* mData{}; + const size_t mLen{}; +}; + +#define CMP_PRINT(op, expected) \ + { \ + const bool res = (op); \ + assert(res == expected); \ + } + +int main() +{ + const char bufa[]{"Hello"}; + const char bufc[]{"Hello"}; + + String a{bufa}; + String b{"C++20"}; + + String c{bufc}; + String d{"HellO"}; + String e{"s"}; + + CMP_PRINT(a == b, false); + CMP_PRINT(a == c, true); + CMP_PRINT(a == d, false); + + CMP_PRINT(a > b, true); + CMP_PRINT(a < b, false); + CMP_PRINT(a > c, false); + CMP_PRINT(a > d, true); + CMP_PRINT(a > e, false); + CMP_PRINT(a < e, true); +} \ No newline at end of file diff --git a/06.10-spaceshipResultingType0/CMakeLists.txt b/06.10-orderingComparisonString3/CMakeLists.txt similarity index 97% rename from 06.10-spaceshipResultingType0/CMakeLists.txt rename to 06.10-orderingComparisonString3/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/06.10-spaceshipResultingType0/CMakeLists.txt +++ b/06.10-orderingComparisonString3/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/06.09-orderingComparisonString3/main.cpp b/06.10-orderingComparisonString3/main.cpp similarity index 100% rename from 06.09-orderingComparisonString3/main.cpp rename to 06.10-orderingComparisonString3/main.cpp diff --git a/06.11-bcd0/CMakeLists.txt b/06.11-spaceshipResultingType0/CMakeLists.txt similarity index 97% rename from 06.11-bcd0/CMakeLists.txt rename to 06.11-spaceshipResultingType0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/06.11-bcd0/CMakeLists.txt +++ b/06.11-spaceshipResultingType0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/06.10-spaceshipResultingType0/main.cpp b/06.11-spaceshipResultingType0/main.cpp similarity index 100% rename from 06.10-spaceshipResultingType0/main.cpp rename to 06.11-spaceshipResultingType0/main.cpp diff --git a/06.12-bcd1/CMakeLists.txt b/06.12-bcd0/CMakeLists.txt similarity index 97% rename from 06.12-bcd1/CMakeLists.txt rename to 06.12-bcd0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/06.12-bcd1/CMakeLists.txt +++ b/06.12-bcd0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/06.11-bcd0/main.cpp b/06.12-bcd0/main.cpp similarity index 100% rename from 06.11-bcd0/main.cpp rename to 06.12-bcd0/main.cpp diff --git a/06.13-bcd1/CMakeLists.txt b/06.13-bcd1/CMakeLists.txt new file mode 100644 index 0000000..03d498a --- /dev/null +++ b/06.13-bcd1/CMakeLists.txt @@ -0,0 +1,90 @@ +# Copyright (c) Andreas Fertig. +# SPDX-License-Identifier: MIT + +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) + +set(CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_STANDARD 20) + +set(EXEC_NAME ${CMAKE_CURRENT_SOURCE_DIR}) + +project(${EXEC_NAME} CXX) + +# build the filename +get_filename_component(EXEC_NAME "${EXEC_NAME}" NAME) + +function(check_compiler COMPILER version) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "${COMPILER}") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${version}) + message(FATAL_ERROR "${COMPILER} version must be at least ${version}!") + endif() + + set(HAVE_COMPILER On PARENT_SCOPE) + endif() +endfunction(check_compiler) + +check_compiler("GNU" 10.2) +check_compiler("Clang" 12.0) +check_compiler("MSVC" 19.28.29914.0) + + +if(NOT HAVE_COMPILER) + message(ERROR "You are using an unsupported compiler!") +endif() + + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(IS_GNU On) + add_definitions(-DIS_GCC=true) +else() + set(IS_GNU Off) + add_definitions(-DIS_GCC=false) +endif() + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") + set(IS_CLANG On) + add_definitions(-DIS_CLANG=true) +else() + set(IS_CLANG Off) + add_definitions(-DIS_CLANG=false) +endif() + +if(MSVC) + add_definitions(-DIS_MSVC=true) + add_definitions(/WX) + add_definitions(/W4) + add_definitions(/wd4189) + add_definitions(/wd4100) + add_definitions(/wd4996) # 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. + add_definitions(/wd4267) + add_definitions(/wd4505) + + # Use sane and nice C++ for MSVC. + # This makes alternative tokens (not, and, ...) as actual keywords and + # enables more conformant C++ in general + add_definitions(/permissive-) + + +else() + add_definitions(-DIS_MSVC=false) + add_definitions(-Werror) + add_definitions(-Wall) + add_definitions(-Wextra) + add_definitions(-Wold-style-cast) + add_definitions(-Wno-unused-variable) + add_definitions(-Wno-unused-parameter) + add_definitions(-Wno-unused-value) + add_definitions(-Wno-cpp) + + if(IS_CLANG) + add_definitions(-Wno-unused-private-field) + add_definitions(-Wno-unneeded-internal-declaration) + + else() + add_definitions(-fcoroutines) # required for GCC-10 + + endif() +endif() + +add_executable(${EXEC_NAME} main.cpp) + diff --git a/06.12-bcd1/main.cpp b/06.13-bcd1/main.cpp similarity index 100% rename from 06.12-bcd1/main.cpp rename to 06.13-bcd1/main.cpp diff --git a/06.13-bcdConstexpr/CMakeLists.txt b/06.13-bcdConstexpr/CMakeLists.txt deleted file mode 100644 index ed3d91e..0000000 --- a/06.13-bcdConstexpr/CMakeLists.txt +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright (c) Andreas Fertig. -# SPDX-License-Identifier: MIT - -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) - -set(CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_STANDARD 20) - -set(EXEC_NAME ${CMAKE_CURRENT_SOURCE_DIR}) - -project(${EXEC_NAME} CXX) - -# build the filename -get_filename_component(EXEC_NAME "${EXEC_NAME}" NAME) - -function(check_compiler COMPILER version) - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "${COMPILER}") - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${version}) - message(FATAL_ERROR "${COMPILER} version must be at least ${version}!") - endif() - - set(HAVE_COMPILER On PARENT_SCOPE) - endif() -endfunction(check_compiler) - -check_compiler("GNU" 10.2) -check_compiler("Clang" 12.0) -check_compiler("MSVC" 19.28.29914.0) - - -if(NOT HAVE_COMPILER) - message(ERROR "You are using an unsupported compiler!") -endif() - - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - set(IS_GNU On) - add_definitions(-DIS_GCC=true) -else() - set(IS_GNU Off) - add_definitions(-DIS_GCC=false) -endif() - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") - set(IS_CLANG On) - add_definitions(-DIS_CLANG=true) -else() - set(IS_CLANG Off) - add_definitions(-DIS_CLANG=false) -endif() - -if(MSVC) - add_definitions(-DIS_MSVC=true) - add_definitions(/WX) - add_definitions(/W4) - add_definitions(/wd4189) - add_definitions(/wd4100) - add_definitions(/wd4996) # 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. - add_definitions(/wd4267) - add_definitions(/wd4505) - - # Use sane and nice C++ for MSVC. - # This makes alternative tokens (not, and, ...) as actual keywords and - # enables more conformant C++ in general - add_definitions(/permissive-) - - -else() - add_definitions(-DIS_MSVC=false) - add_definitions(-Werror) - add_definitions(-Wall) - add_definitions(-Wextra) - add_definitions(-Wold-style-cast) - add_definitions(-Wno-unused-variable) - add_definitions(-Wno-unused-parameter) - add_definitions(-Wno-unused-value) - add_definitions(-Wno-cpp) - - if(IS_CLANG) - add_definitions(-Wno-unused-private-field) - add_definitions(-Wno-unneeded-internal-declaration) - - else() - add_definitions(-fcoroutines) # required for GCC-10 - - endif() -endif() - -add_executable(${EXEC_NAME} main.cpp) - diff --git a/06.14-bcdConstexpr/CMakeLists.txt b/06.14-bcdConstexpr/CMakeLists.txt new file mode 100644 index 0000000..03d498a --- /dev/null +++ b/06.14-bcdConstexpr/CMakeLists.txt @@ -0,0 +1,90 @@ +# Copyright (c) Andreas Fertig. +# SPDX-License-Identifier: MIT + +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) + +set(CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_STANDARD 20) + +set(EXEC_NAME ${CMAKE_CURRENT_SOURCE_DIR}) + +project(${EXEC_NAME} CXX) + +# build the filename +get_filename_component(EXEC_NAME "${EXEC_NAME}" NAME) + +function(check_compiler COMPILER version) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "${COMPILER}") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${version}) + message(FATAL_ERROR "${COMPILER} version must be at least ${version}!") + endif() + + set(HAVE_COMPILER On PARENT_SCOPE) + endif() +endfunction(check_compiler) + +check_compiler("GNU" 10.2) +check_compiler("Clang" 12.0) +check_compiler("MSVC" 19.28.29914.0) + + +if(NOT HAVE_COMPILER) + message(ERROR "You are using an unsupported compiler!") +endif() + + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(IS_GNU On) + add_definitions(-DIS_GCC=true) +else() + set(IS_GNU Off) + add_definitions(-DIS_GCC=false) +endif() + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") + set(IS_CLANG On) + add_definitions(-DIS_CLANG=true) +else() + set(IS_CLANG Off) + add_definitions(-DIS_CLANG=false) +endif() + +if(MSVC) + add_definitions(-DIS_MSVC=true) + add_definitions(/WX) + add_definitions(/W4) + add_definitions(/wd4189) + add_definitions(/wd4100) + add_definitions(/wd4996) # 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. + add_definitions(/wd4267) + add_definitions(/wd4505) + + # Use sane and nice C++ for MSVC. + # This makes alternative tokens (not, and, ...) as actual keywords and + # enables more conformant C++ in general + add_definitions(/permissive-) + + +else() + add_definitions(-DIS_MSVC=false) + add_definitions(-Werror) + add_definitions(-Wall) + add_definitions(-Wextra) + add_definitions(-Wold-style-cast) + add_definitions(-Wno-unused-variable) + add_definitions(-Wno-unused-parameter) + add_definitions(-Wno-unused-value) + add_definitions(-Wno-cpp) + + if(IS_CLANG) + add_definitions(-Wno-unused-private-field) + add_definitions(-Wno-unneeded-internal-declaration) + + else() + add_definitions(-fcoroutines) # required for GCC-10 + + endif() +endif() + +add_executable(${EXEC_NAME} main.cpp) + diff --git a/06.13-bcdConstexpr/main.cpp b/06.14-bcdConstexpr/main.cpp similarity index 100% rename from 06.13-bcdConstexpr/main.cpp rename to 06.14-bcdConstexpr/main.cpp diff --git a/06.14-customOrdering0/CMakeLists.txt b/06.14-customOrdering0/CMakeLists.txt deleted file mode 100644 index ed3d91e..0000000 --- a/06.14-customOrdering0/CMakeLists.txt +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright (c) Andreas Fertig. -# SPDX-License-Identifier: MIT - -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) - -set(CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_STANDARD 20) - -set(EXEC_NAME ${CMAKE_CURRENT_SOURCE_DIR}) - -project(${EXEC_NAME} CXX) - -# build the filename -get_filename_component(EXEC_NAME "${EXEC_NAME}" NAME) - -function(check_compiler COMPILER version) - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "${COMPILER}") - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${version}) - message(FATAL_ERROR "${COMPILER} version must be at least ${version}!") - endif() - - set(HAVE_COMPILER On PARENT_SCOPE) - endif() -endfunction(check_compiler) - -check_compiler("GNU" 10.2) -check_compiler("Clang" 12.0) -check_compiler("MSVC" 19.28.29914.0) - - -if(NOT HAVE_COMPILER) - message(ERROR "You are using an unsupported compiler!") -endif() - - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - set(IS_GNU On) - add_definitions(-DIS_GCC=true) -else() - set(IS_GNU Off) - add_definitions(-DIS_GCC=false) -endif() - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") - set(IS_CLANG On) - add_definitions(-DIS_CLANG=true) -else() - set(IS_CLANG Off) - add_definitions(-DIS_CLANG=false) -endif() - -if(MSVC) - add_definitions(-DIS_MSVC=true) - add_definitions(/WX) - add_definitions(/W4) - add_definitions(/wd4189) - add_definitions(/wd4100) - add_definitions(/wd4996) # 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. - add_definitions(/wd4267) - add_definitions(/wd4505) - - # Use sane and nice C++ for MSVC. - # This makes alternative tokens (not, and, ...) as actual keywords and - # enables more conformant C++ in general - add_definitions(/permissive-) - - -else() - add_definitions(-DIS_MSVC=false) - add_definitions(-Werror) - add_definitions(-Wall) - add_definitions(-Wextra) - add_definitions(-Wold-style-cast) - add_definitions(-Wno-unused-variable) - add_definitions(-Wno-unused-parameter) - add_definitions(-Wno-unused-value) - add_definitions(-Wno-cpp) - - if(IS_CLANG) - add_definitions(-Wno-unused-private-field) - add_definitions(-Wno-unneeded-internal-declaration) - - else() - add_definitions(-fcoroutines) # required for GCC-10 - - endif() -endif() - -add_executable(${EXEC_NAME} main.cpp) - diff --git a/06.15-customOrdering0/CMakeLists.txt b/06.15-customOrdering0/CMakeLists.txt new file mode 100644 index 0000000..03d498a --- /dev/null +++ b/06.15-customOrdering0/CMakeLists.txt @@ -0,0 +1,90 @@ +# Copyright (c) Andreas Fertig. +# SPDX-License-Identifier: MIT + +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) + +set(CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_STANDARD 20) + +set(EXEC_NAME ${CMAKE_CURRENT_SOURCE_DIR}) + +project(${EXEC_NAME} CXX) + +# build the filename +get_filename_component(EXEC_NAME "${EXEC_NAME}" NAME) + +function(check_compiler COMPILER version) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "${COMPILER}") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${version}) + message(FATAL_ERROR "${COMPILER} version must be at least ${version}!") + endif() + + set(HAVE_COMPILER On PARENT_SCOPE) + endif() +endfunction(check_compiler) + +check_compiler("GNU" 10.2) +check_compiler("Clang" 12.0) +check_compiler("MSVC" 19.28.29914.0) + + +if(NOT HAVE_COMPILER) + message(ERROR "You are using an unsupported compiler!") +endif() + + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(IS_GNU On) + add_definitions(-DIS_GCC=true) +else() + set(IS_GNU Off) + add_definitions(-DIS_GCC=false) +endif() + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") + set(IS_CLANG On) + add_definitions(-DIS_CLANG=true) +else() + set(IS_CLANG Off) + add_definitions(-DIS_CLANG=false) +endif() + +if(MSVC) + add_definitions(-DIS_MSVC=true) + add_definitions(/WX) + add_definitions(/W4) + add_definitions(/wd4189) + add_definitions(/wd4100) + add_definitions(/wd4996) # 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. + add_definitions(/wd4267) + add_definitions(/wd4505) + + # Use sane and nice C++ for MSVC. + # This makes alternative tokens (not, and, ...) as actual keywords and + # enables more conformant C++ in general + add_definitions(/permissive-) + + +else() + add_definitions(-DIS_MSVC=false) + add_definitions(-Werror) + add_definitions(-Wall) + add_definitions(-Wextra) + add_definitions(-Wold-style-cast) + add_definitions(-Wno-unused-variable) + add_definitions(-Wno-unused-parameter) + add_definitions(-Wno-unused-value) + add_definitions(-Wno-cpp) + + if(IS_CLANG) + add_definitions(-Wno-unused-private-field) + add_definitions(-Wno-unneeded-internal-declaration) + + else() + add_definitions(-fcoroutines) # required for GCC-10 + + endif() +endif() + +add_executable(${EXEC_NAME} main.cpp) + diff --git a/06.14-customOrdering0/main.cpp b/06.15-customOrdering0/main.cpp similarity index 80% rename from 06.14-customOrdering0/main.cpp rename to 06.15-customOrdering0/main.cpp index f0d80a8..de594eb 100644 --- a/06.14-customOrdering0/main.cpp +++ b/06.15-customOrdering0/main.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: MIT #include +#include #include #include -#if not defined(__clang__) struct Address { std::string city; std::string street; @@ -20,13 +20,4 @@ int main() Address a2{"Heidelberg", "Hauptstrasse", 22}; printf("%d\n", a1 > a2); -} - -#else - -int main() -{ -# pragma message("not supported") -} - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/06.15-customOrdering1/CMakeLists.txt b/06.15-customOrdering1/CMakeLists.txt deleted file mode 100644 index ed3d91e..0000000 --- a/06.15-customOrdering1/CMakeLists.txt +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright (c) Andreas Fertig. -# SPDX-License-Identifier: MIT - -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) - -set(CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_STANDARD 20) - -set(EXEC_NAME ${CMAKE_CURRENT_SOURCE_DIR}) - -project(${EXEC_NAME} CXX) - -# build the filename -get_filename_component(EXEC_NAME "${EXEC_NAME}" NAME) - -function(check_compiler COMPILER version) - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "${COMPILER}") - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${version}) - message(FATAL_ERROR "${COMPILER} version must be at least ${version}!") - endif() - - set(HAVE_COMPILER On PARENT_SCOPE) - endif() -endfunction(check_compiler) - -check_compiler("GNU" 10.2) -check_compiler("Clang" 12.0) -check_compiler("MSVC" 19.28.29914.0) - - -if(NOT HAVE_COMPILER) - message(ERROR "You are using an unsupported compiler!") -endif() - - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - set(IS_GNU On) - add_definitions(-DIS_GCC=true) -else() - set(IS_GNU Off) - add_definitions(-DIS_GCC=false) -endif() - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") - set(IS_CLANG On) - add_definitions(-DIS_CLANG=true) -else() - set(IS_CLANG Off) - add_definitions(-DIS_CLANG=false) -endif() - -if(MSVC) - add_definitions(-DIS_MSVC=true) - add_definitions(/WX) - add_definitions(/W4) - add_definitions(/wd4189) - add_definitions(/wd4100) - add_definitions(/wd4996) # 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. - add_definitions(/wd4267) - add_definitions(/wd4505) - - # Use sane and nice C++ for MSVC. - # This makes alternative tokens (not, and, ...) as actual keywords and - # enables more conformant C++ in general - add_definitions(/permissive-) - - -else() - add_definitions(-DIS_MSVC=false) - add_definitions(-Werror) - add_definitions(-Wall) - add_definitions(-Wextra) - add_definitions(-Wold-style-cast) - add_definitions(-Wno-unused-variable) - add_definitions(-Wno-unused-parameter) - add_definitions(-Wno-unused-value) - add_definitions(-Wno-cpp) - - if(IS_CLANG) - add_definitions(-Wno-unused-private-field) - add_definitions(-Wno-unneeded-internal-declaration) - - else() - add_definitions(-fcoroutines) # required for GCC-10 - - endif() -endif() - -add_executable(${EXEC_NAME} main.cpp) - diff --git a/06.16-customOrdering1/CMakeLists.txt b/06.16-customOrdering1/CMakeLists.txt new file mode 100644 index 0000000..03d498a --- /dev/null +++ b/06.16-customOrdering1/CMakeLists.txt @@ -0,0 +1,90 @@ +# Copyright (c) Andreas Fertig. +# SPDX-License-Identifier: MIT + +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) + +set(CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_STANDARD 20) + +set(EXEC_NAME ${CMAKE_CURRENT_SOURCE_DIR}) + +project(${EXEC_NAME} CXX) + +# build the filename +get_filename_component(EXEC_NAME "${EXEC_NAME}" NAME) + +function(check_compiler COMPILER version) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "${COMPILER}") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${version}) + message(FATAL_ERROR "${COMPILER} version must be at least ${version}!") + endif() + + set(HAVE_COMPILER On PARENT_SCOPE) + endif() +endfunction(check_compiler) + +check_compiler("GNU" 10.2) +check_compiler("Clang" 12.0) +check_compiler("MSVC" 19.28.29914.0) + + +if(NOT HAVE_COMPILER) + message(ERROR "You are using an unsupported compiler!") +endif() + + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(IS_GNU On) + add_definitions(-DIS_GCC=true) +else() + set(IS_GNU Off) + add_definitions(-DIS_GCC=false) +endif() + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") + set(IS_CLANG On) + add_definitions(-DIS_CLANG=true) +else() + set(IS_CLANG Off) + add_definitions(-DIS_CLANG=false) +endif() + +if(MSVC) + add_definitions(-DIS_MSVC=true) + add_definitions(/WX) + add_definitions(/W4) + add_definitions(/wd4189) + add_definitions(/wd4100) + add_definitions(/wd4996) # 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. + add_definitions(/wd4267) + add_definitions(/wd4505) + + # Use sane and nice C++ for MSVC. + # This makes alternative tokens (not, and, ...) as actual keywords and + # enables more conformant C++ in general + add_definitions(/permissive-) + + +else() + add_definitions(-DIS_MSVC=false) + add_definitions(-Werror) + add_definitions(-Wall) + add_definitions(-Wextra) + add_definitions(-Wold-style-cast) + add_definitions(-Wno-unused-variable) + add_definitions(-Wno-unused-parameter) + add_definitions(-Wno-unused-value) + add_definitions(-Wno-cpp) + + if(IS_CLANG) + add_definitions(-Wno-unused-private-field) + add_definitions(-Wno-unneeded-internal-declaration) + + else() + add_definitions(-fcoroutines) # required for GCC-10 + + endif() +endif() + +add_executable(${EXEC_NAME} main.cpp) + diff --git a/06.15-customOrdering1/main.cpp b/06.16-customOrdering1/main.cpp similarity index 88% rename from 06.15-customOrdering1/main.cpp rename to 06.16-customOrdering1/main.cpp index 612a1bf..4072237 100644 --- a/06.15-customOrdering1/main.cpp +++ b/06.16-customOrdering1/main.cpp @@ -2,10 +2,10 @@ // SPDX-License-Identifier: MIT #include +#include #include #include -#if not defined(__clang__) struct Address { std::string city; std::string street; @@ -35,14 +35,4 @@ int main() Address a2{"Heidelberg", "Hauptstrasse", 22}; printf("%d\n", a1 > a2); -} - -#else - -int main() -{ -# pragma message("not supported") - return 1; -} - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/06.16-spaceshipWithLegacyCode0/CMakeLists.txt b/06.16-spaceshipWithLegacyCode0/CMakeLists.txt deleted file mode 100644 index ed3d91e..0000000 --- a/06.16-spaceshipWithLegacyCode0/CMakeLists.txt +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright (c) Andreas Fertig. -# SPDX-License-Identifier: MIT - -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) - -set(CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_STANDARD 20) - -set(EXEC_NAME ${CMAKE_CURRENT_SOURCE_DIR}) - -project(${EXEC_NAME} CXX) - -# build the filename -get_filename_component(EXEC_NAME "${EXEC_NAME}" NAME) - -function(check_compiler COMPILER version) - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "${COMPILER}") - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${version}) - message(FATAL_ERROR "${COMPILER} version must be at least ${version}!") - endif() - - set(HAVE_COMPILER On PARENT_SCOPE) - endif() -endfunction(check_compiler) - -check_compiler("GNU" 10.2) -check_compiler("Clang" 12.0) -check_compiler("MSVC" 19.28.29914.0) - - -if(NOT HAVE_COMPILER) - message(ERROR "You are using an unsupported compiler!") -endif() - - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - set(IS_GNU On) - add_definitions(-DIS_GCC=true) -else() - set(IS_GNU Off) - add_definitions(-DIS_GCC=false) -endif() - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") - set(IS_CLANG On) - add_definitions(-DIS_CLANG=true) -else() - set(IS_CLANG Off) - add_definitions(-DIS_CLANG=false) -endif() - -if(MSVC) - add_definitions(-DIS_MSVC=true) - add_definitions(/WX) - add_definitions(/W4) - add_definitions(/wd4189) - add_definitions(/wd4100) - add_definitions(/wd4996) # 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. - add_definitions(/wd4267) - add_definitions(/wd4505) - - # Use sane and nice C++ for MSVC. - # This makes alternative tokens (not, and, ...) as actual keywords and - # enables more conformant C++ in general - add_definitions(/permissive-) - - -else() - add_definitions(-DIS_MSVC=false) - add_definitions(-Werror) - add_definitions(-Wall) - add_definitions(-Wextra) - add_definitions(-Wold-style-cast) - add_definitions(-Wno-unused-variable) - add_definitions(-Wno-unused-parameter) - add_definitions(-Wno-unused-value) - add_definitions(-Wno-cpp) - - if(IS_CLANG) - add_definitions(-Wno-unused-private-field) - add_definitions(-Wno-unneeded-internal-declaration) - - else() - add_definitions(-fcoroutines) # required for GCC-10 - - endif() -endif() - -add_executable(${EXEC_NAME} main.cpp) - diff --git a/06.17-spaceshipWithLegacyCode0/CMakeLists.txt b/06.17-spaceshipWithLegacyCode0/CMakeLists.txt new file mode 100644 index 0000000..03d498a --- /dev/null +++ b/06.17-spaceshipWithLegacyCode0/CMakeLists.txt @@ -0,0 +1,90 @@ +# Copyright (c) Andreas Fertig. +# SPDX-License-Identifier: MIT + +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) + +set(CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_STANDARD 20) + +set(EXEC_NAME ${CMAKE_CURRENT_SOURCE_DIR}) + +project(${EXEC_NAME} CXX) + +# build the filename +get_filename_component(EXEC_NAME "${EXEC_NAME}" NAME) + +function(check_compiler COMPILER version) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "${COMPILER}") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${version}) + message(FATAL_ERROR "${COMPILER} version must be at least ${version}!") + endif() + + set(HAVE_COMPILER On PARENT_SCOPE) + endif() +endfunction(check_compiler) + +check_compiler("GNU" 10.2) +check_compiler("Clang" 12.0) +check_compiler("MSVC" 19.28.29914.0) + + +if(NOT HAVE_COMPILER) + message(ERROR "You are using an unsupported compiler!") +endif() + + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(IS_GNU On) + add_definitions(-DIS_GCC=true) +else() + set(IS_GNU Off) + add_definitions(-DIS_GCC=false) +endif() + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") + set(IS_CLANG On) + add_definitions(-DIS_CLANG=true) +else() + set(IS_CLANG Off) + add_definitions(-DIS_CLANG=false) +endif() + +if(MSVC) + add_definitions(-DIS_MSVC=true) + add_definitions(/WX) + add_definitions(/W4) + add_definitions(/wd4189) + add_definitions(/wd4100) + add_definitions(/wd4996) # 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. + add_definitions(/wd4267) + add_definitions(/wd4505) + + # Use sane and nice C++ for MSVC. + # This makes alternative tokens (not, and, ...) as actual keywords and + # enables more conformant C++ in general + add_definitions(/permissive-) + + +else() + add_definitions(-DIS_MSVC=false) + add_definitions(-Werror) + add_definitions(-Wall) + add_definitions(-Wextra) + add_definitions(-Wold-style-cast) + add_definitions(-Wno-unused-variable) + add_definitions(-Wno-unused-parameter) + add_definitions(-Wno-unused-value) + add_definitions(-Wno-cpp) + + if(IS_CLANG) + add_definitions(-Wno-unused-private-field) + add_definitions(-Wno-unneeded-internal-declaration) + + else() + add_definitions(-fcoroutines) # required for GCC-10 + + endif() +endif() + +add_executable(${EXEC_NAME} main.cpp) + diff --git a/06.16-spaceshipWithLegacyCode0/main.cpp b/06.17-spaceshipWithLegacyCode0/main.cpp similarity index 100% rename from 06.16-spaceshipWithLegacyCode0/main.cpp rename to 06.17-spaceshipWithLegacyCode0/main.cpp diff --git a/06.17-see-06.16-spaceshipWithLegacyCode0 b/06.18-see-06.17-spaceshipWithLegacyCode0 similarity index 100% rename from 06.17-see-06.16-spaceshipWithLegacyCode0 rename to 06.18-see-06.17-spaceshipWithLegacyCode0 diff --git a/06.18-spaceshipEqualityRewrite2/CMakeLists.txt b/06.18-spaceshipEqualityRewrite2/CMakeLists.txt deleted file mode 100644 index ed3d91e..0000000 --- a/06.18-spaceshipEqualityRewrite2/CMakeLists.txt +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright (c) Andreas Fertig. -# SPDX-License-Identifier: MIT - -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) - -set(CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_STANDARD 20) - -set(EXEC_NAME ${CMAKE_CURRENT_SOURCE_DIR}) - -project(${EXEC_NAME} CXX) - -# build the filename -get_filename_component(EXEC_NAME "${EXEC_NAME}" NAME) - -function(check_compiler COMPILER version) - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "${COMPILER}") - if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${version}) - message(FATAL_ERROR "${COMPILER} version must be at least ${version}!") - endif() - - set(HAVE_COMPILER On PARENT_SCOPE) - endif() -endfunction(check_compiler) - -check_compiler("GNU" 10.2) -check_compiler("Clang" 12.0) -check_compiler("MSVC" 19.28.29914.0) - - -if(NOT HAVE_COMPILER) - message(ERROR "You are using an unsupported compiler!") -endif() - - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - set(IS_GNU On) - add_definitions(-DIS_GCC=true) -else() - set(IS_GNU Off) - add_definitions(-DIS_GCC=false) -endif() - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") - set(IS_CLANG On) - add_definitions(-DIS_CLANG=true) -else() - set(IS_CLANG Off) - add_definitions(-DIS_CLANG=false) -endif() - -if(MSVC) - add_definitions(-DIS_MSVC=true) - add_definitions(/WX) - add_definitions(/W4) - add_definitions(/wd4189) - add_definitions(/wd4100) - add_definitions(/wd4996) # 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. - add_definitions(/wd4267) - add_definitions(/wd4505) - - # Use sane and nice C++ for MSVC. - # This makes alternative tokens (not, and, ...) as actual keywords and - # enables more conformant C++ in general - add_definitions(/permissive-) - - -else() - add_definitions(-DIS_MSVC=false) - add_definitions(-Werror) - add_definitions(-Wall) - add_definitions(-Wextra) - add_definitions(-Wold-style-cast) - add_definitions(-Wno-unused-variable) - add_definitions(-Wno-unused-parameter) - add_definitions(-Wno-unused-value) - add_definitions(-Wno-cpp) - - if(IS_CLANG) - add_definitions(-Wno-unused-private-field) - add_definitions(-Wno-unneeded-internal-declaration) - - else() - add_definitions(-fcoroutines) # required for GCC-10 - - endif() -endif() - -add_executable(${EXEC_NAME} main.cpp) - diff --git a/06.19-spaceshipEqualityRewrite2/CMakeLists.txt b/06.19-spaceshipEqualityRewrite2/CMakeLists.txt new file mode 100644 index 0000000..03d498a --- /dev/null +++ b/06.19-spaceshipEqualityRewrite2/CMakeLists.txt @@ -0,0 +1,90 @@ +# Copyright (c) Andreas Fertig. +# SPDX-License-Identifier: MIT + +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) + +set(CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_STANDARD 20) + +set(EXEC_NAME ${CMAKE_CURRENT_SOURCE_DIR}) + +project(${EXEC_NAME} CXX) + +# build the filename +get_filename_component(EXEC_NAME "${EXEC_NAME}" NAME) + +function(check_compiler COMPILER version) + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "${COMPILER}") + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${version}) + message(FATAL_ERROR "${COMPILER} version must be at least ${version}!") + endif() + + set(HAVE_COMPILER On PARENT_SCOPE) + endif() +endfunction(check_compiler) + +check_compiler("GNU" 10.2) +check_compiler("Clang" 12.0) +check_compiler("MSVC" 19.28.29914.0) + + +if(NOT HAVE_COMPILER) + message(ERROR "You are using an unsupported compiler!") +endif() + + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(IS_GNU On) + add_definitions(-DIS_GCC=true) +else() + set(IS_GNU Off) + add_definitions(-DIS_GCC=false) +endif() + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") + set(IS_CLANG On) + add_definitions(-DIS_CLANG=true) +else() + set(IS_CLANG Off) + add_definitions(-DIS_CLANG=false) +endif() + +if(MSVC) + add_definitions(-DIS_MSVC=true) + add_definitions(/WX) + add_definitions(/W4) + add_definitions(/wd4189) + add_definitions(/wd4100) + add_definitions(/wd4996) # 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. + add_definitions(/wd4267) + add_definitions(/wd4505) + + # Use sane and nice C++ for MSVC. + # This makes alternative tokens (not, and, ...) as actual keywords and + # enables more conformant C++ in general + add_definitions(/permissive-) + + +else() + add_definitions(-DIS_MSVC=false) + add_definitions(-Werror) + add_definitions(-Wall) + add_definitions(-Wextra) + add_definitions(-Wold-style-cast) + add_definitions(-Wno-unused-variable) + add_definitions(-Wno-unused-parameter) + add_definitions(-Wno-unused-value) + add_definitions(-Wno-cpp) + + if(IS_CLANG) + add_definitions(-Wno-unused-private-field) + add_definitions(-Wno-unneeded-internal-declaration) + + else() + add_definitions(-fcoroutines) # required for GCC-10 + + endif() +endif() + +add_executable(${EXEC_NAME} main.cpp) + diff --git a/06.18-spaceshipEqualityRewrite2/main.cpp b/06.19-spaceshipEqualityRewrite2/main.cpp similarity index 100% rename from 06.18-spaceshipEqualityRewrite2/main.cpp rename to 06.19-spaceshipEqualityRewrite2/main.cpp diff --git a/07.01-captureByCopy0/CMakeLists.txt b/07.01-captureByCopy0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/07.01-captureByCopy0/CMakeLists.txt +++ b/07.01-captureByCopy0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/07.02-captureByCopy1/CMakeLists.txt b/07.02-captureByCopy1/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/07.02-captureByCopy1/CMakeLists.txt +++ b/07.02-captureByCopy1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/07.03-captureByCopy1Insights/CMakeLists.txt b/07.03-captureByCopy1Insights/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/07.03-captureByCopy1Insights/CMakeLists.txt +++ b/07.03-captureByCopy1Insights/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/07.04-captureByCopy2/CMakeLists.txt b/07.04-captureByCopy2/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/07.04-captureByCopy2/CMakeLists.txt +++ b/07.04-captureByCopy2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/07.05-mapSortBooksByIsbn0/CMakeLists.txt b/07.05-mapSortBooksByIsbn0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/07.05-mapSortBooksByIsbn0/CMakeLists.txt +++ b/07.05-mapSortBooksByIsbn0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/07.07-mapSortBooksByIsbn1/CMakeLists.txt b/07.07-mapSortBooksByIsbn1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/07.07-mapSortBooksByIsbn1/CMakeLists.txt +++ b/07.07-mapSortBooksByIsbn1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/07.08-mapSortBooksByIsbn2/CMakeLists.txt b/07.08-mapSortBooksByIsbn2/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/07.08-mapSortBooksByIsbn2/CMakeLists.txt +++ b/07.08-mapSortBooksByIsbn2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/07.09-mapSortBooksByIsbn3/CMakeLists.txt b/07.09-mapSortBooksByIsbn3/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/07.09-mapSortBooksByIsbn3/CMakeLists.txt +++ b/07.09-mapSortBooksByIsbn3/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/07.09-mapSortBooksByIsbn3/main.cpp b/07.09-mapSortBooksByIsbn3/main.cpp index 787e533..34b638e 100644 --- a/07.09-mapSortBooksByIsbn3/main.cpp +++ b/07.09-mapSortBooksByIsbn3/main.cpp @@ -22,12 +22,11 @@ struct Price { #if(__cpp_generic_lambdas >= 201707) template -using MapSortedByIsbn = - std::map b.isbn; })>; +using MapSortedByIsbn = std::map< + KEY, + VALUE, + decltype([](const auto& a, // #A Using a generic lambda + const auto& b) { return a.isbn > b.isbn; })>; namespace usingAliasVersion { // #A Define a using alias with the compare lambda which can diff --git a/07.13-mapSortBooksByIsbn4/CMakeLists.txt b/07.13-mapSortBooksByIsbn4/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/07.13-mapSortBooksByIsbn4/CMakeLists.txt +++ b/07.13-mapSortBooksByIsbn4/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/07.14-printWithOrigin0/CMakeLists.txt b/07.14-printWithOrigin0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/07.14-printWithOrigin0/CMakeLists.txt +++ b/07.14-printWithOrigin0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/07.15-genericLambdaVarArgsForward0/CMakeLists.txt b/07.15-genericLambdaVarArgsForward0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/07.15-genericLambdaVarArgsForward0/CMakeLists.txt +++ b/07.15-genericLambdaVarArgsForward0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/07.17-genericLambdaVarArgsForward1/CMakeLists.txt b/07.17-genericLambdaVarArgsForward1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/07.17-genericLambdaVarArgsForward1/CMakeLists.txt +++ b/07.17-genericLambdaVarArgsForward1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/07.18-genericLambdaVarArgsForward2/CMakeLists.txt b/07.18-genericLambdaVarArgsForward2/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/07.18-genericLambdaVarArgsForward2/CMakeLists.txt +++ b/07.18-genericLambdaVarArgsForward2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/07.19-lambdaInitCapture0/CMakeLists.txt b/07.19-lambdaInitCapture0/CMakeLists.txt index df94d21..5ce5e14 100644 --- a/07.19-lambdaInitCapture0/CMakeLists.txt +++ b/07.19-lambdaInitCapture0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 14) diff --git a/07.20-genericLambdaVarArgsForward3/CMakeLists.txt b/07.20-genericLambdaVarArgsForward3/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/07.20-genericLambdaVarArgsForward3/CMakeLists.txt +++ b/07.20-genericLambdaVarArgsForward3/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/07.21-genericLambdaVarArgsForward4/CMakeLists.txt b/07.21-genericLambdaVarArgsForward4/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/07.21-genericLambdaVarArgsForward4/CMakeLists.txt +++ b/07.21-genericLambdaVarArgsForward4/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/07.23-genericLambdaVarArgsForward5/CMakeLists.txt b/07.23-genericLambdaVarArgsForward5/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/07.23-genericLambdaVarArgsForward5/CMakeLists.txt +++ b/07.23-genericLambdaVarArgsForward5/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/07.24-genericLambdaVarArgsForward6/CMakeLists.txt b/07.24-genericLambdaVarArgsForward6/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/07.24-genericLambdaVarArgsForward6/CMakeLists.txt +++ b/07.24-genericLambdaVarArgsForward6/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/07.25-genericLambdaVarArgsForward7/CMakeLists.txt b/07.25-genericLambdaVarArgsForward7/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/07.25-genericLambdaVarArgsForward7/CMakeLists.txt +++ b/07.25-genericLambdaVarArgsForward7/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/07.25-genericLambdaVarArgsForward7/main.cpp b/07.25-genericLambdaVarArgsForward7/main.cpp index 350b38a..c0df4bd 100644 --- a/07.25-genericLambdaVarArgsForward7/main.cpp +++ b/07.25-genericLambdaVarArgsForward7/main.cpp @@ -28,8 +28,8 @@ auto getNamedLogger(Origins&&... origins) { return [... _origins = std::forward(origins)] // #A Type-constraint NotFloatingPoint to restrict all parameters not to be floats - (Ts && ... args) requires( - not std::disjunction_v...>) + (Ts && ... args) + requires(not std::disjunction_v...>) { print(_origins..., std::forward(args)...); }; diff --git a/08.01-aggregateInit0/CMakeLists.txt b/08.01-aggregateInit0/CMakeLists.txt index 14b1ad9..2811d7c 100644 --- a/08.01-aggregateInit0/CMakeLists.txt +++ b/08.01-aggregateInit0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 14) diff --git a/08.02-userProvidedVsDeclared0/CMakeLists.txt b/08.02-userProvidedVsDeclared0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/08.02-userProvidedVsDeclared0/CMakeLists.txt +++ b/08.02-userProvidedVsDeclared0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/08.03-designatedInitializers0/CMakeLists.txt b/08.03-designatedInitializers0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/08.03-designatedInitializers0/CMakeLists.txt +++ b/08.03-designatedInitializers0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/08.04-designatedInitializers1/CMakeLists.txt b/08.04-designatedInitializers1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/08.04-designatedInitializers1/CMakeLists.txt +++ b/08.04-designatedInitializers1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/08.05-mostVertexingParse0/CMakeLists.txt b/08.05-mostVertexingParse0/CMakeLists.txt index 6b6ab12..a5a3beb 100644 --- a/08.05-mostVertexingParse0/CMakeLists.txt +++ b/08.05-mostVertexingParse0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/08.06-designatedInitializers2/CMakeLists.txt b/08.06-designatedInitializers2/CMakeLists.txt index 134ea0d..39b115d 100644 --- a/08.06-designatedInitializers2/CMakeLists.txt +++ b/08.06-designatedInitializers2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/08.07-designatedInitializers3/CMakeLists.txt b/08.07-designatedInitializers3/CMakeLists.txt index d1c753e..bd9f88f 100644 --- a/08.07-designatedInitializers3/CMakeLists.txt +++ b/08.07-designatedInitializers3/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/08.09-designatedInitializers4/CMakeLists.txt b/08.09-designatedInitializers4/CMakeLists.txt index a23742e..22f0d81 100644 --- a/08.09-designatedInitializers4/CMakeLists.txt +++ b/08.09-designatedInitializers4/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/08.10-guaranteedCopyElision0/CMakeLists.txt b/08.10-guaranteedCopyElision0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/08.10-guaranteedCopyElision0/CMakeLists.txt +++ b/08.10-guaranteedCopyElision0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/08.11-designatedInitializers5/CMakeLists.txt b/08.11-designatedInitializers5/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/08.11-designatedInitializers5/CMakeLists.txt +++ b/08.11-designatedInitializers5/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/08.13-designatedInitializersAndFunctionParameters0/CMakeLists.txt b/08.13-designatedInitializersAndFunctionParameters0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/08.13-designatedInitializersAndFunctionParameters0/CMakeLists.txt +++ b/08.13-designatedInitializersAndFunctionParameters0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/08.15-designatedInitializersAndFunctionParameters1/CMakeLists.txt b/08.15-designatedInitializersAndFunctionParameters1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/08.15-designatedInitializersAndFunctionParameters1/CMakeLists.txt +++ b/08.15-designatedInitializersAndFunctionParameters1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/08.17-designatedInitializersOverloadResolution0/CMakeLists.txt b/08.17-designatedInitializersOverloadResolution0/CMakeLists.txt index a23742e..22f0d81 100644 --- a/08.17-designatedInitializersOverloadResolution0/CMakeLists.txt +++ b/08.17-designatedInitializersOverloadResolution0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/08.17-designatedInitializersOverloadResolution0/main.cpp b/08.17-designatedInitializersOverloadResolution0/main.cpp index b3910a3..598ea60 100644 --- a/08.17-designatedInitializersOverloadResolution0/main.cpp +++ b/08.17-designatedInitializersOverloadResolution0/main.cpp @@ -20,12 +20,12 @@ void Add(const Point2D& p, int v); void Add(const Point& p, int v) { - printf("Point\n"); + puts("Point"); } void Add(const Point2D& p, int v) { - printf("Point2D\n"); + puts("Point2D"); } int main() diff --git a/08.18-bracedInitVsParensWithStdVector0/CMakeLists.txt b/08.18-bracedInitVsParensWithStdVector0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/08.18-bracedInitVsParensWithStdVector0/CMakeLists.txt +++ b/08.18-bracedInitVsParensWithStdVector0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/08.19-makeUniqueWithAnAggregate0/CMakeLists.txt b/08.19-makeUniqueWithAnAggregate0/CMakeLists.txt index 796c1c2..d7a7550 100644 --- a/08.19-makeUniqueWithAnAggregate0/CMakeLists.txt +++ b/08.19-makeUniqueWithAnAggregate0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/08.21-initializationForms0/CMakeLists.txt b/08.21-initializationForms0/CMakeLists.txt index 1dc0d59..daf86f8 100644 --- a/08.21-initializationForms0/CMakeLists.txt +++ b/08.21-initializationForms0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/08.21-initializationForms0/main.cpp b/08.21-initializationForms0/main.cpp index 2c4400b..9da6d9a 100644 --- a/08.21-initializationForms0/main.cpp +++ b/08.21-initializationForms0/main.cpp @@ -41,8 +41,8 @@ int main() // Point bNarrowing{3.5};// #J Does not allow narrowing Point pNarrowing(3.5); // #K Allows narrowing - Point bValueInit{}; // #L Default or zero initialization - Point pValueInit(); // #M Still a function declaration + Point bValueInit{}; // #L Default or zero initialization + Point pValueInit(); // #M Still a function declaration // #N Initialization of a built-in type int bBuiltIn{4}; diff --git a/08.22-aggregateWithUserDeclaredConstructor0/CMakeLists.txt b/08.22-aggregateWithUserDeclaredConstructor0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/08.22-aggregateWithUserDeclaredConstructor0/CMakeLists.txt +++ b/08.22-aggregateWithUserDeclaredConstructor0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/08.25-ctad0/CMakeLists.txt b/08.25-ctad0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/08.25-ctad0/CMakeLists.txt +++ b/08.25-ctad0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/08.26-structuredBindingsPOSIXError0/CMakeLists.txt b/08.26-structuredBindingsPOSIXError0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/08.26-structuredBindingsPOSIXError0/CMakeLists.txt +++ b/08.26-structuredBindingsPOSIXError0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/08.27-structuredBindingsPOSIXError1/CMakeLists.txt b/08.27-structuredBindingsPOSIXError1/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/08.27-structuredBindingsPOSIXError1/CMakeLists.txt +++ b/08.27-structuredBindingsPOSIXError1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/08.28-structuredBindingsPOSIXError2/CMakeLists.txt b/08.28-structuredBindingsPOSIXError2/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/08.28-structuredBindingsPOSIXError2/CMakeLists.txt +++ b/08.28-structuredBindingsPOSIXError2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/08.29-structuredBindingsPOSIXError3/CMakeLists.txt b/08.29-structuredBindingsPOSIXError3/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/08.29-structuredBindingsPOSIXError3/CMakeLists.txt +++ b/08.29-structuredBindingsPOSIXError3/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/08.30-structuredBindingsPOSIXError4/CMakeLists.txt b/08.30-structuredBindingsPOSIXError4/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/08.30-structuredBindingsPOSIXError4/CMakeLists.txt +++ b/08.30-structuredBindingsPOSIXError4/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/09.01-stdArray0/CMakeLists.txt b/09.01-stdArray0/CMakeLists.txt index 9566747..47b1d42 100644 --- a/09.01-stdArray0/CMakeLists.txt +++ b/09.01-stdArray0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 11) diff --git a/09.02-floatingPointNTTP0/CMakeLists.txt b/09.02-floatingPointNTTP0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/09.02-floatingPointNTTP0/CMakeLists.txt +++ b/09.02-floatingPointNTTP0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/09.03-fixedString0/CMakeLists.txt b/09.03-fixedString0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/09.03-fixedString0/CMakeLists.txt +++ b/09.03-fixedString0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/09.04-fixedString1/CMakeLists.txt b/09.04-fixedString1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/09.04-fixedString1/CMakeLists.txt +++ b/09.04-fixedString1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/09.04-fixedString1/main.cpp b/09.04-fixedString1/main.cpp index ab92d3c..01a542f 100644 --- a/09.04-fixedString1/main.cpp +++ b/09.04-fixedString1/main.cpp @@ -6,7 +6,6 @@ #include #include -#if not defined(__clang__) template struct fixed_string { CharT data[N]{}; @@ -61,10 +60,4 @@ int main() FixedStringContainer<"Hello, C++"> fc{}; fc.print(); // #D For those who believe it only if they see // it -} -#else -int main() -{ -# pragma message("not supported") -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/09.12-fixedString2/CMakeLists.txt b/09.12-fixedString2/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/09.12-fixedString2/CMakeLists.txt +++ b/09.12-fixedString2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/09.12-fixedString2/main.cpp b/09.12-fixedString2/main.cpp index 0ed0bb6..cd09487 100644 --- a/09.12-fixedString2/main.cpp +++ b/09.12-fixedString2/main.cpp @@ -7,7 +7,6 @@ #include #include -#if __has_include() and not defined(__clang__) template struct fixed_string { CharT data[N]{}; @@ -52,10 +51,4 @@ int main() print(FormatString<"%s, %s">{}, "Hello", "C++20"); print("%s, %s"_fs, "Hello", "C++20"); -} -#else -int main() -{ -# pragma message("not supported") -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/09.13-fixedString3/CMakeLists.txt b/09.13-fixedString3/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/09.13-fixedString3/CMakeLists.txt +++ b/09.13-fixedString3/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/09.13-fixedString3/main.cpp b/09.13-fixedString3/main.cpp index 500756e..c635c91 100644 --- a/09.13-fixedString3/main.cpp +++ b/09.13-fixedString3/main.cpp @@ -5,10 +5,9 @@ #include #include +#include #include -#if __has_include() and not defined(__clang__) - template struct fixed_string { CharT data[N]{}; @@ -80,11 +79,9 @@ constexpr auto get(const std::span& str) template constexpr bool IsMatching(std::span str) { - return [&](std::index_sequence) - { + return [&](std::index_sequence) { return ((match(get(str))) && ...); - } - (std::make_index_sequence{}); + }(std::make_index_sequence{}); } template @@ -127,12 +124,4 @@ int main() char fmt[]{"Hello, %s"}; print(fmt, "C++20"); - - // fmt("test"); -} -#else -int main() -{ -# pragma message("not supported") -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/10.01-bitCastFloatToInt0/CMakeLists.txt b/10.01-bitCastFloatToInt0/CMakeLists.txt index a5353cc..b228ac0 100644 --- a/10.01-bitCastFloatToInt0/CMakeLists.txt +++ b/10.01-bitCastFloatToInt0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/10.02-bitCastFloatToInt1/CMakeLists.txt b/10.02-bitCastFloatToInt1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/10.02-bitCastFloatToInt1/CMakeLists.txt +++ b/10.02-bitCastFloatToInt1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/10.03-byteSwap0/CMakeLists.txt b/10.03-byteSwap0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/10.03-byteSwap0/CMakeLists.txt +++ b/10.03-byteSwap0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/10.03-byteSwap0/main.cpp b/10.03-byteSwap0/main.cpp index e13264b..bb7fbd7 100644 --- a/10.03-byteSwap0/main.cpp +++ b/10.03-byteSwap0/main.cpp @@ -11,13 +11,11 @@ constexpr auto ReverseBytes(std::integral auto value) { - return [&](std::index_sequence)->decltype(value) - { + return [&](std::index_sequence) -> decltype(value) { return ( (((value >> I * 8) & 0xff) << ((8 * sizeof(value)) - ((1 + I) * 8))) | ...); - } - (std::make_index_sequence{}); + }(std::make_index_sequence{}); } constexpr auto ByteSwap(std::integral auto value) diff --git a/10.04-stdArrayVsCArray0/CMakeLists.txt b/10.04-stdArrayVsCArray0/CMakeLists.txt index 9566747..47b1d42 100644 --- a/10.04-stdArrayVsCArray0/CMakeLists.txt +++ b/10.04-stdArrayVsCArray0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 11) diff --git a/10.05-stdArrayVsCArray1/CMakeLists.txt b/10.05-stdArrayVsCArray1/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/10.05-stdArrayVsCArray1/CMakeLists.txt +++ b/10.05-stdArrayVsCArray1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/10.06-stdArrayVsCArray2/CMakeLists.txt b/10.06-stdArrayVsCArray2/CMakeLists.txt index d1c753e..bd9f88f 100644 --- a/10.06-stdArrayVsCArray2/CMakeLists.txt +++ b/10.06-stdArrayVsCArray2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/10.07-lengthAndValue0/CMakeLists.txt b/10.07-lengthAndValue0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/10.07-lengthAndValue0/CMakeLists.txt +++ b/10.07-lengthAndValue0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/10.08-lengthAndValue1/CMakeLists.txt b/10.08-lengthAndValue1/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/10.08-lengthAndValue1/CMakeLists.txt +++ b/10.08-lengthAndValue1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/10.09-lengthAndValue2/CMakeLists.txt b/10.09-lengthAndValue2/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/10.09-lengthAndValue2/CMakeLists.txt +++ b/10.09-lengthAndValue2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/10.10-span0/CMakeLists.txt b/10.10-span0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/10.10-span0/CMakeLists.txt +++ b/10.10-span0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/10.11-assert0/CMakeLists.txt b/10.11-assert0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/10.11-assert0/CMakeLists.txt +++ b/10.11-assert0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/10.13-assert1/CMakeLists.txt b/10.13-assert1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/10.13-assert1/CMakeLists.txt +++ b/10.13-assert1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/10.13-assert1/main.cpp b/10.13-assert1/main.cpp index 68ad5be..8e8ccc4 100644 --- a/10.13-assert1/main.cpp +++ b/10.13-assert1/main.cpp @@ -1,10 +1,9 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() && not defined(__clang__) -# include -# include -# include +#include +#include +#include // #A Assert function taking condition, message, and source // location @@ -24,10 +23,4 @@ int main() { // #C A call to Assert with information of Use Assert(1 != 2, "Not met"); -} -#else -int main() -{ -# pragma message("not supported") -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/10.14-logFunction0/CMakeLists.txt b/10.14-logFunction0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/10.14-logFunction0/CMakeLists.txt +++ b/10.14-logFunction0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/10.14-logFunction0/main.cpp b/10.14-logFunction0/main.cpp index 407235e..9f0b892 100644 --- a/10.14-logFunction0/main.cpp +++ b/10.14-logFunction0/main.cpp @@ -1,10 +1,9 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) -# include -# include -# include +#include +#include +#include enum LogLevel { Info, Warning, Error }; @@ -24,19 +23,10 @@ void Log(LogLevel level, } // #B Macro wrapper to call Log -# define LOG(level, fmt, ...) \ - Log(level, __FUNCTION__, __LINE__, fmt, __VA_ARGS__) +#define LOG(level, fmt, ...) \ + Log(level, __FUNCTION__, __LINE__, fmt, __VA_ARGS__) int main() { LOG(LogLevel::Info, "hello {} {} {}", 2, 3, 4); -} - -#else - -int main() -{ -# pragma message("not supported") -} - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/10.15-logFunction1/CMakeLists.txt b/10.15-logFunction1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/10.15-logFunction1/CMakeLists.txt +++ b/10.15-logFunction1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/10.15-logFunction1/main.cpp b/10.15-logFunction1/main.cpp index ffabae6..52929c4 100644 --- a/10.15-logFunction1/main.cpp +++ b/10.15-logFunction1/main.cpp @@ -1,11 +1,10 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include() and not defined(__clang__) && __has_include() -# include -# include -# include -# include +#include +#include +#include +#include enum LogLevel { Info, Warning, Error }; @@ -24,22 +23,10 @@ void Log(LogLevel level, } // #B Macro wrapper to call Log -# define LOG(level, fmt, ...) \ - Log(level, \ - std::source_location::current(), \ - fmt, \ - __VA_ARGS__) +#define LOG(level, fmt, ...) \ + Log(level, std::source_location::current(), fmt, __VA_ARGS__) int main() { LOG(LogLevel::Info, "hello {} {} {}", 2, 3, 4); -} - -#else - -int main() -{ -# pragma message("not supported") -} - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/10.16-logFunction2/CMakeLists.txt b/10.16-logFunction2/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/10.16-logFunction2/CMakeLists.txt +++ b/10.16-logFunction2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/10.16-logFunction2/main.cpp b/10.16-logFunction2/main.cpp index 3b65de7..0729741 100644 --- a/10.16-logFunction2/main.cpp +++ b/10.16-logFunction2/main.cpp @@ -1,12 +1,10 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#if __has_include( \ - ) and not defined(__clang__) && __has_include() && not defined(__clang__) -# include -# include -# include -# include +#include +#include +#include +#include enum LogLevel { Info, Warning, Error }; @@ -39,13 +37,4 @@ void Log(LogLevel level, Format fmt, const auto&... args) int main() { Log(LogLevel::Info, "hello {} {} {}", 2, 3, 4); -} - -#else - -int main() -{ -# pragma message("not supported") -} - -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/10.17-mapContains0/CMakeLists.txt b/10.17-mapContains0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/10.17-mapContains0/CMakeLists.txt +++ b/10.17-mapContains0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/10.18-mapContains1/CMakeLists.txt b/10.18-mapContains1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/10.18-mapContains1/CMakeLists.txt +++ b/10.18-mapContains1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/10.19-startsWith0/CMakeLists.txt b/10.19-startsWith0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/10.19-startsWith0/CMakeLists.txt +++ b/10.19-startsWith0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/10.19-startsWith0/main.cpp b/10.19-startsWith0/main.cpp index c6fcc50..764ed2e 100644 --- a/10.19-startsWith0/main.cpp +++ b/10.19-startsWith0/main.cpp @@ -7,5 +7,5 @@ int main() { const std::string s{"Hello, C++20"}; - if(s.find("Hello") != std::string::npos) { printf("Found!\n"); } + if(s.find("Hello") != std::string::npos) { puts("Found!"); } } \ No newline at end of file diff --git a/10.20-startsWith1/CMakeLists.txt b/10.20-startsWith1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/10.20-startsWith1/CMakeLists.txt +++ b/10.20-startsWith1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/10.20-startsWith1/main.cpp b/10.20-startsWith1/main.cpp index ac4e9db..5906484 100644 --- a/10.20-startsWith1/main.cpp +++ b/10.20-startsWith1/main.cpp @@ -7,7 +7,7 @@ int main() { const std::string s{"Hello, C++20"}; - if(s.starts_with("Hello")) { printf("Found!\n"); } + if(s.starts_with("Hello")) { puts("Found!"); } - if(s.ends_with("C++20")) { printf("Found!\n"); } + if(s.ends_with("C++20")) { puts("Found!"); } } \ No newline at end of file diff --git a/11.01-rangeBaseForWithInit0/CMakeLists.txt b/11.01-rangeBaseForWithInit0/CMakeLists.txt index 9566747..47b1d42 100644 --- a/11.01-rangeBaseForWithInit0/CMakeLists.txt +++ b/11.01-rangeBaseForWithInit0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 11) diff --git a/11.02-rangeBaseForWithInit1/CMakeLists.txt b/11.02-rangeBaseForWithInit1/CMakeLists.txt index 9566747..47b1d42 100644 --- a/11.02-rangeBaseForWithInit1/CMakeLists.txt +++ b/11.02-rangeBaseForWithInit1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 11) diff --git a/11.03-rangeBaseForWithInit2/CMakeLists.txt b/11.03-rangeBaseForWithInit2/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/11.03-rangeBaseForWithInit2/CMakeLists.txt +++ b/11.03-rangeBaseForWithInit2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/11.04-rangeBasedForLoopWithTemporary0/CMakeLists.txt b/11.04-rangeBasedForLoopWithTemporary0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/11.04-rangeBasedForLoopWithTemporary0/CMakeLists.txt +++ b/11.04-rangeBasedForLoopWithTemporary0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/11.04-rangeBasedForLoopWithTemporary0/main.cpp b/11.04-rangeBasedForLoopWithTemporary0/main.cpp index 4dcf77e..1afb4ba 100644 --- a/11.04-rangeBasedForLoopWithTemporary0/main.cpp +++ b/11.04-rangeBasedForLoopWithTemporary0/main.cpp @@ -1,8 +1,9 @@ // Copyright (c) Andreas Fertig. // SPDX-License-Identifier: MIT -#include -#include +#if not(defined(__GNUC__) && !defined(__clang__)) +# include +# include class Keeper { // #A std::vector data{2, 3, 4}; @@ -25,4 +26,10 @@ int main() for(auto& item : GetKeeper().items()) { std::cout << item << '\n'; } -} \ No newline at end of file +} +#else +int main() +{ +# pragma message("GCC detects the error") +} +#endif \ No newline at end of file diff --git a/11.05-rangeBasedForLoopWithTemporary1/CMakeLists.txt b/11.05-rangeBasedForLoopWithTemporary1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/11.05-rangeBasedForLoopWithTemporary1/CMakeLists.txt +++ b/11.05-rangeBasedForLoopWithTemporary1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/11.06-likely0/CMakeLists.txt b/11.06-likely0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/11.06-likely0/CMakeLists.txt +++ b/11.06-likely0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/11.06-likely0/main.cpp b/11.06-likely0/main.cpp index a1dcd28..e6773ee 100644 --- a/11.06-likely0/main.cpp +++ b/11.06-likely0/main.cpp @@ -6,8 +6,8 @@ int main(int value, const char*[]) { switch(value) { - case 0: printf("Hello\n"); break; - case 1: printf("World\n"); break; - case 2: printf("C++\n"); break; + case 0: puts("Hello"); break; + case 1: puts("World"); break; + case 2: puts("C++"); break; } } \ No newline at end of file diff --git a/11.07-likely1/CMakeLists.txt b/11.07-likely1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/11.07-likely1/CMakeLists.txt +++ b/11.07-likely1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/11.07-likely1/main.cpp b/11.07-likely1/main.cpp index 4a1a027..933d232 100644 --- a/11.07-likely1/main.cpp +++ b/11.07-likely1/main.cpp @@ -6,9 +6,9 @@ int main(int value, const char*[]) { switch(value) { - case 0: printf("Hello\n"); break; - [[likely]] case 1: printf("World\n"); break; - case 2: printf("C++\n"); break; + case 0: puts("Hello"); break; + [[likely]] case 1: puts("World"); break; + case 2: puts("C++"); break; } } \ No newline at end of file diff --git a/11.08-notCopyable0/CMakeLists.txt b/11.08-notCopyable0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/11.08-notCopyable0/CMakeLists.txt +++ b/11.08-notCopyable0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/11.09-notCopyable1/CMakeLists.txt b/11.09-notCopyable1/CMakeLists.txt index 4d5f8f8..fb7aa9d 100644 --- a/11.09-notCopyable1/CMakeLists.txt +++ b/11.09-notCopyable1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/11.10-usingEnum0/CMakeLists.txt b/11.10-usingEnum0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/11.10-usingEnum0/CMakeLists.txt +++ b/11.10-usingEnum0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/11.11-usingEnum1/CMakeLists.txt b/11.11-usingEnum1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/11.11-usingEnum1/CMakeLists.txt +++ b/11.11-usingEnum1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/11.12-conditionalExplicit0/CMakeLists.txt b/11.12-conditionalExplicit0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/11.12-conditionalExplicit0/CMakeLists.txt +++ b/11.12-conditionalExplicit0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/11.13-conditionalExplicit1/CMakeLists.txt b/11.13-conditionalExplicit1/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/11.13-conditionalExplicit1/CMakeLists.txt +++ b/11.13-conditionalExplicit1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/11.14-conditionalExplicit2/CMakeLists.txt b/11.14-conditionalExplicit2/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/11.14-conditionalExplicit2/CMakeLists.txt +++ b/11.14-conditionalExplicit2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/11.15-conditionalExplicit5/CMakeLists.txt b/11.15-conditionalExplicit5/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/11.15-conditionalExplicit5/CMakeLists.txt +++ b/11.15-conditionalExplicit5/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/12.01-constexprStrlenCpp110/CMakeLists.txt b/12.01-constexprStrlenCpp110/CMakeLists.txt index 9566747..47b1d42 100644 --- a/12.01-constexprStrlenCpp110/CMakeLists.txt +++ b/12.01-constexprStrlenCpp110/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 11) diff --git a/12.02-constexprStrlenCpp111/CMakeLists.txt b/12.02-constexprStrlenCpp111/CMakeLists.txt index 9566747..47b1d42 100644 --- a/12.02-constexprStrlenCpp111/CMakeLists.txt +++ b/12.02-constexprStrlenCpp111/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 11) diff --git a/12.03-constexprPoint0/CMakeLists.txt b/12.03-constexprPoint0/CMakeLists.txt index 14b1ad9..2811d7c 100644 --- a/12.03-constexprPoint0/CMakeLists.txt +++ b/12.03-constexprPoint0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 14) diff --git a/12.04-constexprThrow0/CMakeLists.txt b/12.04-constexprThrow0/CMakeLists.txt index 14b1ad9..2811d7c 100644 --- a/12.04-constexprThrow0/CMakeLists.txt +++ b/12.04-constexprThrow0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 14) diff --git a/12.05-throwAtCompileTime0/CMakeLists.txt b/12.05-throwAtCompileTime0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/12.05-throwAtCompileTime0/CMakeLists.txt +++ b/12.05-throwAtCompileTime0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/12.06-logStatementInConstexpr0/CMakeLists.txt b/12.06-logStatementInConstexpr0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/12.06-logStatementInConstexpr0/CMakeLists.txt +++ b/12.06-logStatementInConstexpr0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/12.08-byteSwap1/CMakeLists.txt b/12.08-byteSwap1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/12.08-byteSwap1/CMakeLists.txt +++ b/12.08-byteSwap1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/12.08-byteSwap1/main.cpp b/12.08-byteSwap1/main.cpp index fd84cc6..8db82ed 100644 --- a/12.08-byteSwap1/main.cpp +++ b/12.08-byteSwap1/main.cpp @@ -18,13 +18,12 @@ constexpr auto ReverseBytes(std::integral auto value) { - return [&](std::index_sequence)->decltype(value) - { - return ((((value >> I * 8) & 0xff) - << ((8 * sizeof(value)) - ((1 + I) * 8))) | - ...); - } - (std::make_index_sequence{}); + return + [&](std::index_sequence) -> decltype(value) { + return ((((value >> I * 8) & 0xff) + << ((8 * sizeof(value)) - ((1 + I) * 8))) | + ...); + }(std::make_index_sequence{}); } template diff --git a/12.09-constantEvalutedAndConstexprIf0/CMakeLists.txt b/12.09-constantEvalutedAndConstexprIf0/CMakeLists.txt index 2d1f52d..b54edd9 100644 --- a/12.09-constantEvalutedAndConstexprIf0/CMakeLists.txt +++ b/12.09-constantEvalutedAndConstexprIf0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) @@ -84,7 +84,8 @@ else() else() add_definitions(-fcoroutines) # required for GCC-10 - + add_definitions(-Wno-tautological-compare) + endif() endif() diff --git a/12.10-constexprAllocation0/CMakeLists.txt b/12.10-constexprAllocation0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/12.10-constexprAllocation0/CMakeLists.txt +++ b/12.10-constexprAllocation0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/12.12-constexprAllocation1/CMakeLists.txt b/12.12-constexprAllocation1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/12.12-constexprAllocation1/CMakeLists.txt +++ b/12.12-constexprAllocation1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/12.14-constexprAllocation2/CMakeLists.txt b/12.14-constexprAllocation2/CMakeLists.txt index ed3d91e..fb85410 100644 --- a/12.14-constexprAllocation2/CMakeLists.txt +++ b/12.14-constexprAllocation2/CMakeLists.txt @@ -1,10 +1,10 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD 23) set(EXEC_NAME ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/12.14-constexprAllocation2/main.cpp b/12.14-constexprAllocation2/main.cpp index 5151cde..93573fb 100644 --- a/12.14-constexprAllocation2/main.cpp +++ b/12.14-constexprAllocation2/main.cpp @@ -3,19 +3,7 @@ #if not(defined(__GNUC__) && !defined(__clang__)) -template -class unique_ptr { -public: - constexpr unique_ptr(T* data) noexcept - : _data{data} - {} - constexpr ~unique_ptr() noexcept { delete _data; } - - constexpr T* operator->() const noexcept { return _data; } - -private: - T* _data{}; -}; +# include struct Car { // #A Base class for all cars virtual ~Car() = default; @@ -33,12 +21,12 @@ struct Tesla : Car { constexpr int speed() const override { return 9; } }; -constexpr unique_ptr CreateCar(int i) +constexpr std::unique_ptr CreateCar(int i) { switch(i) { - case 0: return new Mercedes{}; - case 1: return new Toyota{}; - case 2: return new Tesla{}; + case 0: return std::make_unique(); + case 1: return std::make_unique(); + case 2: return std::make_unique(); } return nullptr; diff --git a/12.15-asConstant0/CMakeLists.txt b/12.15-asConstant0/CMakeLists.txt index 114d0a0..09feead 100644 --- a/12.15-asConstant0/CMakeLists.txt +++ b/12.15-asConstant0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) @@ -79,7 +79,8 @@ else() if(IS_CLANG) add_definitions(-Wno-unused-private-field) add_definitions(-Wno-unneeded-internal-declaration) - + add_definitions(-Wno-unused-but-set-variable) + else() add_definitions(-fcoroutines) # required for GCC-10 diff --git a/12.16-asConstant1/CMakeLists.txt b/12.16-asConstant1/CMakeLists.txt index ed3d91e..fc89c11 100644 --- a/12.16-asConstant1/CMakeLists.txt +++ b/12.16-asConstant1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) @@ -79,7 +79,8 @@ else() if(IS_CLANG) add_definitions(-Wno-unused-private-field) add_definitions(-Wno-unneeded-internal-declaration) - + add_definitions(-Wno-unused-but-set-variable) + else() add_definitions(-fcoroutines) # required for GCC-10 diff --git a/12.16-asConstant1/main.cpp b/12.16-asConstant1/main.cpp index 04e3d54..e2443f5 100644 --- a/12.16-asConstant1/main.cpp +++ b/12.16-asConstant1/main.cpp @@ -15,5 +15,5 @@ int main() { auto value2 = as_constant(ExpensiveCalculation(2)); // #B compile-time - ++value2; // #C Compiles + ++value2; // #C Compiles } \ No newline at end of file diff --git a/12.18-constevalParmCheck0/CMakeLists.txt b/12.18-constevalParmCheck0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/12.18-constevalParmCheck0/CMakeLists.txt +++ b/12.18-constevalParmCheck0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/12.19-constevalParmCheck1/CMakeLists.txt b/12.19-constevalParmCheck1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/12.19-constevalParmCheck1/CMakeLists.txt +++ b/12.19-constevalParmCheck1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/12.19-constevalParmCheck1/main.cpp b/12.19-constevalParmCheck1/main.cpp index f512ddc..68a51fa 100644 --- a/12.19-constevalParmCheck1/main.cpp +++ b/12.19-constevalParmCheck1/main.cpp @@ -150,7 +150,7 @@ struct basic_format_string { std::string_view str; // #A Holds the actual format string template - requires std::is_convertible_v + requires std::is_convertible_v consteval basic_format_string( const T& s) // #B A consteval constructor : str{s} diff --git a/12.21-constantEvalutedAndConsteval0/CMakeLists.txt b/12.21-constantEvalutedAndConsteval0/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/12.21-constantEvalutedAndConsteval0/CMakeLists.txt +++ b/12.21-constantEvalutedAndConsteval0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/12.22-constantEvalutedAndConsteval1/CMakeLists.txt b/12.22-constantEvalutedAndConsteval1/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/12.22-constantEvalutedAndConsteval1/CMakeLists.txt +++ b/12.22-constantEvalutedAndConsteval1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/12.23-constexprStaticInitFiasco0/CMakeLists.txt b/12.23-constexprStaticInitFiasco0/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/12.23-constexprStaticInitFiasco0/CMakeLists.txt +++ b/12.23-constexprStaticInitFiasco0/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/12.24-constexprStaticInitFiasco1/CMakeLists.txt b/12.24-constexprStaticInitFiasco1/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/12.24-constexprStaticInitFiasco1/CMakeLists.txt +++ b/12.24-constexprStaticInitFiasco1/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/12.25-constexprStaticInitFiasco2/CMakeLists.txt b/12.25-constexprStaticInitFiasco2/CMakeLists.txt index 114d0a0..bdeed93 100644 --- a/12.25-constexprStaticInitFiasco2/CMakeLists.txt +++ b/12.25-constexprStaticInitFiasco2/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 17) diff --git a/12.26-constexprStaticInitFiasco3/CMakeLists.txt b/12.26-constexprStaticInitFiasco3/CMakeLists.txt index ed3d91e..03d498a 100644 --- a/12.26-constexprStaticInitFiasco3/CMakeLists.txt +++ b/12.26-constexprStaticInitFiasco3/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) set(CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 20) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93f781a..a2b239a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Andreas Fertig. # SPDX-License-Identifier: MIT -cmake_minimum_required(VERSION 3.16.2 FATAL_ERROR) +cmake_minimum_required(VERSION 3.28.2 FATAL_ERROR) project("Programming with C++20 - Concepts, Coroutines, Ranges, and more" CXX) diff --git a/LICENSE.txt b/LICENSE.txt index 1792830..cdad4ec 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 Andreas Fertig +Copyright (c) 2024 Andreas Fertig Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Readme.md b/Readme.md index a367a36..a3bee8e 100644 --- a/Readme.md +++ b/Readme.md @@ -1,4 +1,4 @@ -# Companion Source Code for "Programming with C++20 - Concepts, Coroutines, Ranges, and more" 1. Edition +# Companion Source Code for "Programming with C++20 - Concepts, Coroutines, Ranges, and more" 2. Edition [![Build Status](https://github.com/andreasfertig/programming-with-cpp20/workflows/ci/badge.svg)](https://github.com/andreasfertig/programming-with-cpp20/actions/) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](/LICENSE.txt) @@ -6,7 +6,7 @@ ## Code examples -This repository contains runnable source code examples from the 1. edition of [Programming with C++20 - Concepts, Coroutines, Ranges, and more](https://andreasfertig.com/books/programming-with-cpp20/), by [Andreas Fertig](https://andreasfertig.com). +This repository contains runnable source code examples from the 2. edition of [Programming with C++20 - Concepts, Coroutines, Ranges, and more](https://andreasfertig.com/books/programming-with-cpp20/), by [Andreas Fertig](https://andreasfertig.com). ### The layout of the examples @@ -14,8 +14,8 @@ The examples are separated into different directories based on how they appear i ### Running the examples -The examples are contained in a single `.cpp` file that can be easily executed in any IDE. There is also an `CMakeLists.txt` which can generate IDE projects or used to compile the example in a terminal. -This repo contains a top-level `CMakeLists.txt` which does build all the examples. +The examples are in a single `.cpp` file that can be easily executed in any IDE. There is also an `CMakeLists.txt` which can generate IDE projects or be used to compile the example in a terminal. +This repo contains a top-level `CMakeLists.txt`, which does build all the examples. ### Building the examples @@ -31,9 +31,9 @@ cmake ../ cmake --build . -j ``` -After that you find all the executables in `programming-with-cpp20/build/bin`. +After that, you find all the executables in `programming-with-cpp20/build/bin`. -Some of these examples use the latest C++ standard, so you will need a modern compiler in order to compile them. The latest stable versions of GCC or [Clang](https://releases.llvm.org/) are recommended. The code is not tested, but expected to work, with MSVC as well. +Some examples use the latest C++ standard, so you will need a modern compiler to compile them. The latest stable versions of GCC or [Clang](https://releases.llvm.org/) are recommended. The code is not tested but is also expected to work with MSVC. ## License