0
Files
src/storage
Maksim Moskvitin b47c7e21ee [EnumSet] Refactor constructor usages
TL;DR: EnumSet variadic template ctor is being replaced with ctor
accepting std::initializer_list. Some usages are not compatible and this
CL updates them.

Implicit EnumValue->EnumSet conversions and direct calls of variadic
template constructor (e.g. EnumSet(value1,...)) don't work with
initializer_list ctor. This CL replaces them with:
1. [Only variables initializations] EnumSet set = {value1, ...};
2. [Only inside macro invocations] EnumSet({value1, ...})
3. Implicit construction from initializer_list (note that this is a
special case of implicit conversion, intentionally supported in STL
and by clang-tidy warnings):
foo(value1) -> foo({value1});
foo(EnumSet(value1, ...)) -> foo({value1, ...});
4. EnumSet(value1, ...) -> EnumSet{value1, ...};

Note that 3 and 4 are mostly the same, in most places I made a choice
that resembles pre-existing code closer (exceptions are mostly usages of
Sync EnumSets).

Motivation:
EnumSet variadic template constructor is defective in a sense that it
allows code like this to compile:
using ModelTypeSet = EnumSet<ModelType,...>;
void foo(ModelTypeSet set);
foo(ModelType()); // Typo, intended to pass empty ModelTypeSet.

The problem is that constructor is not explicit. Simply making it
explicit will disallow nice STL-like usage:
class C {
  ModelTypeSet set = {HISTORY, BOOKMARKS};
};

STL and other containers under base/containers avoid this problem by
using std::initializer_list, this refactoring does the same for EnumSet.

This CL was uploaded by git cl split.

R=dcheng@chromium.org

Bug: 1444105
Change-Id: I557b77d610a5ef6a4397ae0f811097ed3dfce65a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4523204
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Auto-Submit: Maksim Moskvitin <mmoskvitin@google.com>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1143387}
2023-05-12 17:57:49 +00:00
..