Warning: This file is not a C or C++ file. It does not have highlighting.
| 1 | // -*- C++ -*- |
|---|---|
| 2 | //===----------------------------------------------------------------------===// |
| 3 | // |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | // See https://llvm.org/LICENSE.txt for license information. |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP___TYPE_TRAITS_CONTAINER_TRAITS_H |
| 11 | #define _LIBCPP___TYPE_TRAITS_CONTAINER_TRAITS_H |
| 12 | |
| 13 | #include <__config> |
| 14 | |
| 15 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 16 | # pragma GCC system_header |
| 17 | #endif |
| 18 | |
| 19 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 20 | |
| 21 | // // __container_traits is a general purpose utility containing traits describing various containers operations. |
| 22 | // It currently only has one trait: `__emplacement_has_strong_exception_safety_guarantee`, but it's |
| 23 | // intended to be extended in the future. |
| 24 | // |
| 25 | // These traits should only be used for optimization or QoI purposes. In particular, since this is a libc++ internal |
| 26 | // mechanism, no user-defined containers should be expected to specialize these traits (in fact it would be illegal for |
| 27 | // them to do so). Hence, when using these traits to implement something, make sure that a container that fails to |
| 28 | // specialize these traits does not result in non-conforming code. |
| 29 | // |
| 30 | // When a trait is nonsensical for a type, this class still provides a fallback value for that trait. |
| 31 | // For example, `std::array` does not support `insert` or `emplace`, so |
| 32 | // `__emplacement_has_strong_exception_safety_guarantee` is false for such types. |
| 33 | template <class _Container> |
| 34 | struct __container_traits { |
| 35 | // A trait that tells whether a single element insertion/emplacement via member function |
| 36 | // `insert(...)` or `emplace(...)` has strong exception guarantee, that is, if the function |
| 37 | // exits via an exception, the original container is unaffected |
| 38 | static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = false; |
| 39 | |
| 40 | // A trait that tells whether a container supports `reserve(n)` member function. |
| 41 | static _LIBCPP_CONSTEXPR const bool __reservable = false; |
| 42 | }; |
| 43 | |
| 44 | _LIBCPP_END_NAMESPACE_STD |
| 45 | |
| 46 | #endif // _LIBCPP___TYPE_TRAITS_CONTAINER_TRAITS_H |
| 47 |
Warning: This file is not a C or C++ file. It does not have highlighting.
