diff --git a/fluent/Continuable.h b/fluent/Continuable.h index cbb1814..cd30026 100644 --- a/fluent/Continuable.h +++ b/fluent/Continuable.h @@ -21,6 +21,11 @@ #include "Callback.h" +namespace detail +{ + +} // detail + template struct Continuable { @@ -37,9 +42,9 @@ struct Continuable : _callback_insert(std::forward<_FTy>(callback_insert)) { } template - Continuable<_ATy...>& then(_CTy&&) + Continuable<_ATy...> then(_CTy&&) { - return *this; + return Continuable<_ATy...>(); } }; diff --git a/fluent/functional_unwrap.hpp b/fluent/functional_unwrap.hpp index d490a71..8d24541 100644 --- a/fluent/functional_unwrap.hpp +++ b/fluent/functional_unwrap.hpp @@ -160,6 +160,15 @@ namespace fu struct is_unwrappable : decltype(detail::test_unwrappable(0)) { }; + template + struct requires_functional_constructible + { + static_assert(is_unwrappable::type>::value, + "Given type is not functional unwrappable, did you try to use a std::bind expression or a non functional type?"); + + typedef T type; + }; + } // fu #endif // _FUNCTIONAL_UNWRAP_HPP_ diff --git a/test.cpp b/test.cpp index b7e21a3..cb1b967 100644 --- a/test.cpp +++ b/test.cpp @@ -78,7 +78,7 @@ int main(int /*argc*/, char** /*argv*/) // Continuable> spell CastSpell(63362) - .then([](SpellCastResult result) + .then([](SpellCastResult result) { return CastSpell(63362); }) @@ -95,6 +95,13 @@ int main(int /*argc*/, char** /*argv*/) }); + std::vector myvec; + + typedef fu::requires_functional_constructible>::type test_assert1; + // typedef fu::requires_functional_constructible>::type test_assert2; + + // auto cba2 = make_continuable(myvec); + std::cout << "ok" << std::endl; return 0; }