diff --git a/README.md b/README.md index ca902c5..92dd22f 100644 --- a/README.md +++ b/README.md @@ -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 +#include bool triggered = false; @@ -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 +#include { auto file = beman::scope::unique_resource( @@ -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 +#include //modular version diff --git a/examples/examples.md b/examples/examples.md new file mode 100644 index 0000000..7ddf8f7 --- /dev/null +++ b/examples/examples.md @@ -0,0 +1,10 @@ +# Scope Examples + +The header-based examples include ``. 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`. | diff --git a/examples/scope_example.cpp b/examples/scope_example.cpp index 9746049..62ea926 100644 --- a/examples/scope_example.cpp +++ b/examples/scope_example.cpp @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include +#include #include #include diff --git a/examples/unique_resource.cpp b/examples/unique_resource.cpp index ea26a98..19f8ec0 100644 --- a/examples/unique_resource.cpp +++ b/examples/unique_resource.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include constexpr size_t arr_size = 10; // clang-format off diff --git a/examples/unique_resource_file.cpp b/examples/unique_resource_file.cpp index ed76cda..9ed8d29 100644 --- a/examples/unique_resource_file.cpp +++ b/examples/unique_resource_file.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include // clang-format off int main() { diff --git a/include/beman/scope.hpp b/include/beman/scope.hpp new file mode 100644 index 0000000..2d4ba7a --- /dev/null +++ b/include/beman/scope.hpp @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#ifndef BEMAN_SCOPE_CONVENIENCE_HPP +#define BEMAN_SCOPE_CONVENIENCE_HPP + +#include + +#endif // BEMAN_SCOPE_CONVENIENCE_HPP diff --git a/tests/beman/scope/scope_exit.test.cpp b/tests/beman/scope/scope_exit.test.cpp index 65acf7a..2882ada 100644 --- a/tests/beman/scope/scope_exit.test.cpp +++ b/tests/beman/scope/scope_exit.test.cpp @@ -2,7 +2,7 @@ // clang-format off -#include +#include #include #include diff --git a/tests/beman/scope/scope_fail.test.cpp b/tests/beman/scope/scope_fail.test.cpp index 47f4530..fd0f07c 100644 --- a/tests/beman/scope/scope_fail.test.cpp +++ b/tests/beman/scope/scope_fail.test.cpp @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include +#include #include #include diff --git a/tests/beman/scope/scope_success.test.cpp b/tests/beman/scope/scope_success.test.cpp index e680cd0..ee947de 100644 --- a/tests/beman/scope/scope_success.test.cpp +++ b/tests/beman/scope/scope_success.test.cpp @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include +#include #include #include diff --git a/tests/beman/scope/unique_resource.test.cpp b/tests/beman/scope/unique_resource.test.cpp index 48f611d..d21ee65 100644 --- a/tests/beman/scope/unique_resource.test.cpp +++ b/tests/beman/scope/unique_resource.test.cpp @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include +#include #include #include #include