From ffb3db7089c86b24d2fe359a94e7fedffe41e1de Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Mon, 2 Sep 2019 01:03:28 +0200 Subject: [PATCH] Fix the asio example * Attempt to fix the GCC warning in a different way --- examples/example-asio/example-asio.cpp | 6 ++- .../single/test-continuable-result.cpp | 10 +---- test/unit-test/test-continuable.hpp | 42 ++++++++----------- 3 files changed, 23 insertions(+), 35 deletions(-) diff --git a/examples/example-asio/example-asio.cpp b/examples/example-asio/example-asio.cpp index acbf5bd..2a12098 100644 --- a/examples/example-asio/example-asio.cpp +++ b/examples/example-asio/example-asio.cpp @@ -67,7 +67,11 @@ struct functional_io_service { auto trough_post() noexcept { return [&](auto&& work) mutable { - asio::post(service_, std::forward(work)); + asio::post(service_, + [work = std::forward(work)]() mutable { + std::move(work)(); + // .. or: work.set_value(); + }); }; } diff --git a/test/unit-test/single/test-continuable-result.cpp b/test/unit-test/single/test-continuable-result.cpp index 121c32a..bfedadc 100644 --- a/test/unit-test/single/test-continuable-result.cpp +++ b/test/unit-test/single/test-continuable-result.cpp @@ -62,15 +62,7 @@ using unique_type = result>; using result_test_types = testing::Types; -// https://github.com/google/googletest/issues/2271 -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" -#endif -TYPED_TEST_SUITE(result_all_tests, result_test_types); -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +TYPED_TEST_SUITE(result_all_tests, result_test_types, name_generator); TYPED_TEST(result_all_tests, is_default_constructible) { TypeParam e; diff --git a/test/unit-test/test-continuable.hpp b/test/unit-test/test-continuable.hpp index c04f1ed..11aa0c0 100644 --- a/test/unit-test/test-continuable.hpp +++ b/test/unit-test/test-continuable.hpp @@ -33,6 +33,7 @@ #include #include #include +#include using cti::detail::identity; using cti::detail::util::unused; @@ -48,7 +49,7 @@ auto to_hint(identity hint) { template auto supplier_of(Args&&... args) { return [values = std::make_tuple(std::forward(args)...)]( - auto&& promise) mutable { + auto&& promise) mutable { EXPECT_TRUE(promise); cti::detail::traits::unpack( [&](auto&&... passed) { @@ -115,12 +116,12 @@ struct provide_copyable { struct provide_unique { template auto make(identity, identity, T&& callback) { - return cti::make_continuable([ - callback = std::forward(callback), guard = std::make_unique(0) - ](auto&&... args) mutable { - (void)(*guard); - return std::move(callback)(std::forward(args)...); - }); + return cti::make_continuable( + [callback = std::forward(callback), + guard = std::make_unique(0)](auto&&... args) mutable { + (void)(*guard); + return std::move(callback)(std::forward(args)...); + }); } }; @@ -205,18 +206,17 @@ struct tag1 {}; struct tag2 {}; struct tag3 {}; +struct name_generator { + template + static std::string GetName(int i) { + return std::to_string(i); + } +}; + template struct single_dimension_tests : continuation_provider {}; -// https://github.com/google/googletest/issues/2271 -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" -#endif -TYPED_TEST_SUITE(single_dimension_tests, single_types); -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +TYPED_TEST_SUITE(single_dimension_tests, single_types, name_generator); template struct combine_to_type; @@ -258,15 +258,7 @@ struct single_aggregate_tests> : continuation_provider, Connector {}; -// https://github.com/google/googletest/issues/2271 -#ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" -#endif -TYPED_TEST_SUITE(single_aggregate_tests, aggregate_types); -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif +TYPED_TEST_SUITE(single_aggregate_tests, aggregate_types, name_generator); template auto make_step(T* me, unsigned& current, unsigned step) {