File tree Expand file tree Collapse file tree 3 files changed +41
-3
lines changed Expand file tree Collapse file tree 3 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -32,17 +32,20 @@ namespace cib::detail {
3232 }
3333 }
3434
35- return str. size () ;
35+ return 0 ;
3636 }
3737
3838 // clang-8 and below don't have constexpr find_last_of on std::string_view
3939 CIB_CONSTEVAL std::string_view::size_type find_last_of (std::string_view str, char c) {
4040 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++) {
4243 if (str[i] == c) {
43- return i;
44+ match = i;
4445 }
4546 }
47+
48+ return match;
4649 }
4750
4851 template <typename Tag>
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ add_executable(tests
99 callback.cpp
1010 nexus.cpp
1111 detail/ordered_set.cpp
12+ readme_hello_world.cpp
1213)
1314
1415if (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