add static asserts

This commit is contained in:
Naios 2015-06-11 16:57:53 +02:00
parent 092f83f74b
commit fe5a922fc7
3 changed files with 24 additions and 3 deletions

View File

@ -21,6 +21,11 @@
#include "Callback.h" #include "Callback.h"
namespace detail
{
} // detail
template <typename... _ATy> template <typename... _ATy>
struct Continuable struct Continuable
{ {
@ -37,9 +42,9 @@ struct Continuable
: _callback_insert(std::forward<_FTy>(callback_insert)) { } : _callback_insert(std::forward<_FTy>(callback_insert)) { }
template <typename _CTy> 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 struct is_unwrappable
: decltype(detail::test_unwrappable<Function...>(0)) { }; : 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 } // fu
#endif // _FUNCTIONAL_UNWRAP_HPP_ #endif // _FUNCTIONAL_UNWRAP_HPP_

View File

@ -78,7 +78,7 @@ int main(int /*argc*/, char** /*argv*/)
// Continuable<Callback<SpellCastResult>> spell // Continuable<Callback<SpellCastResult>> spell
CastSpell(63362) CastSpell(63362)
.then([](SpellCastResult result) .then([](SpellCastResult result)
{ {
return CastSpell(63362); 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; std::cout << "ok" << std::endl;
return 0; return 0;
} }