[libcxx-commits] [PATCH] D109668: [libc++][test] Fix iterator assertion in span.cons/deduct.pass.cpp
Joe Loser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Sep 13 11:46:12 PDT 2021
jloser updated this revision to Diff 372305.
jloser added a comment.
Include <memory> instead of <__memory/pointer_traits.h> to make modules build happy
Remove cast to size_t
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109668/new/
https://reviews.llvm.org/D109668
Files:
libcxx/test/std/containers/views/span.cons/deduct.pass.cpp
Index: libcxx/test/std/containers/views/span.cons/deduct.pass.cpp
===================================================================
--- libcxx/test/std/containers/views/span.cons/deduct.pass.cpp
+++ libcxx/test/std/containers/views/span.cons/deduct.pass.cpp
@@ -28,60 +28,63 @@
#include <span>
-#include <algorithm>
#include <array>
#include <cassert>
+#include <memory>
#include <string>
-#include <type_traits>
#include "test_macros.h"
-// std::array is explicitly allowed to be initialized with A a = { init-list };.
-// Disable the missing braces warning for this reason.
-#include "disable_missing_braces_warning.h"
-
int main(int, char**)
{
{
int arr[] = {1,2,3};
std::span s{arr};
- using S = decltype(s);
- ASSERT_SAME_TYPE(S, std::span<int, 3>);
- assert((std::equal(std::begin(arr), std::end(arr), s.begin(), s.end())));
+ ASSERT_SAME_TYPE(decltype(s), std::span<int, 3>);
+ assert(std::to_address(s.begin()) == std::begin(arr));
+ assert(std::to_address(s.end()) == std::end(arr));
+ }
+
+ {
+ const int arr[] = {1,2,3};
+ std::span s{arr};
+ ASSERT_SAME_TYPE(decltype(s), std::span<const int, 3>);
+ assert(std::to_address(s.begin()) == std::begin(arr));
+ assert(std::to_address(s.end()) == std::end(arr));
}
{
std::array<double, 4> arr = {1.0, 2.0, 3.0, 4.0};
std::span s{arr};
- using S = decltype(s);
- ASSERT_SAME_TYPE(S, std::span<double, 4>);
- assert((std::equal(std::begin(arr), std::end(arr), s.begin(), s.end())));
+ ASSERT_SAME_TYPE(decltype(s), std::span<double, 4>);
+ assert(std::to_address(s.begin()) == arr.begin());
+ assert(std::to_address(s.end()) == arr.end());
}
{
const std::array<long, 5> arr = {4, 5, 6, 7, 8};
std::span s{arr};
- using S = decltype(s);
- ASSERT_SAME_TYPE(S, std::span<const long, 5>);
- assert((std::equal(std::begin(arr), std::end(arr), s.begin(), s.end())));
+ ASSERT_SAME_TYPE(decltype(s), std::span<const long, 5>);
+ assert(std::to_address(s.begin()) == arr.begin());
+ assert(std::to_address(s.end()) == arr.end());
}
{
std::string str{"ABCDE"};
std::span s{str};
- using S = decltype(s);
- ASSERT_SAME_TYPE(S, std::span<char>);
- assert((size_t)s.size() == str.size());
- assert((std::equal(s.begin(), s.end(), std::begin(s), std::end(s))));
+ ASSERT_SAME_TYPE(decltype(s), std::span<char>);
+ assert(s.size() == str.size());
+ assert(std::to_address(s.begin()) == std::to_address(str.begin()));
+ assert(std::to_address(s.end()) == std::to_address(str.end()));
}
{
const std::string str{"QWERTYUIOP"};
std::span s{str};
- using S = decltype(s);
- ASSERT_SAME_TYPE(S, std::span<const char>);
- assert((size_t)s.size() == str.size());
- assert((std::equal(s.begin(), s.end(), std::begin(s), std::end(s))));
+ ASSERT_SAME_TYPE(decltype(s), std::span<const char>);
+ assert(s.size() == str.size());
+ assert(std::to_address(s.begin()) == std::to_address(str.begin()));
+ assert(std::to_address(s.end()) == std::to_address(str.end()));
}
return 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109668.372305.patch
Type: text/x-patch
Size: 3159 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210913/407e2824/attachment.bin>
More information about the libcxx-commits
mailing list