diff --git a/include/rapidcheck/Gen.hpp b/include/rapidcheck/Gen.hpp index 7d8f124e..65517e9e 100644 --- a/include/rapidcheck/Gen.hpp +++ b/include/rapidcheck/Gen.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #include "rapidcheck/detail/Any.h" @@ -17,6 +18,13 @@ Gen::type>> map(Gen gen, } // namespace gen +// Concept check for types that have method +// `Shrinkable G::operator()(const Random &, int) const` +template +using MakesShrinkable = std::is_convertible< + decltype(std::declval()(std::declval(), 0)), + Shrinkable>; + template class Gen::IGenImpl { public: @@ -55,7 +63,10 @@ class Gen::GenImpl : public IGenImpl { template template Gen::Gen(Impl &&impl) - : m_impl(new GenImpl>(std::forward(impl))) {} + : m_impl(new GenImpl>(std::forward(impl))) { + static_assert(MakesShrinkable>::value, + "Generator implementation must have a method Shrinkable operator()(const Random &, int) const"); +} template std::string Gen::name() const {