-// Copyright (C) 2019-2021 Free Software Foundation, Inc.
+// Copyright (C) 2019-2023 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// { dg-do run { target c++2a } }
#include <ranges>
+#include <utility> // as_const
#include <testsuite_hooks.h>
void
std::as_const(s).data();
}
+void
+test05()
+{
+ int i = 0;
+ static_assert(noexcept(std::ranges::single_view<int>()));
+ static_assert(noexcept(std::ranges::single_view<int>(i)));
+ static_assert(noexcept(std::ranges::single_view<int>(1)));
+ static_assert(noexcept(std::ranges::single_view<int>(std::in_place, 2)));
+ static_assert(noexcept(std::ranges::views::single(i)));
+ auto s = std::ranges::views::single(i);
+ static_assert(noexcept(s.begin()));
+ static_assert(noexcept(s.end()));
+ static_assert(noexcept(s.size()));
+ static_assert(noexcept(s.data()));
+ static_assert(noexcept(s.empty())); // view_interface::empty()
+ const auto cs = s;
+ static_assert(noexcept(cs.begin()));
+ static_assert(noexcept(cs.end()));
+ static_assert(noexcept(cs.size()));
+ static_assert(noexcept(cs.data()));
+ static_assert(noexcept(cs.empty())); // view_interface::empty()
+}
+
+void
+test06()
+{
+ // PR libstdc++/100475 comment #7
+ struct S {
+ S() = default;
+ S(std::initializer_list<S>) = delete;
+ S(const S&) {}
+ };
+ S obj;
+ auto x = std::views::single(obj);
+ auto y = std::views::single(std::move(obj));
+}
+
int main()
{
test01();
test02();
test03();
test04();
+ test05();
+ test06();
}