1
0
Fork 0

Compare commits

...

2 Commits

Author SHA1 Message Date
mandlm ea6777f7ea
feat(wip): if constexpr 2023-10-22 21:43:45 +02:00
mandlm 03756b0429
build: write binaries to bin folder 2023-10-22 21:43:45 +02:00
10 changed files with 37 additions and 7 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
/build /.build
/.cache /.cache
/bin

View File

@ -21,7 +21,7 @@ repos:
hooks: hooks:
- id: clang-format - id: clang-format
- id: clang-tidy - id: clang-tidy
args: [-p=build] args: [-p=.build]
- repo: https://github.com/cheshirekow/cmake-format-precommit - repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13 rev: v0.6.13

View File

@ -31,6 +31,12 @@ target_include_directories(
target_link_libraries(book_exercises PRIVATE chapter_02) target_link_libraries(book_exercises PRIVATE chapter_02)
set_target_properties(
book_exercises
PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin"
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin"
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin")
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
add_subdirectory(tests) add_subdirectory(tests)
endif() endif()

View File

@ -1,3 +1,3 @@
#!/usr/bin/env sh #!/usr/bin/env sh
cmake -S . -B build -G Ninja -D CMAKE_EXPORT_COMPILE_COMMANDS=ON cmake -S . -B .build -G Ninja -D CMAKE_EXPORT_COMPILE_COMMANDS=ON

View File

@ -1,3 +1,3 @@
#!/usr/bin/env sh #!/usr/bin/env sh
cmake --build build cmake --build .build

View File

@ -1,6 +1,12 @@
add_library( add_library(
chapter_02 src/initlist.cpp src/null.cpp src/constexp.cpp src/ifswitch.cpp chapter_02
src/structured_binding.cpp src/type_inference.cpp) 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) target_compile_features(chapter_02 PUBLIC cxx_std_20)

View File

@ -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"; }
};

View File

@ -0,0 +1,6 @@
#include <iostream>
#include <type_traits>
#include "if_constexpr.h"
void IfConstexprTest::run() {}

View File

@ -4,6 +4,7 @@
#include <vector> #include <vector>
#include "constexp.h" #include "constexp.h"
#include "if_constexpr.h"
#include "ifswitch.h" #include "ifswitch.h"
#include "initlist.h" #include "initlist.h"
#include "null.h" #include "null.h"
@ -24,6 +25,7 @@ int main(int argc, char **argv) {
chapter_2_tests.emplace_back(std::make_unique<InitListTest>()); chapter_2_tests.emplace_back(std::make_unique<InitListTest>());
chapter_2_tests.emplace_back(std::make_unique<StructuredBindingTest>()); chapter_2_tests.emplace_back(std::make_unique<StructuredBindingTest>());
chapter_2_tests.emplace_back(std::make_unique<TypeInferenceTest>()); chapter_2_tests.emplace_back(std::make_unique<TypeInferenceTest>());
chapter_2_tests.emplace_back(std::make_unique<IfConstexprTest>());
for (auto &test : chapter_2_tests) { for (auto &test : chapter_2_tests) {
std::cout << "\n" << test->name() << ":" << std::endl; std::cout << "\n" << test->name() << ":" << std::endl;

View File

@ -1,3 +1,3 @@
#!/usr/bin/env sh #!/usr/bin/env sh
cmake --build build && cmake --build build --target test cmake --build .build && cmake --build .build --target test