[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 Oct 11 10:17:56 PDT 2024
================
@@ -0,0 +1,36 @@
+// -*- 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>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// __container_traits is a general purpose struct contains traits of containers' different operations.
+// It currently only has one trait: `__emplacement_has_strong_exception_safety_guarantee`, but it's
+// intended to be extended in the future.
+// If a container does not support an operation. For example, `std::array` does not support `insert`
+// or `emplace`, the trait of that operation will return false.
----------------
ldionne wrote:
```suggestion
// __container_traits is a general purpose utility containing traits describing various containers operations.
// It currently only has one trait: `__emplacement_has_strong_exception_safety_guarantee`, but it's
// intended to be extended in the future.
//
// When a trait is nonsensical for a type, this class still provides a fallback value for that trait.
// For example, `std::array` does not support `insert` or `emplace`, so `__emplacement_has_strong_exception_safety_guarantee` is false for such types.
```
https://github.com/llvm/llvm-project/pull/109578
More information about the libcxx-commits
mailing list