Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Modularize <iterator> #330

Merged
merged 32 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
428d817
Rename internal iterator typetraits to `is_cpp17_meow_iterator`
miscco Dec 13, 2022
e814fde
Update `<iterator>` synopsis
miscco Dec 13, 2022
e055bd2
Move `{c}begin` and `{c}end` into their own file
miscco Dec 13, 2022
03338fd
Move `data`, `empty` and `size` into their own files
miscco Dec 13, 2022
373fe24
Move `__libcpp_erase_if_container` to its own file
miscco Dec 13, 2022
8d0314c
Move `iterator` base class into its own file
miscco Dec 13, 2022
8002699
Move `iterator_traits` into its own file
miscco Dec 13, 2022
d4dc207
Move `advance` into its own file
miscco Dec 13, 2022
1320dfa
Move `distance` into its own file
miscco Dec 13, 2022
3737956
Move `next` into its own file
miscco Dec 13, 2022
41f8104
Move `prev` into its own file
miscco Dec 13, 2022
aefda09
Move `reverse_iterator` into its own file
miscco Dec 13, 2022
68a09a4
Move `pointer_traits` into its own file
miscco Dec 13, 2022
33a6e1d
Move `back_insert_iterator` into its own file
miscco Dec 13, 2022
71b58e6
Move `front_insert_iterator` into its own file
miscco Dec 13, 2022
48e6df7
Move `insert_iterator` into its own file
miscco Dec 13, 2022
716d6cd
Move `istream_iterator` into its own file
miscco Dec 13, 2022
0e62313
Move `ostream_iterator` into its own file
miscco Dec 13, 2022
ecbe87a
Move `istreambuf_iterator` into its own file
miscco Dec 13, 2022
daf2413
Move `ostreambuf_iterator` into its own file
miscco Dec 13, 2022
323fee5
Move `move_iterator` into its own file
miscco Dec 13, 2022
c7aa942
Move `wrap_iter` to its own file
miscco Dec 13, 2022
936fcb0
Move `{c}rbegin` and `{c}rend` to their own file
miscco Dec 13, 2022
7750a61
Move `unary_function` into its own file
miscco Dec 13, 2022
66d6313
Move `binary_function` into its own file
miscco Dec 13, 2022
110bc76
Move `weak_result_type` into its own file
miscco Dec 13, 2022
73d99e0
Move `reference_wrapper` into its own file
miscco Dec 13, 2022
a65f425
Add copyright header to test files
miscco Dec 13, 2022
ce32c26
Make tests pass for nvc++
miscco Dec 13, 2022
697829b
Add new files to CMakeLists.txt
miscco Dec 13, 2022
3e1aed2
Make tests pass with removed negators
miscco Dec 13, 2022
c190127
Rework includes
miscco Dec 16, 2022
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ Output/
compile_commands.json
*~
*lit_test_times.txt
llvm-project/
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++98, c++03, c++11, c++14
// UNSUPPORTED: c++98, c++03, c++11

// <cuda/std/iterator>
// template <class C> constexpr auto data(C& c) -> decltype(c.data()); // C++17
Expand Down Expand Up @@ -70,6 +71,8 @@ void test_const_array( const T (&array)[Sz] )
assert ( cuda::std::data(array) == &array[0]);
}

__device__ static constexpr int arrA [] { 1, 2, 3 };

int main(int, char**)
{
#if defined(_LIBCUDACXX_HAS_VECTOR)
Expand Down Expand Up @@ -98,7 +101,6 @@ int main(int, char**)
#endif
#endif

static constexpr int arrA [] { 1, 2, 3 };
test_const_array ( arrA );

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++98, c++03, c++11, c++14
// UNSUPPORTED: c++98, c++03, c++11

// <cuda/std/iterator>
// template <class C> constexpr auto empty(const C& c) -> decltype(c.empty()); // C++17
Expand Down Expand Up @@ -44,7 +45,7 @@ template<typename T>
__host__ __device__
void test_const_container( const cuda::std::initializer_list<T>& c )
{
assert ( cuda::std::empty(c) == (c.size() == 0));
assert (!cuda::std::empty(c));
}

template<typename C>
Expand All @@ -60,7 +61,7 @@ __host__ __device__
void test_container( cuda::std::initializer_list<T>& c )
{
ASSERT_NOEXCEPT(cuda::std::empty(c));
assert ( cuda::std::empty(c) == (c.size() == 0));
assert (!cuda::std::empty(c));
}

template<typename T, size_t Sz>
Expand All @@ -71,6 +72,8 @@ void test_const_array( const T (&array)[Sz] )
assert (!cuda::std::empty(array));
}

