add static asserts

This commit is contained in:
Denis Blank 2015-06-11 16:57:53 +02:00 committed by Naios
parent 0cf353d576
commit 913b414b1f
3 changed files with 24 additions and 3 deletions

View File

@ -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...>();
}
};

View File

@ -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_

View File

@ -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;
}