X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FUnit.h;h=df99eba27bebfb0bfc0ad8276d840e466bcd4481;hb=0826d16bb14b477fa619a4a30f4d8c000f381ff4;hp=cb6a6566df41a57ead7ea60d940e338f639bc61c;hpb=a3323738a37ad3e8cae4a70931728e82fb5aeb6f;p=folly.git diff --git a/folly/Unit.h b/folly/Unit.h index cb6a6566..df99eba2 100644 --- a/folly/Unit.h +++ b/folly/Unit.h @@ -21,11 +21,18 @@ namespace folly { /// 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 a liability for template -/// metaprogramming. So, instead of e.g. Future, we have Future. -/// You can ignore the actual value, and we port some of the syntactic -/// niceties like setValue() instead of setValue(Unit{}). +/// 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, a library author may instead rule that out and simply +/// have library users use SomeContainer. Contained values may be ignored. +/// Much easier. +/// +/// "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. struct Unit { template using Lift = std::conditional::value, Unit, T>;