Skip to content

Commit c71ac3e

Browse files
committed
Feat: add example/scope-module if possible
1 parent ad5c639 commit c71ac3e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

examples/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
set(ALL_EXAMPLES scope_example unique_resource unique_resource-file)
44

5+
# module tests will only compile with gcc15 or clang20 and above
6+
if(CMAKE_CXX_SCAN_FOR_MODULES AND CMAKE_CXX_STANDARD GREATER 20)
7+
list(APPEND ALL_EXAMPLES scope-module)
8+
endif()
9+
510
message("Examples to be built: ${ALL_EXAMPLES}")
611

712
foreach(example ${ALL_EXAMPLES})

examples/scope-module.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
// destroy noisy
1616
// scope exit: true success: true fail: false
1717

18+
#ifdef HAS_MODULE_STD
1819
import std;
20+
#else
21+
#include <print>
22+
#endif
23+
1924
import beman.scope;
2025

2126
// clang-format off

0 commit comments

Comments
 (0)