Skip to content

Commit 2c64e3e

Browse files
committed
make project buildable
1 parent d705cdc commit 2c64e3e

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ option(
2020
${PROJECT_IS_TOP_LEVEL}
2121
)
2222

23-
include(FetchContent)
2423
include(GNUInstallDirs)
2524

2625
add_subdirectory(src/beman/scope)

examples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ message("Examples to be built: ${ALL_EXAMPLES}")
77
foreach(example ${ALL_EXAMPLES})
88
add_executable(beman.scope.examples.${example})
99
target_sources(beman.scope.examples.${example} PRIVATE ${example}.cpp)
10+
target_link_libraries(beman.scope.examples.${example} beman::scope)
1011
endforeach()

examples/scope_example.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
22

3-
// #include <beman/scope/scope.hpp>
3+
#include <beman/scope/scope.hpp>
44

55
#include <cstdlib>
66
#include <iostream>
77
#include <string_view>
88

9-
// using scope = beman::scope;
9+
namespace scope = beman::scope;
1010

1111
void print_exit_status(std::string_view name, bool exit_status, bool did_throw) {
1212
std::cout << name << ":\n";
@@ -35,7 +35,7 @@ int main() {
3535
// Using scope_exit: runs on scope exit (success or exception)
3636
exit_status = did_throw = false;
3737
try {
38-
// auto guard = std::experimental::scope_exit{[&] { exit_status = true; }};
38+
auto guard = scope::scope_exit{[&] { exit_status = true; }};
3939
maybe_throw();
4040
} catch (...) {
4141
did_throw = true;
@@ -45,7 +45,7 @@ int main() {
4545
// Using scope_fail: runs only if an exception occurs
4646
exit_status = did_throw = false;
4747
try {
48-
// auto guard = std::experimental::scope_fail{[&] { exit_status = true; }};
48+
auto guard = scope::scope_fail{[&] { exit_status = true; }};
4949
maybe_throw();
5050
} catch (...) {
5151
did_throw = true;
@@ -55,7 +55,7 @@ int main() {
5555
// Using scope_success: runs only if no exception occurs
5656
exit_status = did_throw = false;
5757
try {
58-
// auto guard = std::experimental::scope_success{[&] { exit_status = true; }};
58+
auto guard = scope::scope_success{[&] { exit_status = true; }};
5959
maybe_throw();
6060
} catch (...) {
6161
did_throw = true;

include/beman/scope/scope.hpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,26 @@
33
#ifndef BEMAN_SCOPE_HPP
44
#define BEMAN_SCOPE_HPP
55

6-
namespace beman::scope {} // namespace beman::scope
6+
namespace beman::scope {
7+
8+
// TODO: Implement
9+
struct scope_exit {
10+
template <typename F>
11+
scope_exit(F) {}
12+
};
13+
14+
// TODO: Implement
15+
struct scope_fail {
16+
template <typename F>
17+
scope_fail(F) {}
18+
};
19+
20+
// TODO: Implement
21+
struct scope_success {
22+
template <typename F>
23+
scope_success(F) {}
24+
};
25+
26+
} // namespace beman::scope
727

828
#endif // BEMAN_SCOPE_HPP

0 commit comments

Comments
 (0)