SpECTRE  v2024.05.11
db::protocols::Mutator Struct Reference

A DataBox mutator. More...

#include <Mutator.hpp>


struct  test

Detailed Description

A DataBox mutator.

A class conforming to this protocol can be used as the template argument for a call to db::mutate_apply(const gsl::not_null<DataBox<BoxTags>*> box, Args&&... args). The conforming class must provide the following:

  • return_tags: A type list of tags corresponding to mutable items in the DataBox passed to db::mutate_apply that may be modified.
  • argument_tags: A type list of tags corresponding to items in the DataBox passed to db::mutate_apply that may not be modified.
  • apply: A static function whose return value is returned by db::mutate_apply, and that takes as arguments:

    • A const gsl::not_null<Tag::type*> for each Tag in return_tags
    • A const db::const_item_type<Tag, BoxTags> for each Tag in argument_tags
    • The additional arguments passed to db::mutate_apply

    Note: use the explicit type whenever possible, not the type aliases. db::const_item_type will usually be Tag::type unless that is a std::unique_ptr<T>, in which case it will be T

Here is an example for a class conforming to this protocol:

struct ExampleMutator : tt::ConformsTo<db::protocols::Mutator> {
using return_tags = tmpl::list<ExampleSimpleTag0, ExampleSimpleTag1>;
using argument_tags = tmpl::list<ExampleSimpleTag2>;
static void apply(const gsl::not_null<double*> item_0,
const gsl::not_null<int*> item_1, const double item_2,
const int additional_arg) {
*item_0 = 2.0 * item_2;
*item_1 = 2 * additional_arg;
Require a pointer to not be a nullptr
Definition: Gsl.hpp:183
constexpr auto apply(F &&f, const DataBox< BoxTags > &box, Args &&... args)
Apply the invokable f with argument Tags TagsList from DataBox box
Definition: DataBox.hpp:1602
Indicate a class conforms to the Protocol.
Definition: ProtocolHelpers.hpp:22

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