Export of internal Abseil changes
-- 47f13ea42ae272c995b1cd5073a45e046fa325eb by Matthew Brown <matthewbr@google.com>: absl::StrFormat: Centralize FormatConversionCharSet vs FormatConversionSpec checking - Move it into a central location, rather than requiring individual overloads to validate. PiperOrigin-RevId: 310583805 -- a567c8fc8032031d551d6b457755851f442e65ad by Gennadiy Rozental <rogeeff@google.com>: Internal change PiperOrigin-RevId: 310427635 -- 49848f7fab9b0f528d33f60cbccf688e2ea68afa by Gennadiy Rozental <rogeeff@google.com>: Make Get/Set private methods of absl::Flag<T>. PiperOrigin-RevId: 310413908 GitOrigin-RevId: 47f13ea42ae272c995b1cd5073a45e046fa325eb Change-Id: I6530c754731c1a9463877561fa61786460ed60af
This commit is contained in:
parent
a35ef8a62c
commit
c45d1c09d5
8 changed files with 148 additions and 36 deletions
|
|
@ -327,12 +327,16 @@ constexpr FormatConversionCharSet FormatConversionCharSetUnion(
|
|||
static_cast<uint64_t>(FormatConversionCharSetUnion(rest...)));
|
||||
}
|
||||
|
||||
constexpr uint64_t FormatConversionCharToConvInt(FormatConversionChar c) {
|
||||
return uint64_t{1} << (1 + static_cast<uint8_t>(c));
|
||||
}
|
||||
|
||||
constexpr uint64_t FormatConversionCharToConvInt(char conv) {
|
||||
return
|
||||
#define ABSL_INTERNAL_CHAR_SET_CASE(c) \
|
||||
conv == #c[0] ? (uint64_t{1} << (1 + static_cast<uint8_t>( \
|
||||
FormatConversionCharInternal::c))) \
|
||||
:
|
||||
#define ABSL_INTERNAL_CHAR_SET_CASE(c) \
|
||||
conv == #c[0] \
|
||||
? FormatConversionCharToConvInt(FormatConversionCharInternal::c) \
|
||||
:
|
||||
ABSL_INTERNAL_CONVERSION_CHARS_EXPAND_(ABSL_INTERNAL_CHAR_SET_CASE, )
|
||||
#undef ABSL_INTERNAL_CHAR_SET_CASE
|
||||
conv == '*'
|
||||
|
|
@ -406,6 +410,11 @@ constexpr bool Contains(FormatConversionCharSet set,
|
|||
static_cast<uint64_t>(c);
|
||||
}
|
||||
|
||||
// Checks whether all the characters in `c` are contained in `set`
|
||||
constexpr bool Contains(FormatConversionCharSet set, FormatConversionChar c) {
|
||||
return (static_cast<uint64_t>(set) & FormatConversionCharToConvInt(c)) != 0;
|
||||
}
|
||||
|
||||
// Return capacity - used, clipped to a minimum of 0.
|
||||
inline size_t Excess(size_t used, size_t capacity) {
|
||||
return used < capacity ? capacity - used : 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue