Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ is exited with an exception. `scope_success` and `scope_exit` provide similar c
but with different checked conditions on exiting the scope.

```c++
#include <beman/scope/scope.hpp>
#include <beman/scope.hpp>


bool triggered = false;
Expand All @@ -59,7 +59,7 @@ but with different checked conditions on exiting the scope.
`unique_resource` is a cutomizeable RAII type similar to `unique_ptr`.

```c++
#include <beman/scope/scope.hpp>
#include <beman/scope.hpp>

{
auto file = beman::scope::unique_resource(
Expand Down Expand Up @@ -97,7 +97,7 @@ As a header only library no building is required to use in a project -- simply m
the `include` directory available add add the following to your source.

```cpp
#include <beman/scope/scope.hpp>
#include <beman/scope.hpp>

//modular version

Expand Down
10 changes: 10 additions & 0 deletions examples/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Scope Examples

The header-based examples include `<beman/scope.hpp>`. The module example imports `beman.scope` and `std` and requires a compiler and build configuration that support those modules.

| Example | Description |
| --- | --- |
| [`scope_example.cpp`](scope_example.cpp) | Compares manual scope handling with `scope_exit`, `scope_fail`, and `scope_success`. |
| [`unique_resource.cpp`](unique_resource.cpp) | Manages a dynamically allocated integer array with `unique_resource` automatically releases it with `delete[]` on scope exit. |
| [`unique_resource_file.cpp`](unique_resource_file.cpp) | Manages a `FILE*` opened with `fopen`, checks for an open failure and automatically closes the file with `fclose` on scope exit. |
| [`scope_module.cpp`](scope_module.cpp) | Uses `import beman.scope` and `import std` to demonstrate scope guard and `unique_resource`. |
2 changes: 1 addition & 1 deletion examples/scope_example.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <beman/scope/scope.hpp>
#include <beman/scope.hpp>

#include <cstdlib>
#include <iostream>
Expand Down
2 changes: 1 addition & 1 deletion examples/unique_resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <iostream>
#include <memory>
#include <beman/scope/scope.hpp>
#include <beman/scope.hpp>

constexpr size_t arr_size = 10;
// clang-format off
Expand Down
2 changes: 1 addition & 1 deletion examples/unique_resource_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <iostream>
#include <memory>
#include <cstdio>
#include <beman/scope/scope.hpp>
#include <beman/scope.hpp>

// clang-format off
int main() {
Expand Down
8 changes: 8 additions & 0 deletions include/beman/scope.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#ifndef BEMAN_SCOPE_CONVENIENCE_HPP
#define BEMAN_SCOPE_CONVENIENCE_HPP

#include <beman/scope/scope.hpp>

#endif // BEMAN_SCOPE_CONVENIENCE_HPP
2 changes: 1 addition & 1 deletion tests/beman/scope/scope_exit.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// clang-format off

#include <beman/scope/scope.hpp>
#include <beman/scope.hpp>
#include <stdexcept>
#include <string>

Expand Down
2 changes: 1 addition & 1 deletion tests/beman/scope/scope_fail.test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <beman/scope/scope.hpp>
#include <beman/scope.hpp>
#include <stdexcept>
#include <string>

Expand Down
2 changes: 1 addition & 1 deletion tests/beman/scope/scope_success.test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <beman/scope/scope.hpp>
#include <beman/scope.hpp>
#include <stdexcept>
#include <string>

Expand Down
2 changes: 1 addition & 1 deletion tests/beman/scope/unique_resource.test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <beman/scope/scope.hpp>
#include <beman/scope.hpp>
#include <memory>
#include <cstdio>
#include <stdexcept>
Expand Down
Loading