Do C++ enums Start at 0?

Per that standard [dcl.enum] The enumeration type declared with an enum-key of only enum is an unscoped enumeration, and its enumerators are unscoped enumerators. The enum-keys enum class and enum struct are semantically equivalent; an enumeration type declared with one of these is a scoped enumeration, and its enumerators are scoped enumerators. The optional identifier …

Read more

How do you format the day of the month to say “11th”, “21st” or “23rd” (ordinal indicator)?

// https://github.com/google/guava import static com.google.common.base.Preconditions.*; String getDayOfMonthSuffix(final int n) { checkArgument(n >= 1 && n <= 31, “illegal day of month: ” + n); if (n >= 11 && n <= 13) { return “th”; } switch (n % 10) { case 1: return “st”; case 2: return “nd”; case 3: return “rd”; default: return …

Read more

Difference between InvariantCulture and Ordinal string comparison

InvariantCulture Uses a “standard” set of character orderings (a,b,c, … etc.). This is in contrast to some specific locales, which may sort characters in different orders (‘a-with-acute’ may be before or after ‘a’, depending on the locale, and so on). Ordinal On the other hand, looks purely at the values of the raw byte(s) that …

Read more