mirror of
https://github.com/Naios/continuable.git
synced 2025-12-11 22:19:54 +08:00
add static asserts
This commit is contained in:
parent
0cf353d576
commit
913b414b1f
@ -21,6 +21,11 @@
|
||||
|
||||
#include "Callback.h"
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
} // detail
|
||||
|
||||
template <typename... _ATy>
|
||||
struct Continuable
|
||||
{
|
||||
@ -37,9 +42,9 @@ struct Continuable
|
||||
: _callback_insert(std::forward<_FTy>(callback_insert)) { }
|
||||
|
||||
template <typename _CTy>
|
||||
Continuable<_ATy...>& then(_CTy&&)
|
||||
Continuable<_ATy...> then(_CTy&&)
|
||||
{
|
||||
return *this;
|
||||
return Continuable<_ATy...>();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -160,6 +160,15 @@ namespace fu
|
||||
struct is_unwrappable
|
||||
: decltype(detail::test_unwrappable<Function...>(0)) { };
|
||||
|
||||
template<typename T>
|
||||
struct requires_functional_constructible
|
||||
{
|
||||
static_assert(is_unwrappable<typename std::decay<T>::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_
|
||||
|
||||
9
test.cpp
9
test.cpp
@ -78,7 +78,7 @@ int main(int /*argc*/, char** /*argv*/)
|
||||
|
||||
// Continuable<Callback<SpellCastResult>> spell
|
||||
CastSpell(63362)
|
||||
.then([](SpellCastResult result)
|
||||
.then([](SpellCastResult result)
|
||||
{
|
||||
return CastSpell(63362);
|
||||
})
|
||||
@ -95,6 +95,13 @@ int main(int /*argc*/, char** /*argv*/)
|
||||
|
||||
});
|
||||
|
||||
std::vector<int> myvec;
|
||||
|
||||
typedef fu::requires_functional_constructible<std::function<void()>>::type test_assert1;
|
||||
// typedef fu::requires_functional_constructible<std::vector<int>>::type test_assert2;
|
||||
|
||||
// auto cba2 = make_continuable(myvec);
|
||||
|
||||
std::cout << "ok" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user