Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc++] P2502R2: std::generator #92213

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libcxx/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ set(files
__ranges/data.h
__ranges/drop_view.h
__ranges/drop_while_view.h
__ranges/elements_of.h
__ranges/elements_view.h
__ranges/empty.h
__ranges/empty_view.h
Expand Down Expand Up @@ -950,6 +951,7 @@ set(files
fstream
functional
future
generator
initializer_list
inttypes.h
iomanip
Expand Down
55 changes: 55 additions & 0 deletions libcxx/include/__ranges/elements_of.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review note, elements_of is #91414.

//
// 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___RANGES_ELEMENTS_OF_H
#define _LIBCPP___RANGES_ELEMENTS_OF_H

#include <__config>
#include <__memory/allocator.h>
#include <__ranges/concepts.h>
#include <__utility/move.h>
#include <cstddef>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif

_LIBCPP_PUSH_MACROS
#include <__undef_macros>

_LIBCPP_BEGIN_NAMESPACE_STD

#if _LIBCPP_STD_VER >= 23

namespace ranges {

template <range _Range, class _Allocator = allocator<byte>>
struct elements_of {
_LIBCPP_NO_UNIQUE_ADDRESS _Range range;
_LIBCPP_NO_UNIQUE_ADDRESS _Allocator allocator;

// This explicit constructor is required because AppleClang 15 hasn't implement P0960R3
xiaoyang-sde marked this conversation as resolved.
Show resolved Hide resolved
_LIBCPP_HIDE_FROM_ABI explicit constexpr elements_of(_Range __range, _Allocator __alloc = _Allocator())
: range(std::move(__range)), allocator(std::move(__alloc)) {}
};

template <class _Range, class _Allocator = allocator<byte>>
// This explicit constraint is required because AppleClang 15 might not deduce the correct type for `_Range` without it
xiaoyang-sde marked this conversation as resolved.
Show resolved Hide resolved
requires range<_Range&&>
elements_of(_Range&&, _Allocator = _Allocator()) -> elements_of<_Range&&, _Allocator>;

} // namespace ranges

#endif // _LIBCPP_STD_VER >= 23

_LIBCPP_END_NAMESPACE_STD

_LIBCPP_POP_MACROS

#endif // _LIBCPP___RANGES_ELEMENTS_OF_H
1 change: 1 addition & 0 deletions libcxx/include/__std_clang_module
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
#if !defined(_LIBCPP_HAS_NO_THREADS)
# include <future>
#endif
#include <generator>
#include <initializer_list>
#include <inttypes.h>
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
Expand Down
Loading
Loading