-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
externalize lambda examples and simple tests (not unit tests)
- Loading branch information
George K. Thiruvathukal
committed
Oct 3, 2023
1 parent
9bd4782
commit 4026aee
Showing
12 changed files
with
116 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,28 @@ | ||
add_executable(cli11-mva cli11-mva.cpp) | ||
target_link_libraries(cli11-mva fmt::fmt spdlog::spdlog CLI11::CLI11) | ||
|
||
add_executable(auto-mva auto-mva.cpp) | ||
target_link_libraries(auto-mva fmt::fmt spdlog::spdlog CLI11::CLI11) | ||
|
||
add_executable(auto-with-stl auto-with-stl.cpp) | ||
target_link_libraries(auto-with-stl fmt::fmt spdlog::spdlog CLI11::CLI11) | ||
|
||
#add_executable(const-constexpr const-constexpr.cpp) | ||
#target_link_libraries(const-constexpr fmt::fmt spdlog::spdlog CLI11::CLI11) | ||
|
||
add_executable(mc-triangle mc-triangle.cpp) | ||
target_link_libraries(mc-triangle fmt::fmt spdlog::spdlog CLI11::CLI11) | ||
|
||
add_executable(mc-triangle-threads mc-triangle-threads.cpp) | ||
target_link_libraries(mc-triangle-threads fmt::fmt spdlog::spdlog CLI11::CLI11) | ||
|
||
add_executable(move-mvp move-mvp.cpp) | ||
target_link_libraries(move-mvp fmt::fmt spdlog::spdlog CLI11::CLI11) | ||
|
||
add_executable(point_demo point_demo.cpp) | ||
target_link_libraries(point_demo fmt::fmt spdlog::spdlog CLI11::CLI11) | ||
|
||
add_executable(random-hist random-hist.cpp) | ||
target_link_libraries(random-hist fmt::fmt spdlog::spdlog CLI11::CLI11) | ||
|
||
add_executable(range1 range1.cpp) | ||
target_link_libraries(range1 fmt::fmt spdlog::spdlog CLI11::CLI11) | ||
|
||
add_executable(range2 range2.cpp) | ||
target_link_libraries(range2 fmt::fmt spdlog::spdlog CLI11::CLI11) | ||
|
||
#add_executable(sleep-coroutine sleep-coroutine.cpp) | ||
#target_link_libraries(sleep-coroutine fmt::fmt spdlog::spdlog CLI11::CLI11) | ||
|
||
add_executable(weak_ptr weak_ptr.cpp) | ||
target_link_libraries(weak_ptr fmt::fmt spdlog::spdlog CLI11::CLI11) | ||
function(add_my_executable target_name) | ||
add_executable(${target_name} ${target_name}.cpp) | ||
target_link_libraries(${target_name} fmt::fmt spdlog::spdlog CLI11::CLI11) | ||
endfunction() | ||
|
||
set(MY_APP_NAMES cli11-mva | ||
auto-mva | ||
auto-with-stl | ||
mc-triangle | ||
mc-triangle-threads | ||
move-mvp | ||
point-demo | ||
random-hist | ||
range1 | ||
range2 | ||
weak-ptr | ||
lambda-no-parameters | ||
lambda-with-parameters | ||
lambda-with-closures-byref | ||
lambda-with-closures-byref-all | ||
lambda-with-closures-byval | ||
lambda-with-closures-byval-all | ||
lambda-with-return-type | ||
) | ||
|
||
foreach(APP_NAME IN LISTS MY_APP_NAMES) | ||
add_my_executable(${APP_NAME}) | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <iostream> | ||
|
||
int main() { | ||
auto sayHello = []() { | ||
std::cout << "Hello from lambda!" << std::endl; | ||
}; | ||
|
||
sayHello(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
#include <iostream> | ||
|
||
int main() { | ||
int a = 5; | ||
int b = 10; | ||
|
||
auto sum = [=]() { | ||
return a + b; | ||
}; | ||
|
||
std::cout << "Sum" << sum() << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <iostream> | ||
|
||
int main() { | ||
int a = 5; | ||
int b = 10; | ||
|
||
auto incrementA = [&a]() { | ||
a++; | ||
}; | ||
|
||
incrementA(); | ||
std::cout << "a = " << a << std::endl; // 6 | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include <iostream> | ||
|
||
int main() { | ||
int a = 5; | ||
int b = 10; | ||
|
||
auto incrementBoth = [&]() { | ||
a++; | ||
b++; | ||
}; | ||
|
||
incrementBoth(); | ||
std::cout << "Increment Both " << "a = " << a << " b = " << b << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <iostream> | ||
|
||
int main() { | ||
int a = 5; | ||
int b = 10; | ||
|
||
auto sum = [a, b]() { | ||
return a + b; | ||
}; | ||
|
||
std::cout << "Sum = " << sum() << std::endl; // 15 | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <iostream> | ||
|
||
int main() { | ||
auto divide = [](double a, double b) -> double { | ||
if (b == 0.0) return 0.0; // handle division by zero | ||
return a / b; | ||
}; | ||
|
||
std::cout << "8.0 / 2.0 = " << divide(8.0, 2.0) << std::endl; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include <iostream> | ||
|
||
int main() { | ||
auto divide = [](double a, double b) -> double { | ||
if (b == 0.0) return 0.0; // handle division by zero | ||
return a / b; | ||
}; | ||
|
||
std::cout << "8.0 / 2.0 = " << divide(8.0, 2.0) << std::endl; | ||
return 0; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.