PSA: base::Contains() lives in base/containers/contains.h, not base/stl_util.h

43 views
Skip to first unread message

Lei Zhang

unread,
May 18, 2021, 1:54:48 AM5/18/21
to Chromium-dev
Hi Chromium devs,

As part of https://crbug.com/970209, https://crrev.com/883799 moved
base::Contains() from base/stl_util.h to base/containers/contains.h 6
months ago. However, base/stl_util.h still includes
base/containers/contains.h, so if you are not aware of this, you may
be still including base/stl_util.h for base::Contains(), or not
including anything, since stl_util.h is transitively included in many
other headers. This will likely change by next week when I fix all the
existing missing includes and then remove base/containers/contains.h
from base/stl_util.h. So please remember to include what you use, and
include the correct header for base::Contains().

Lei Zhang

unread,
May 20, 2021, 11:34:13 PM5/20/21
to Chromium-dev
I've prepped https://crrev.com/c/2901614 to remove
base/containers/contains.h from base/stl_util.h. I will try to land it
over this upcoming weekend to try to avoid colliding with another CL.

Lei Zhang

unread,
May 24, 2021, 11:25:37 AM5/24/21
to Chromium-dev
The CL I prepped to remove base/containers/contains.h from
base/stl_util.h landed as https://crrev.com/885763. Please remember to
#include "base/containers/contains.h" when using base::Contains() in
the future.

Lei Zhang

unread,
Jan 16, 2026, 2:40:59 PM (2 days ago) Jan 16
to Chromium-dev, Lei Zhang
An update to base::Contains(): As of https://crrev.com/1570540, which hopefully does not get reverted, base/containers/contains.h has been deleted. Please stop trying to use base::Contains() in new code. See https://groups.google.com/a/chromium.org/g/chromium-dev/c/IwpCkAdQHXg for details.
Reply all
Reply to author
Forward
0 new messages