[libcxx-commits] [libcxx] [libc++] Add container_traits (prework for `std::flat_map`) (PR #109578)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Sep 27 10:36:30 PDT 2024
================
@@ -0,0 +1,28 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+#ifndef _LIBCPP___TYPE_TRAITS_CONTAINER_TRAITS_H
+#define _LIBCPP___TYPE_TRAITS_CONTAINER_TRAITS_H
+
+#include <__config>
+#include <__type_traits/integral_constant.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+struct __container_traits {
----------------
ldionne wrote:
Let's add a short comment explaining the purpose of this class, and the fact that it's intended to be extended in the future. It is also worth mentioning that this trait is not meaningful for types that don't have `insert(...)` and `emplace(...)`, for example `std::array`. I think it's fine if the traits appear to "lie" for such types.
Also, let's add a comment explaining what `__emplacement_has_strong_exception_safety_guarantee` does a bit more precisely. It obviously has something to do with emplacement and exceptions safety, but for example is `insert(...)` also included in this trait? Does this connect to a container.req clause in the standard?
Since this is a general-purpose trait, it makes sense to make it as generally useful as possible.
https://github.com/llvm/llvm-project/pull/109578
More information about the libcxx-commits
mailing list