Writing a Visitor
To avoid assuming a particular set of operations WTF relies on the visitor pattern. This page should eventually be a tutorial, but for now is just a set of notes.
Assume that visitor is an object of type T. The dispatch function will
additionally require a std::tuple<FPList...> where FPList... is a list
of the floating-point types you want to be able to support. Then assume we are
trying to dispatch based on the wrapped types of N FloatBuffer objects.
Tmust be a callable type, i.e., defineoperator(). Functions, lambdas, and functors all satisfy this criterionoperator()may be overloaded. If it is overloaded, the usual C++ overloadresolution rules will be used to select the appropriate overload.
- Dispatching considers the type of the floating point buffers and the number of
floating point buffers.
operator()overloads must accentNparameters.operator()must possess an overload capable of supporting any permutation with replacement of the types inFPLists....The easiest way to satisfy this is to have a templated overload with
Ntemplate parameters (one for the type of each positional argument).
Each
FloatBufferwill be unwrapped to astd::span<U>object whereUis the type of the wrapped floating point objects.