diff --git a/scientific_cpp.pptx b/scientific_cpp.pptx index eba8d46..e61444d 100644 Binary files a/scientific_cpp.pptx and b/scientific_cpp.pptx differ diff --git a/source-code/Boost/ProgramOptions/random_default.cpp b/source-code/Boost/ProgramOptions/random_default.cpp index 8bd450d..dcb35ea 100644 --- a/source-code/Boost/ProgramOptions/random_default.cpp +++ b/source-code/Boost/ProgramOptions/random_default.cpp @@ -9,10 +9,7 @@ using Options = std::tuple; Options get_options(int argc, char* argv[]); int main(int argc, char* argv[]) { - int n; - double a, b; - size_t seed; - std::tie(n, a, b, seed) = get_options(argc, argv); + auto [n, a, b, seed] = get_options(argc, argv); std::mt19937 engine(seed); std::uniform_real_distribution distr(a, b); diff --git a/source-code/UserDefinedTypes/ObjectLifeCycle/CMakeLists.txt b/source-code/UserDefinedTypes/ObjectLifeCycle/CMakeLists.txt new file mode 100644 index 0000000..3ded173 --- /dev/null +++ b/source-code/UserDefinedTypes/ObjectLifeCycle/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.20) + +project(object_life_cycle LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +add_executable(gadget.exe gadget.cpp) + +add_executable(emplace.exe emplace.cpp) diff --git a/source-code/UserDefinedTypes/ObjectLifeCycle/Makefile b/source-code/UserDefinedTypes/ObjectLifeCycle/Makefile deleted file mode 100644 index be01bb8..0000000 --- a/source-code/UserDefinedTypes/ObjectLifeCycle/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -CXX = g++ -CXXFLAGS = -std=c++17 -O2 -g -Wall -Wextra -CPPFLAGS = -MMD -MP -LDLIBS = -lm - -all: gadget.exe emplace.exe - -%.exe: %.o - $(CXX) $(CXXFLAGS) -o $@ $^ $(LDLIBS) - --include $(wildcard *.d) - -clean: - $(RM) $(wildcard *.exe) $(wildcard *.o) $(wildcard *.d) - $(RM) core $(wildcard core.*) diff --git a/source-code/UserDefinedTypes/ObjectLifeCycle/README.md b/source-code/UserDefinedTypes/ObjectLifeCycle/README.md index e95bfcb..3468579 100644 --- a/source-code/UserDefinedTypes/ObjectLifeCycle/README.md +++ b/source-code/UserDefinedTypes/ObjectLifeCycle/README.md @@ -7,4 +7,4 @@ copy constructors, copy assignment, and copy elision. 1. `gadget.cpp`: driver function to illustrate the various life cycle scenarios of an object. 1. `emplace.cpp`: example of using emplace for vectors. - 1. `Makefile`: make file to build the application. + 1. `CMakeLists.txt`: CMake file to build the application. diff --git a/source-code/UserDefinedTypes/ObjectLifeCycle/emplace.cpp b/source-code/UserDefinedTypes/ObjectLifeCycle/emplace.cpp index c539537..6aff165 100644 --- a/source-code/UserDefinedTypes/ObjectLifeCycle/emplace.cpp +++ b/source-code/UserDefinedTypes/ObjectLifeCycle/emplace.cpp @@ -4,7 +4,9 @@ struct S { S() { puts("S()"); } S(const S&) { puts("S(&)"); } + S& operator=(const S&) { puts("S=&"); return *this; } S(S&&) { puts("S(&&)"); } + S& operator=(S&&) { puts("S=&&"); return *this; } ~S() { puts("~S()"); } };