__device__ static constexpr int arrA [] { 1, 2, 3 };

int main(int, char**)
{
#if defined(_LIBCUDACXX_HAS_VECTOR)
Expand Down Expand Up @@ -108,7 +111,6 @@ int main(int, char**)
#endif
#endif

static constexpr int arrA [] { 1, 2, 3 };
test_const_array ( arrA );

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++98, c++03, c++11, c++14
// UNSUPPORTED: c++98, c++03, c++11

// <cuda/std/iterator>
// template <class C> constexpr auto size(const C& c) -> decltype(c.size()); // C++17
Expand Down Expand Up @@ -75,6 +76,8 @@ void test_const_array( const T (&array)[Sz] )
assert ( cuda::std::size(array) == Sz );
}

__device__ static constexpr int arrA [] { 1, 2, 3 };

int main(int, char**)
{
#if defined(_LIBCUDACXX_HAS_VECTOR)
Expand Down Expand Up @@ -111,7 +114,6 @@ int main(int, char**)
#endif
#endif

static constexpr int arrA [] { 1, 2, 3 };
test_const_array ( arrA );

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down Expand Up @@ -36,7 +37,7 @@
struct short_container {
__host__ __device__
uint16_t size() const { return 60000; } // not noexcept
};
};


template<typename C>
Expand Down Expand Up @@ -84,6 +85,8 @@ void test_const_array(const T (&array)[Sz])
assert ( cuda::std::ssize(array) == Sz );
}

__device__ static constexpr int arrA [] { 1, 2, 3 };

int main(int, char**)
{
#if defined(_LIBCUDACXX_HAS_VECTOR)
Expand Down Expand Up @@ -124,7 +127,6 @@ int main(int, char**)
test_const_container ( sv );
#endif

static constexpr int arrA [] { 1, 2, 3 };
ASSERT_SAME_TYPE(ptrdiff_t, decltype(cuda::std::ssize(arrA)));
static_assert( cuda::std::is_signed_v<decltype(cuda::std::ssize(arrA))>, "");
test_const_array ( arrA );
Expand All @@ -142,7 +144,9 @@ int main(int, char**)
static_assert( cuda::std::is_signed_v< decltype(cuda::std::ssize(sc))>, "");
static_assert( cuda::std::numeric_limits< decltype(cuda::std::ssize(sc))>::max() > 60000, "");
static_assert( cuda::std::numeric_limits<cuda::std::make_signed_t<decltype(cuda::std:: size(sc))>>::max() < 60000, "");
#ifdef __CUDA_ARCH__
griwes marked this conversation as resolved.
Show resolved Hide resolved
assert (cuda::std::ssize(sc) == 60000);
#endif
LIBCPP_ASSERT_NOT_NOEXCEPT(cuda::std::ssize(sc));

return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down Expand Up @@ -144,6 +145,11 @@ void test_const_array( const T (&array)[Sz] ) {
#endif
}

__device__ static constexpr int arrA [] { 1, 2, 3 };
#if TEST_STD_VER > 14
__device__ static constexpr const int c[] = {0,1,2,3,4};
#endif

int main(int, char**) {
#if defined(_LIBCUDACXX_HAS_VECTOR)
cuda::std::vector<int> v; v.push_back(1);
Expand Down Expand Up @@ -172,7 +178,6 @@ int main(int, char**) {
test_const_container ( a, 3 );
test_const_container ( il, 4 );

static constexpr int arrA [] { 1, 2, 3 };
test_const_array ( arrA );
#if TEST_STD_VER > 11
constexpr const int *b = cuda::std::cbegin(arrA);
Expand Down Expand Up @@ -210,7 +215,6 @@ int main(int, char**) {
}

{
static constexpr const int c[] = {0,1,2,3,4};

static_assert ( *cuda::std::begin(c) == 0, "" );
static_assert ( *cuda::std::cbegin(c) == 0, "" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// 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
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
//===----------------------------------------------------------------------===//

Expand Down
Loading