From f1bd1b74e4b79c53ab7ab6b6f1a0d008ff6034e6 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 22 Oct 2023 21:43:17 +0200 Subject: [PATCH] feat(wip): if constexpr --- chapters/chapter_02/CMakeLists.txt | 10 ++++++++-- chapters/chapter_02/include/if_constexpr.h | 9 +++++++++ chapters/chapter_02/src/if_constexpr.cpp | 6 ++++++ src/main.cpp | 2 ++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 chapters/chapter_02/include/if_constexpr.h create mode 100644 chapters/chapter_02/src/if_constexpr.cpp diff --git a/chapters/chapter_02/CMakeLists.txt b/chapters/chapter_02/CMakeLists.txt index 2bc50d2..6236fdc 100644 --- a/chapters/chapter_02/CMakeLists.txt +++ b/chapters/chapter_02/CMakeLists.txt @@ -1,6 +1,12 @@ add_library( - chapter_02 src/initlist.cpp src/null.cpp src/constexp.cpp src/ifswitch.cpp - src/structured_binding.cpp src/type_inference.cpp) + chapter_02 + src/initlist.cpp + src/null.cpp + src/constexp.cpp + src/ifswitch.cpp + src/structured_binding.cpp + src/type_inference.cpp + src/if_constexpr.cpp) target_compile_features(chapter_02 PUBLIC cxx_std_20) diff --git a/chapters/chapter_02/include/if_constexpr.h b/chapters/chapter_02/include/if_constexpr.h new file mode 100644 index 0000000..f696d16 --- /dev/null +++ b/chapters/chapter_02/include/if_constexpr.h @@ -0,0 +1,9 @@ +#pragma once + +#include "chapter_interface.h" + +class IfConstexprTest : public ChapterTest { +public: + virtual void run() override; + virtual const char *name() const override { return "If constexpr test"; } +}; diff --git a/chapters/chapter_02/src/if_constexpr.cpp b/chapters/chapter_02/src/if_constexpr.cpp new file mode 100644 index 0000000..1bfa840 --- /dev/null +++ b/chapters/chapter_02/src/if_constexpr.cpp @@ -0,0 +1,6 @@ +#include +#include + +#include "if_constexpr.h" + +void IfConstexprTest::run() {} diff --git a/src/main.cpp b/src/main.cpp index 94d49ce..4a567c3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,6 +4,7 @@ #include #include "constexp.h" +#include "if_constexpr.h" #include "ifswitch.h" #include "initlist.h" #include "null.h" @@ -24,6 +25,7 @@ int main(int argc, char **argv) { chapter_2_tests.emplace_back(std::make_unique()); chapter_2_tests.emplace_back(std::make_unique()); chapter_2_tests.emplace_back(std::make_unique()); + chapter_2_tests.emplace_back(std::make_unique()); for (auto &test : chapter_2_tests) { std::cout << "\n" << test->name() << ":" << std::endl;