[libcxx-commits] [libcxx] [libc++] implement std::flat_set (PR #125241)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Mar 21 12:21:57 PDT 2025
================
@@ -0,0 +1,156 @@
+// -*- 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___FLAT_SET_RA_ITERATOR_H
+#define _LIBCPP___FLAT_SET_RA_ITERATOR_H
+
+#include <__compare/three_way_comparable.h>
+#include <__config>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <__type_traits/is_constructible.h>
+#include <__utility/move.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+#if _LIBCPP_STD_VER >= 23
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+/**
+ * __ra_iterator is a random access iterator that wraps an underlying iterator.
+ * It also stores the underlying container type in its type so that algorithms
+ * can optimize based on the underlying container type, and to avoid inadvertently
+ * mixing iterators coming from different containers..
+ */
+template <class _Container, class _Iterator>
+struct __ra_iterator {
+private:
+ _Iterator __iter_;
+
+ friend _Container;
+
+ // note: checking the concept random_access_iterator does not work for incomplete types
+ static_assert(__is_same(iterator_traits<_Iterator>::iterator_category, random_access_iterator_tag),
----------------
ldionne wrote:
```suggestion
static_assert(_IsSame<typename iterator_traits<_Iterator>::iterator_category, random_access_iterator_tag>::value,
```
https://github.com/llvm/llvm-project/pull/125241
More information about the libcxx-commits
mailing list