Function FilterGenerator
Synopsis
#include <include/internal/catch_generators_generic.hpp>
template <typename P = Predicate>
FilterGenerator(P &&pred, GeneratorWrapper< T > &&generator)
Description
No description yet.
Source
Lines 58-71 in include/internal/catch_generators_generic.hpp.
template <typename P = Predicate>
FilterGenerator(P&& pred, GeneratorWrapper<T>&& generator):
m_generator(std::move(generator)),
m_predicate(std::forward<P>(pred))
{
if (!m_predicate(m_generator.get())) {
// It might happen that there are no values that pass the
// filter. In that case we throw an exception.
auto has_initial_value = next();
if (!has_initial_value) {
Catch::throw_exception(GeneratorException("No valid value found in filtered generator"));
}
}
}