File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 8686 max-size : " 2G"
8787 - name : Compile
8888 run : |
89- $CXX --version
9089 cmake -B build -G Ninja -DORYX_CRT_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release
9190 cmake --build build
9291 - name : Run tests
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ template <class... Args>
1717class CallbackList {
1818public:
1919 using ID = uint64_t ;
20+ using Callback = std::function<void (Args...)>;
2021
2122 static constexpr ID kIDMax = std::numeric_limits<ID >::max();
2223 /* *
@@ -41,13 +42,11 @@ class CallbackList {
4142 ID id_;
4243 };
4344
44- using Callback = std::function<void (Args...)>;
45-
4645 CallbackList () = default;
4746
4847 auto Subscribe (Callback&& cb) -> Handle {
4948 ID id = id_.fetch_add (1 , std::memory_order_relaxed);
50- subs_.Apply ([&](auto & subs) mutable { subs.emplace_back (id, std::forward<Callback>(cb)); });
49+ subs_.Apply ([&](auto & subs) { subs.emplace_back (id, std::forward<Callback>(cb)); });
5150 return Handle (id);
5251 }
5352
Original file line number Diff line number Diff line change @@ -13,7 +13,14 @@ namespace oryx {
1313template <class T >
1414class LazyComponent {
1515public:
16- using FactoryContainer = std::move_only_function<T()>;
16+ #ifdef __cpp_lib_move_only_function
17+ template <typename ... S>
18+ using FunctionType = std::move_only_function<S...>;
19+ #else
20+ template <typename ... S>
21+ using FunctionType = std::function<S...>;
22+ #endif
23+ using FactoryContainer = FunctionType<T()>;
1724
1825 LazyComponent () = default ;
1926
@@ -53,7 +60,7 @@ class LazyComponent {
5360 }
5461
5562 std::once_flag created_flag_{};
56- std::move_only_function<T()> factory_{};
63+ FactoryContainer factory_{};
5764 mutable std::unique_ptr<T> value_{};
5865};
5966
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ TEST_CASE("Retryable succeeds after some tries") {
3636TEST_CASE (" Exhausting max retries" ) {
3737 int tries = 4 ;
3838 int tries_so_far = 0 ;
39- auto retryable = [&]() -> bool {
39+ auto retryable = [&]() {
4040 tries_so_far++;
4141
4242 if (tries_so_far == tries) {
@@ -56,14 +56,14 @@ TEST_CASE("Passing a custom predicate") {
5656 int tries_so_far = 0 ;
5757 int tries = 5 ;
5858
59- auto never_succeeds = [&] -> bool {
59+ auto never_succeeds = [&]() {
6060 if (++tries_so_far == tries) {
6161 flag = true ;
6262 }
6363 return false ;
6464 };
6565
66- auto stopper = [&flag] -> bool { return flag; };
66+ auto stopper = [&flag]() { return flag; };
6767 auto config = kDefaultConfig ;
6868 config.max_retries = 10 ;
6969 CHECK_FALSE (retry::ExponentialBackoff (config, never_succeeds, stopper));
@@ -75,7 +75,7 @@ TEST_CASE("Works with stop token as expected") {
7575 int tries_so_far = 0 ;
7676 int tries = 5 ;
7777
78- auto never_succeeds = [&] -> bool {
78+ auto never_succeeds = [&]() {
7979 if (++tries_so_far == tries) {
8080 ssource.request_stop ();
8181 }
You can’t perform that action at this time.
0 commit comments