Skip to content

Commit a08e784

Browse files
authored
Merge pull request #26 from bemanproject/23-add-godbolt-links-improve-readme
reorganize the readme - move related work down, add a godbolt link/badge
2 parents d74d6e0 + 9375c02 commit a08e784

File tree

5 files changed

+47
-41
lines changed

5 files changed

+47
-41
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
# ignore emacs temp files
66
*~
7+
\#*\#

README.md

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,64 +4,36 @@ SPDX-License-Identifier: CC0-1.0
44

55
# beman.scope: Generic Scope Guard
66

7-
![Library Status](https://github.com/bemanproject/beman/blob/c6997986557ec6dda98acbdf502082cdf7335526/images/badges/beman_badge-beman_library_under_development.svg)
7+
![Library Status](https://raw.githubusercontent.com/bemanproject/beman/refs/heads/main/images/badges/beman_badge-beman_library_under_development.svg)
88
![Continuous Integration Tests](https://github.com/bemanproject/scope/actions/workflows/ci_tests.yml/badge.svg)
99
![Lint Check (pre-commit)](https://github.com/bemanproject/scope/actions/workflows/pre-commit.yml/badge.svg)
1010

11+
`beman.scope` is a C++ library provides `scope_guard` facilities. The library conforms to [The Beman Standard](https://github.com/bemanproject/beman/blob/main/docs/BEMAN_STANDARD.md).
12+
13+
**Implements**: [D3610R0 Scope Guard](./doc/scope.org) targeted at C++29.
14+
15+
**Status**: [Under development and not yet ready for production use.](https://github.com/bemanproject/beman/blob/main/docs/BEMAN_LIBRARY_MATURITY_MODEL.md#under-development-and-not-yet-ready-for-production-use)
16+
1117
# Overview
1218

1319
During the C++20 cycle [P0052 Generic Scope Guard and RAII Wrapper for the Standard Library](https://wg21.link/P0052)
1420
added 4 types: `scope_exit`, `scope_fail`, `scope_success`
1521
and `unique_resource` to [LTFSv3](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/n4908#scopeguard).
22+
1623
In the intervening time, two standard libraries have implemented support as well as Boost.
1724
With the imperative for safety and security in C++ developers need every tool in the toolbox.
1825
The authors believe it is time to move this facility into the standard.
1926
The paper will re-examine the five year old design and any learning from deployment of the LTFSv3.
2027

21-
For discussions of this library see:
28+
For discussions of this library and related work see:
2229

2330
- [Discourse for discussion of scope](https://discourse.bemanproject.org/t/scope-library/315)
24-
25-
# Prior And Other Work
26-
27-
## Papers
28-
29-
- TS design and wording paper [p0052 - Generic Scope Guard and RAII Wrapper for the Standard Library](https://wg21.link/p0052)
30-
- TS adoption paper [p1411 - Please reconsider <scope> for C++20](https://wg21.link/p1411)
31-
- [N3677 A Proposal to Add additional RAII Wrappers to the Standard Library](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3677.html)
32-
- [N4152 uncaught_exceptions - Sutter](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4152.pdf)
33-
34-
## Implementations
35-
36-
- [GSL final_action](https://github.com/microsoft/GSL/blob/main/include/gsl/util) - part of core guidelines
37-
- [Boost.scope](https://www.boost.org/doc/libs/1_87_0/libs/scope/doc/html/index.html)
38-
- [scope_guard based on Andrei Alexandrescu and Petru Marginean article](https://ricab.github.io/scope_guard)
39-
- [Windows Implementation Libraries (WIL) - scope_exit](https://github.com/microsoft/wil/blob/182e6521140174e1d2ed1920f88d005fc4c546e2/include/wil/resource.h#L660)
40-
- [GCC libstdc++-v3 experimental/scope implementation](https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3/include/experimental/scope;h=6e1d342e1b6486b0d1f32166c7eb91d29ed79f4d;hb=refs/heads/master)
41-
- [LLVM - ADT/ScopeExit.h](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/ADT/ScopeExit.h)
42-
- [libcxx - scope_guard.h](https://github.com/llvm/llvm-project/blob/main/libcxx/include/__utility/scope_guard.h)
43-
- [Folly - ScopeGuard.h](https://github.com/facebook/folly/blob/main/folly/ScopeGuard.h)
44-
- [BDE (Bloomberg) - ScopeExit.h](https://github.com/bloomberg/bde/blob/main/groups/bdl/bdlb/bdlb_scopeexit.h)
45-
46-
## Videos
47-
48-
- [Peter Sommerlad - Woes of Scope Guards and Unique_Resource - 5+ years in the making](https://www.youtube.com/watch?v=O1sK__G5Nrg)
49-
- [Andrei Alexandrescu - Declarative Control Flow](https://www.youtube.com/watch?v=WjTrfoiB0MQ)
50-
51-
# Examples
52-
53-
- [TS example of scope_exit](https://godbolt.org/z/T5KhTYjP7)
54-
55-
---
56-
57-
`beman.scope` is a C++ library conforming to [The Beman Standard](https://github.com/bemanproject/beman/blob/main/docs/BEMAN_STANDARD.md).
58-
59-
**Implements**: D3610R0 Scope Guard for C++29
60-
61-
**Status**: [Under development and not yet ready for production use.](https://github.com/bemanproject/beman/blob/main/docs/BEMAN_LIBRARY_MATURITY_MODEL.md#under-development-and-not-yet-ready-for-production-use)
31+
- [Prior art, papers, related libraries, videos](https://github.com/bemanproject/scope/blob/main/resources.md)
6232

6333
## Usage
6434

35+
- [![Compiler Explorer Example](https://img.shields.io/badge/Try%20it%20on%20Compiler%20Explorer-grey?logo=compilerexplorer&logoColor=67c52a)](https://godbolt.org/z/qMvrsPexd)
36+
6537
The following is an example of using `scope_fail` to trigger and action when the scope
6638
is exited with an exception. `scope_success` and `scope_exit` provide similar capability
6739
but with different checked conditions on exiting the scope.
@@ -136,6 +108,7 @@ Build-time dependencies:
136108
- `cmake`
137109
- `ninja`, `make`, or another CMake-supported build system
138110
- CMake defaults to "Unix Makefiles" on POSIX systems
111+
- `catch2` for building tests
139112

140113
### How to build beman.scope
141114

paper/scope.org

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727

2828
* Introduction
29+
- NOTE: This paper is a draft work in progress.
2930

3031
During the C++20 cycle [[https://wg21.link/P0052][P0052 Generic Scope Guard and RAII Wrapper for the Standard Library]] was added to LTFSv3. In the intervening time, two standard libraries have implemented support as well as Boost. With the imperative for safety and security in C++, developers need every tool in the toolbox. The authors believe it is time to move this facility into the standard. The paper will re-examine the now five plus year old design and any learning from deployments of the LTFSv3.
3132

resources.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!-- SPDX-License-Identifier: CC0-1.0 -->
2+
3+
# Resources
4+
5+
This file contains a variety of links to prior art in this area including related libraries and videos.
6+
7+
## Papers
8+
9+
- TS design and wording paper [p0052 - Generic Scope Guard and RAII Wrapper for the Standard Library](https://wg21.link/p0052)
10+
- TS adoption paper [p1411 - Please reconsider <scope> for C++20](https://wg21.link/p1411)
11+
- [N3677 A Proposal to Add additional RAII Wrappers to the Standard Library](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3677.html)
12+
- [N4152 uncaught_exceptions - Sutter](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4152.pdf)
13+
14+
## Implementations
15+
16+
- [TS example of scope_exit](https://godbolt.org/z/T5KhTYjP7)
17+
- [GSL final_action](https://github.com/microsoft/GSL/blob/main/include/gsl/util) - part of core guidelines
18+
- [gsl-lite `finally`, `on_return`, `on_error`](https://github.com/gsl-lite/gsl-lite/blob/master/doc/Reference.md#ad-hoc-resource-management-c11-and-higher)
19+
- [Boost.scope](https://www.boost.org/doc/libs/1_87_0/libs/scope/doc/html/index.html)
20+
- [scope_guard based on Andrei Alexandrescu and Petru Marginean article](https://ricab.github.io/scope_guard)
21+
- [Windows Implementation Libraries (WIL) - scope_exit](https://github.com/microsoft/wil/blob/182e6521140174e1d2ed1920f88d005fc4c546e2/include/wil/resource.h#L660)
22+
- [GCC libstdc++-v3 experimental/scope implementation](https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=libstdc%2B%2B-v3/include/experimental/scope;h=6e1d342e1b6486b0d1f32166c7eb91d29ed79f4d;hb=refs/heads/master)
23+
- [LLVM - ADT/ScopeExit.h](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/ADT/ScopeExit.h)
24+
- [libcxx - scope_guard.h](https://github.com/llvm/llvm-project/blob/main/libcxx/include/__utility/scope_guard.h)
25+
- [Folly - ScopeGuard.h](https://github.com/facebook/folly/blob/main/folly/ScopeGuard.h)
26+
- [BDE (Bloomberg) - ScopeExit.h](https://github.com/bloomberg/bde/blob/main/groups/bdl/bdlb/bdlb_scopeexit.h)
27+
28+
## Videos
29+
30+
- [Peter Sommerlad - Woes of Scope Guards and Unique_Resource - 5+ years in the making](https://www.youtube.com/watch?v=O1sK__G5Nrg)
31+
- [Andrei Alexandrescu - Declarative Control Flow](https://www.youtube.com/watch?v=WjTrfoiB0MQ)

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ FetchContent_MakeAvailable(Catch2)
1111

1212
set(ALL_TESTNAMES scope_success scope_exit scope_fail unique_resource)
1313

14-
message("Tests to be built: ${ALL_TESTS}")
14+
message("Tests to be built: ${ALL_TESTNAMES}")
1515

1616
include(CTest)
1717
include(Catch)

0 commit comments

Comments
 (0)