Hegel 0.18.3
Property-based testing for C++
Loading...
Searching...
No Matches
hegel::generators::DeferredGeneratorDefinition< T, Printable > Class Template Reference

A forward reference to a generator whose definition is provided later. More...

#include <combinators.h>

Public Types

using Handle = detail::handle_t<Printable, T>
 The handle type of the generator.

Public Member Functions

Handle generator () const
 Return a handle that delegates to whatever is later passed to set(). May be called multiple times. Drawing from it before set() is called throws.
void set (Handle gen)
 Set the implementation for this deferred generator.

Detailed Description

template<typename T, bool Printable = true>
class hegel::generators::DeferredGeneratorDefinition< T, Printable >

A forward reference to a generator whose definition is provided later.

Created by deferred() or deferred_silent(). Call generator() to obtain handles that can be embedded in other generators before the implementation is known, then call set() to install it. This enables self-recursive and mutually recursive generators.

Template Parameters
TValue type produced by the eventual generator.
PrintableWhether the generator is printable: true for deferred(), false for deferred_silent().

Member Function Documentation

◆ generator()

template<typename T, bool Printable = true>
Handle hegel::generators::DeferredGeneratorDefinition< T, Printable >::generator ( ) const
inline

Return a handle that delegates to whatever is later passed to set(). May be called multiple times. Drawing from it before set() is called throws.

The handle prints what the installed generator prints.

Returns
A Generator (an AnyGenerator for deferred_silent()) that delegates to the implementation installed by set().

◆ set()

template<typename T, bool Printable = true>
void hegel::generators::DeferredGeneratorDefinition< T, Printable >::set ( Handle gen)
inline

Set the implementation for this deferred generator.

All handles previously returned by generator() delegate to gen. May be called only once. A second call throws. Drawing from a handle before set() is called throws.

Parameters
genThe generator to install as the implementation.

The documentation for this class was generated from the following file: