| Home | Libraries | People | FAQ | More

#### Formattable concept

A type `T` is `Formattable` if it can be passed as a format argument to SQL formatting functions, like `format_sql`.

Formally, let `T` be any type, and `U` the result of stripping cv-qualifiers and references from `T`. `T` satisfies `Formattable` if any of the following are true:

- `U` satisfies `WritableField`. This includes scalar types and optionals.
- The class `formatter` has been specialized for `U`.
- `T` is a formattable range, or a reference to one. Formally, given a variable `t` of type `T` (that might be a reference), `T` is a formattable range if:
  - `std::begin(t)` and `std::end(t)` return an iterator/sentinel pair that can be compared for (in)equality.
  - The type `std::decay_t<decltype(*std::begin(t))>` is a `WritableField` or has a specialized formatter. In other words, the range's element type must be either an elemental type or have a custom formatted defined, but must not be a range.
  - `U` does not satisfy `WritableField` (i.e. `vector<unsigned char>` is formatted as a blob, not as a sequence).
- `U` is `formattable_ref`.

For a reference table on built-in formattable types, see this section.