[all-commits] [llvm/llvm-project] 692c5c: [libc++] Do not call `reserve` in flat containers ...

Hui via All-commits all-commits at lists.llvm.org
Sat Jun 7 00:48:07 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 692c5cdb56a321b0b0e97dd08cf90878cd6970fb
      https://github.com/llvm/llvm-project/commit/692c5cdb56a321b0b0e97dd08cf90878cd6970fb
  Author: Hui <hui.xie1990 at gmail.com>
  Date:   2025-06-07 (Sat, 07 Jun 2025)

  Changed paths:
    M libcxx/include/__flat_map/flat_map.h
    M libcxx/include/__flat_map/flat_multimap.h
    M libcxx/include/__flat_set/flat_multiset.h
    M libcxx/include/__flat_set/flat_set.h
    M libcxx/include/__type_traits/container_traits.h
    M libcxx/include/__vector/container_traits.h
    M libcxx/include/deque
    M libcxx/include/forward_list
    M libcxx/include/list
    M libcxx/include/map
    M libcxx/include/set
    M libcxx/include/unordered_map
    M libcxx/include/unordered_set
    M libcxx/test/std/containers/container.adaptors/flat.map/flat.map.modifiers/insert_iter_iter.pass.cpp
    M libcxx/test/std/containers/container.adaptors/flat.multimap/flat.multimap.modifiers/insert_iter_iter.pass.cpp
    M libcxx/test/std/containers/container.adaptors/flat.multiset/flat.multiset.modifiers/insert_iter_iter.pass.cpp
    M libcxx/test/std/containers/container.adaptors/flat.set/flat.set.modifiers/insert_iter_iter.pass.cpp
    M libcxx/test/std/containers/container.adaptors/flat_helpers.h

  Log Message:
  -----------
  [libc++] Do not call `reserve` in flat containers if underlying container is user defined (#140379)

This is brought up in the LWG reflector. We currently call `reserve` if
the underlying container has one. But the spec does not specify what
`reserve` should do for Sequence Container. So in theory if the
underlying container is user defined type and it can have a function
called `reserve` which does something completely different.

The fix is to just call `reserve` for STL containers if it has one



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list