Duff's delimiter

From vegard.wiki
Revision as of 16:55, 14 March 2020 by Vegard (talk | contribs) (new page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Example:

switch (int i = 0; count) {
case 0:
    for (; i < count; ++i) {
        printf(", ");
        // fallthrough
default:
        printf("%s", strings[i]);
    }
}

Invented by Joe Groff (https://twitter.com/jckarter/status/1238669170767585280) and named by John Regehr (https://twitter.com/johnregehr/status/1238670958199635968).

This particular version requires C++17.