File tree 3 files changed +41
-3
lines changed 3 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -32,17 +32,20 @@ namespace cib::detail {
32
32
}
33
33
}
34
34
35
- return str. size () ;
35
+ return 0 ;
36
36
}
37
37
38
38
// clang-8 and below don't have constexpr find_last_of on std::string_view
39
39
CIB_CONSTEVAL std::string_view::size_type find_last_of (std::string_view str, char c) {
40
40
using size_type = std::string_view::size_type;
41
- for (size_type i = str.size () - 1 ; true ; i--) {
41
+ size_type match = str.size ();
42
+ for (size_type i = 0 ; i < str.size (); i++) {
42
43
if (str[i] == c) {
43
- return i;
44
+ match = i;
44
45
}
45
46
}
47
+
48
+ return match;
46
49
}
47
50
48
51
template <typename Tag>
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ add_executable(tests
9
9
callback.cpp
10
10
nexus.cpp
11
11
detail/ordered_set.cpp
12
+ readme_hello_world.cpp
12
13
)
13
14
14
15
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
Original file line number Diff line number Diff line change
1
+ #include < cib/cib.hpp>
2
+
3
+ #include < catch2/catch_test_macros.hpp>
4
+
5
+ #include < cstdio>
6
+
7
+ struct say_message : public cib ::callback_meta<>{};
8
+
9
+ // the 'core' component exposes the 'say_message' service for others to extend
10
+ struct core {
11
+ constexpr static auto config = cib::exports<say_message>;
12
+ };
13
+
14
+ // the 'say_hello_world' component extends 'say_message' with its own functionality
15
+ struct say_hello_world {
16
+ constexpr static auto config =
17
+ cib::extend <say_message>([](){
18
+ puts (" Hello, world!\n " );
19
+ });
20
+ };
21
+
22
+ // the 'hello_world' project composes 'core' and 'say_hello_world'
23
+ struct hello_world {
24
+ constexpr static auto config =
25
+ cib::components<core, say_hello_world>;
26
+ };
27
+
28
+ // the nexus instantiates the project
29
+ cib::nexus<hello_world> nexus{};
30
+
31
+
32
+ TEST_CASE (" make sure the simple hello world example compiles" ) {
33
+ nexus.service <say_message>();
34
+ }
You can’t perform that action at this time.
0 commit comments