[#SER_PARAMS] = SER_PARAMS :mrdocs: Formatter methods can retrieve parameters attached to a stream using the SER_PARAMS(type) macro as long as the stream is created directly or indirectly with a parameter of that type. This permits making serialization depend on run‐time context in a type‐safe way. == Synopsis Declared in `<serialize.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- #define SER_PARAMS(type) ---- == Description Example use: struct BarParameter { bool fancy; ... }; struct Bar { ... }; struct FooFormatter { FORMATTER_METHODS(Bar, obj) { auto& param = SER_PARAMS(BarParameter); if (param.fancy) { READWRITE(VARINT(obj.value)); } else { READWRITE(obj.value); } } }; which would then be invoked as READWRITE(BarParameter{...}(Using<FooFormatter>(obj.foo))) parameter(obj) can be invoked anywhere in the call stack; it is passed down recursively into all serialization code, until another serialization parameter overrides it. Parameters will be implicitly converted where appropriate. This means that "parent" serialization code can use a parameter that derives from, or is convertible to, a "child" formatter's parameter type. Compilation will fail in any context where serialization is invoked but no parameter of a type convertible to BarParameter is provided. == Parameters [cols="1,4"] |=== | Name| Description | *type* | The parameter type to retrieve from the stream. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#