Skip to content

Use library for reference snippets #381

Description

@mvandeberg

The documentation occasionally references snippets that are verbatim from the library.

For example:

// tag::executor_concept[]
template<class E>
concept Executor =
std::is_nothrow_copy_constructible_v<E> &&
std::is_nothrow_move_constructible_v<E> &&
requires(E& e, E const& ce, E const& ce2,
continuation c)
{
{ ce == ce2 } noexcept -> std::convertible_to<bool>;
{ ce.context() } noexcept;
requires std::is_lvalue_reference_v<
decltype(ce.context())> &&
std::derived_from<
std::remove_reference_t<
decltype(ce.context())>,
execution_context>;
{ ce.on_work_started() } noexcept;
{ ce.on_work_finished() } noexcept;
{ ce.dispatch(c) } -> std::same_as<std::coroutine_handle<>>;
{ ce.post(c) };
};
// end::executor_concept[]

is an exact copy of:

template<class E>
concept Executor =
std::is_nothrow_copy_constructible_v<E> &&
std::is_nothrow_move_constructible_v<E> &&
requires(E& e, E const& ce, E const& ce2, continuation c) {
{ ce == ce2 } noexcept -> std::convertible_to<bool>;
{ ce.context() } noexcept;
requires std::is_lvalue_reference_v<decltype(ce.context())> &&
std::derived_from<
std::remove_reference_t<decltype(ce.context())>,
execution_context>;
{ ce.on_work_started() } noexcept;
{ ce.on_work_finished() } noexcept;
{ ce.dispatch(c) } -> std::same_as<std::coroutine_handle<>>;
{ ce.post(c) };
};

The purpose of the snippets is to ensure they build and cannot drift. This concept being redeclared allows for drift.

All snippets should be audited for similar instances and tagged to use code from the library itself so it is impossible for these doc references to drift from the library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions