Move transforms in their own toplevel namespace

This commit is contained in:
Denis Blank 2017-10-11 17:04:01 +02:00
parent 5c4d28233c
commit 20c54f54cb
2 changed files with 11 additions and 4 deletions

View File

@ -35,6 +35,12 @@
#include <continuable/detail/transforms.hpp> #include <continuable/detail/transforms.hpp>
namespace cti { namespace cti {
/// The namespace transforms declares callable objects that transform
/// any continuable_base to an object or to a continuable_base itself.
///
/// Transforms can be applied to continuables through using
/// the continuable-base::apply method accordingly.
namespace transforms {
/// Returns a transform that if applied to a continuable, /// Returns a transform that if applied to a continuable,
/// it will start the continuation chain and returns the asynchronous /// it will start the continuation chain and returns the asynchronous
/// result as `std::future<...>`. /// result as `std::future<...>`.
@ -76,6 +82,7 @@ inline auto flatten() {
return std::forward<decltype(continuable)>(continuable).fail([](auto&&) {}); return std::forward<decltype(continuable)>(continuable).fail([](auto&&) {});
}; };
} }
} // namespace transforms
} // namespace cti } // namespace cti
#endif // CONTINUABLE_TRANSFORMS_HPP_INCLUDED__ #endif // CONTINUABLE_TRANSFORMS_HPP_INCLUDED__

View File

@ -36,7 +36,7 @@ bool is_ready(T& future) {
TYPED_TEST(single_dimension_tests, are_convertible_to_futures) { TYPED_TEST(single_dimension_tests, are_convertible_to_futures) {
{ {
auto future = this->supply().apply(cti::futurize()); auto future = this->supply().apply(cti::transforms::futurize());
ASSERT_TRUE(is_ready(future)); ASSERT_TRUE(is_ready(future));
future.get(); future.get();
} }
@ -47,7 +47,7 @@ TYPED_TEST(single_dimension_tests, are_convertible_to_futures) {
// ... // ...
return 0xFD; return 0xFD;
}) })
.apply(cti::futurize()); .apply(cti::transforms::futurize());
ASSERT_TRUE(is_ready(future)); ASSERT_TRUE(is_ready(future));
EXPECT_EQ(future.get(), 0xFD); EXPECT_EQ(future.get(), 0xFD);
@ -69,8 +69,8 @@ TYPED_TEST(single_dimension_tests, are_convertible_to_futures) {
} }
TYPED_TEST(single_dimension_tests, are_flattable) { TYPED_TEST(single_dimension_tests, are_flattable) {
auto continuation = auto continuation = this->supply_exception(supply_test_exception())
this->supply_exception(supply_test_exception()).apply(cti::flatten()); .apply(cti::transforms::flatten());
ASSERT_ASYNC_INCOMPLETION(std::move(continuation)); ASSERT_ASYNC_INCOMPLETION(std::move(continuation));
} }