In functional programming, the degenerate case is often called "unit". In C++, "void" is often the best analogue. However, because of the syntactic special‐casing required for void, it is frequently a liability for template metaprogramming. So, instead of writing specializations to handle cases like SomeContainer<void>, a library author may instead rule that out and simply have library users use SomeContainer<Unit>. Contained values may be ignored. Much easier.
Synopsis
Declared in <folly/Unit.h>
struct Unit;
Description
"void" is the type that admits of no values at all. It is not possible to construct a value of this type. "unit" is the type that admits of precisely one unique value. It is possible to construct a value of this type, but it is always the same value every time, so it is uninteresting.
Member Functions
Name |
Description |
Compare two Unit values for equality. |
|
Compare two Unit values for inequality. |
Non-Member Functions
Name |
Description |
Try to split a string into a fixed number of fields by delimiter, using folly::tryTo<> for conversions. types by delimiter. ‐ On success, all output values will be initialized and the 'Unit{}' value is returned. Arguments are assigned in reverse order. ‐ On failure, the first failing 'ConversionCode' is returned with its associated substring in a 'SubstringConversionCode'. ‐ String splitting is performed prior to each conversion; field values will not contain the delimiter. ‐ All custom error codes are mapped to ConversionCode::CUSTOM. |
|
Same as makeTask(). See Unit |
|
Same as make_now_task(). See Unit |
|
Like parseTo in folly/Conv.h, but the "source" is SettingValueAndMetadata instead of a StringPiece. Defaults to folly::tryTo<T>(StringPiece) but can be overridden using ADL for user defined types. |
Created with MrDocs