Skip to content

Commit 6ecb758

Browse files
Merge pull request #1 from bemanproject/scope1-transfer
Update README.md - and attempt to satisfy ci and remove exemplar cruft
2 parents 231c3f4 + be25679 commit 6ecb758

File tree

9 files changed

+75
-329
lines changed

9 files changed

+75
-329
lines changed

CMakeLists.txt

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.25)
44

55
project(beman.scope DESCRIPTION "Generic Scope Guard" LANGUAGES CXX)
66

7-
enable_testing()
7+
# enable_testing()
88

99
# [CMAKE.SKIP_TESTS]
1010
option(
@@ -23,24 +23,11 @@ option(
2323
include(FetchContent)
2424
include(GNUInstallDirs)
2525

26-
if(BEMAN_SCOPE_BUILD_TESTS)
27-
# Fetch GoogleTest
28-
FetchContent_Declare(
29-
googletest
30-
GIT_REPOSITORY https://github.com/google/googletest.git
31-
GIT_TAG
32-
f8d7d77c06936315286eb55f8de22cd23c188571 # release-1.14.0
33-
EXCLUDE_FROM_ALL
34-
)
35-
set(INSTALL_GTEST OFF) # Disable GoogleTest installation
36-
FetchContent_MakeAvailable(googletest)
37-
endif()
38-
39-
add_subdirectory(src/beman/scope)
26+
# add_subdirectory(src/beman/scope)
4027

41-
if(BEMAN_SCOPE_BUILD_TESTS)
42-
add_subdirectory(tests/beman/scope)
43-
endif()
28+
#if(BEMAN_SCOPE_BUILD_TESTS)
29+
# add_subdirectory(tests/beman/scope)
30+
#endif()
4431

4532
if(BEMAN_SCOPE_BUILD_EXAMPLES)
4633
add_subdirectory(examples)

README.md

Lines changed: 48 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,55 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
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 minimal C++ library conforming to [The Beman Standard](https://github.com/bemanproject/beman/blob/main/docs/BEMAN_STANDARD.md).
12-
This can be used as a template for those intending to write Beman libraries.
13-
It may also find use as a minimal and modern C++ project structure.
11+
# Overview
1412

15-
**Implements**: `std::identity` proposed in [Standard Library Concepts (P0898R3)](https://wg21.link/P0898R3).
13+
During the C++20 cycle [P0052 Generic Scope Guard and RAII Wrapper for the Standard Library](https://wg21.link/P0052) added 4 types: `scope_exit`, `scope_fail`, `scope_success` and `unique_resource` to [LTFSv3](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/n4908#scopeguard). 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 five year old design and any learning from deployment of the LTFSv3.
14+
15+
For discussions of this library see:
16+
17+
- [Discourse for discussion of scope](https://discourse.bemanproject.org/t/scope-library/315)
18+
19+
# Prior And Other Work
20+
21+
## Papers
22+
23+
- TS design and wording paper [p0052 - Generic Scope Guard and RAII Wrapper for the Standard Library](https://wg21.link/p0052)
24+
- TS adoption paper [p1411 - Please reconsider <scope> for C++20](https://wg21.link/p1411)
25+
- [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)
26+
- [N4152 uncaught_exceptions - Sutter](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4152.pdf)
27+
28+
## Implementations
29+
30+
- [GSL final_action](https://github.com/microsoft/GSL/blob/main/include/gsl/util) - part of core guidelines
31+
- [Boost.scope](https://www.boost.org/doc/libs/1_87_0/libs/scope/doc/html/index.html)
32+
- [scope_guard based on Andrei Alexandrescu and Petru Marginean article](https://ricab.github.io/scope_guard)
33+
- [Windows Implementation Libraries (WIL) - scope_exit](https://github.com/microsoft/wil/blob/182e6521140174e1d2ed1920f88d005fc4c546e2/include/wil/resource.h#L660)
34+
- [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)
35+
- [LLVM - ADT/ScopeExit.h](https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/ADT/ScopeExit.h)
36+
- [libcxx - scope_guard.h](https://github.com/llvm/llvm-project/blob/main/libcxx/include/__utility/scope_guard.h)
37+
- [Folly - ScopeGuard.h](https://github.com/facebook/folly/blob/main/folly/ScopeGuard.h)
38+
- [BDE (Bloomberg) - ScopeExit.h](https://github.com/bloomberg/bde/blob/main/groups/bdl/bdlb/bdlb_scopeexit.h)
39+
40+
## Videos
41+
42+
- [Peter Sommerlad - Woes of Scope Guards and Unique_Resource - 5+ years in the making](https://www.youtube.com/watch?v=O1sK__G5Nrg)
43+
- [Andrei Alexandrescu - Declarative Control Flow](https://www.youtube.com/watch?v=WjTrfoiB0MQ)
44+
45+
# Examples
46+
47+
- [TS example of scope_exit](https://godbolt.org/z/T5KhTYjP7)
48+
49+
---
50+
51+
`beman.scope` is a C++ library conforming to [The Beman Standard](https://github.com/bemanproject/beman/blob/main/docs/BEMAN_STANDARD.md).
52+
53+
**Implements**: TODO
1654

1755
**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)
1856

1957
## Usage
2058

21-
`std::identity` is a function object type whose `operator()` returns its argument unchanged.
22-
`std::identity` serves as the default projection in constrained algorithms.
23-
Its direct usage is usually not needed.
59+
TODO
2460

2561
### Example Usage
2662

@@ -31,7 +67,6 @@ Full runnable examples can be found in `examples/`.
3167
## Building beman.scope
3268

3369
### Dependencies
34-
<!-- TODO Darius: rewrite section!-->
3570

3671
This project has no C or C++ dependencies.
3772

@@ -84,9 +119,7 @@ apt-get install \
84119

85120
### How to build beman.scope
86121

87-
This project strives to be as normal and simple a CMake project as possible.
88-
This build workflow in particular will work,
89-
producing a static `libbeman.scope.a` library, ready to package with its headers:
122+
Beman scope is header only.
90123

91124
```shell
92125
cmake --workflow --preset gcc-debug
@@ -109,126 +142,10 @@ Preset CMake variables:
109142
CMAKE_CXX_FLAGS="-fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=leak -fsanitize=undefined"
110143
CMAKE_CXX_STANDARD="20"
111144

112-
-- The CXX compiler identification is GNU 11.4.0
113-
-- Detecting CXX compiler ABI info
114-
-- Detecting CXX compiler ABI info - done
115-
-- Check for working CXX compiler: /usr/bin/g++ - skipped
116-
-- Detecting CXX compile features
117-
-- Detecting CXX compile features - done
118-
-- The C compiler identification is GNU 11.4.0
119-
-- Detecting C compiler ABI info
120-
-- Detecting C compiler ABI info - done
121-
-- Check for working C compiler: /usr/bin/cc - skipped
122-
-- Detecting C compile features
123-
-- Detecting C compile features - done
124-
-- Found Python3: /usr/bin/python3.10 (found version "3.10.12") found components: Interpreter
125-
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
126-
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
127-
-- Found Threads: TRUE
128-
-- Configuring done
129-
-- Generating done
130-
-- Build files have been written to: /home/runner/work/scope/exemplar/build/gcc-debug
131-
132-
Executing workflow step 2 of 3: build preset "gcc-debug"
133-
134-
[1/14] Building CXX object src/beman/scope/CMakeFiles/beman.exemplar.dir/identity.cpp.o
135-
[2/14] Linking CXX static library src/beman/scope/libbeman.exemplar.a
136-
[3/14] Building CXX object examples/CMakeFiles/beman.scope.examples.identity_direct_usage.dir/identity_direct_usage.cpp.o
137-
[4/14] Linking CXX executable examples/beman.scope.examples.identity_direct_usage
138-
[5/14] Building CXX object _deps/googletest-build/googletest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.o
139-
[6/14] Building CXX object src/beman/scope/CMakeFiles/beman.exemplar.tests.dir/identity.t.cpp.o
140-
[7/14] Building CXX object _deps/googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o
141-
[8/14] Building CXX object _deps/googletest-build/googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.o
142-
[9/14] Building CXX object _deps/googletest-build/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
143-
[10/14] Linking CXX static library lib/libgtest.a
144-
[11/14] Linking CXX static library lib/libgtest_main.a
145-
[12/14] Linking CXX static library lib/libgmock.a
146-
[13/14] Linking CXX static library lib/libgmock_main.a
147-
[14/14] Linking CXX executable src/beman/scope/beman.exemplar.tests
148-
149-
Executing workflow step 3 of 3: test preset "gcc-debug"
150-
151-
Test project /home/runner/work/scope/exemplar/build/gcc-debug
152-
Start 1: IdentityTest.call_identity_with_int
153-
1/4 Test #1: IdentityTest.call_identity_with_int ........... Passed 0.13 sec
154-
Start 2: IdentityTest.call_identity_with_custom_type
155-
2/4 Test #2: IdentityTest.call_identity_with_custom_type ... Passed 0.01 sec
156-
Start 3: IdentityTest.compare_std_vs_beman
157-
3/4 Test #3: IdentityTest.compare_std_vs_beman ............. Passed 0.01 sec
158-
Start 4: IdentityTest.check_is_transparent
159-
4/4 Test #4: IdentityTest.check_is_transparent ............. Passed 0.01 sec
160-
161-
100% tests passed, 0 tests failed out of 4
162-
163-
Total Test time (real) = 0.18 sec
164-
165-
# Configure beman.scope via gcc-release workflow for direct usage.
166-
$ cmake --workflow --preset gcc-release
167-
Executing workflow step 1 of 3: configure preset "gcc-release"
168-
169-
Preset CMake variables:
170-
171-
CMAKE_BUILD_TYPE="RelWithDebInfo"
172-
CMAKE_CXX_COMPILER="g++"
173-
CMAKE_CXX_FLAGS="-O3"
174-
CMAKE_CXX_STANDARD="20"
175-
176-
-- The CXX compiler identification is GNU 11.4.0
177-
-- Detecting CXX compiler ABI info
178-
-- Detecting CXX compiler ABI info - done
179-
-- Check for working CXX compiler: /usr/bin/g++ - skipped
180-
-- Detecting CXX compile features
181-
-- Detecting CXX compile features - done
182-
-- The C compiler identification is GNU 11.4.0
183-
-- Detecting C compiler ABI info
184-
-- Detecting C compiler ABI info - done
185-
-- Check for working C compiler: /usr/bin/cc - skipped
186-
-- Detecting C compile features
187-
-- Detecting C compile features - done
188-
-- Found Python3: /usr/bin/python3.10 (found version "3.10.12") found components: Interpreter
189-
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
190-
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
191-
-- Found Threads: TRUE
192-
-- Configuring done
193-
-- Generating done
194-
-- Build files have been written to: /home/runner/work/scope/exemplar/build/gcc-release
195-
196-
Executing workflow step 2 of 3: build preset "gcc-release"
197-
198-
[1/14] Building CXX object src/beman/scope/CMakeFiles/beman.exemplar.dir/identity.cpp.o
199-
[2/14] Linking CXX static library src/beman/scope/libbeman.exemplar.a
200-
[3/14] Building CXX object examples/CMakeFiles/beman.scope.examples.identity_direct_usage.dir/identity_direct_usage.cpp.o
201-
[4/14] Linking CXX executable examples/beman.scope.examples.identity_direct_usage
202-
[5/14] Building CXX object _deps/googletest-build/googletest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.o
203-
[6/14] Building CXX object src/beman/scope/CMakeFiles/beman.exemplar.tests.dir/identity.t.cpp.o
204-
[7/14] Building CXX object _deps/googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o
205-
[8/14] Building CXX object _deps/googletest-build/googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.o
206-
[9/14] Building CXX object _deps/googletest-build/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
207-
[10/14] Linking CXX static library lib/libgtest.a
208-
[11/14] Linking CXX static library lib/libgtest_main.a
209-
[12/14] Linking CXX static library lib/libgmock.a
210-
[13/14] Linking CXX executable src/beman/scope/beman.exemplar.tests
211-
[14/14] Linking CXX static library lib/libgmock_main.a
212-
213-
Executing workflow step 3 of 3: test preset "gcc-release"
214-
215-
Test project /home/runner/work/scope/exemplar/build/gcc-release
216-
Start 1: IdentityTest.call_identity_with_int
217-
1/4 Test #1: IdentityTest.call_identity_with_int ........... Passed 0.00 sec
218-
Start 2: IdentityTest.call_identity_with_custom_type
219-
2/4 Test #2: IdentityTest.call_identity_with_custom_type ... Passed 0.00 sec
220-
Start 3: IdentityTest.compare_std_vs_beman
221-
3/4 Test #3: IdentityTest.compare_std_vs_beman ............. Passed 0.00 sec
222-
Start 4: IdentityTest.check_is_transparent
223-
4/4 Test #4: IdentityTest.check_is_transparent ............. Passed 0.00 sec
224-
225-
100% tests passed, 0 tests failed out of 4
226-
227-
Total Test time (real) = 0.01 sec
145+
TODO
228146

229147
# Run examples.
230-
$ build/gcc-release/examples/beman.scope.examples.identity_direct_usage
231-
2024
148+
$ TODO
232149

233150
```
234151

@@ -251,9 +168,8 @@ $ tree /opt/beman.scope
251168
├── include
252169
│   └── beman
253170
│   └── scope
254-
│   └── identity.hpp
255-
└── lib
256-
└── libbeman.scope.a
171+
│   └── scope.hpp
172+
257173

258174
4 directories, 2 files
259175
```

examples/CMakeLists.txt

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
11
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
22

3-
set(ALL_EXAMPLES identity_direct_usage)
4-
5-
# Example `identity_as_default_projection` need ranges support:
6-
include(CheckCXXSymbolExists)
7-
check_cxx_symbol_exists(__cpp_lib_ranges "ranges" HAS_RANGES)
8-
9-
if(HAS_RANGES)
10-
list(APPEND ALL_EXAMPLES identity_as_default_projection)
11-
else()
12-
message(
13-
WARNING
14-
"Missing range support! Skip: identity_as_default_projection"
15-
)
16-
endif()
3+
set(ALL_EXAMPLES scope_example)
174

185
message("Examples to be built: ${ALL_EXAMPLES}")
196

207
foreach(example ${ALL_EXAMPLES})
218
add_executable(beman.scope.examples.${example})
229
target_sources(beman.scope.examples.${example} PRIVATE ${example}.cpp)
23-
target_link_libraries(beman.scope.examples.${example} beman::scope)
2410
endforeach()

examples/identity_as_default_projection.cpp

Lines changed: 0 additions & 74 deletions
This file was deleted.

examples/identity_direct_usage.cpp

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)