Initial commit

This commit is contained in:
Yervant7
2024-01-16 19:28:29 -03:00
commit 8c0524dc0f
9054 changed files with 1081727 additions and 0 deletions
@@ -0,0 +1,48 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
// <functional>
// reference_wrapper
// reference_wrapper(const reference_wrapper<T>& x);
#include <functional>
#include <cassert>
#include "test_macros.h"
class functor1
{
};
template <class T>
void
test(T& t)
{
std::reference_wrapper<T> r(t);
std::reference_wrapper<T> r2 = r;
assert(&r2.get() == &t);
}
void f() {}
int main(int, char**)
{
void (*fp)() = f;
test(fp);
test(f);
functor1 f1;
test(f1);
int i = 0;
test(i);
const int j = 0;
test(j);
return 0;
}
@@ -0,0 +1,44 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17
// <functional>
//
// reference_wrapper<T>
//
// where T is an incomplete type (since C++20)
#include <functional>
#include <cassert>
#include "test_macros.h"
struct Foo;
Foo& get_foo();
void test() {
Foo& foo = get_foo();
std::reference_wrapper<Foo> ref{foo};
assert(&ref.get() == &foo);
}
struct Foo { };
Foo& get_foo() {
static Foo foo;
return foo;
}
int main(int, char**) {
test();
return 0;
}
@@ -0,0 +1,31 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14
// <functional>
// template <class T>
// reference_wrapper(T&) -> reference_wrapper<T>;
#include <functional>
int main(int, char**) {
int i = 0;
std::reference_wrapper ri(i);
static_assert(std::is_same_v<decltype(ri), std::reference_wrapper<int>>);
std::reference_wrapper ri2(ri);
static_assert(std::is_same_v<decltype(ri2), std::reference_wrapper<int>>);
const int j = 0;
std::reference_wrapper rj(j);
static_assert(std::is_same_v<decltype(rj), std::reference_wrapper<const int>>);
std::reference_wrapper rj2(rj);
static_assert(std::is_same_v<decltype(rj2), std::reference_wrapper<const int>>);
return 0;
}
@@ -0,0 +1,76 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
// <functional>
//
// reference_wrapper
//
// template <class U>
// reference_wrapper(U&&) noexcept(see below);
#include <functional>
#include <cassert>
#include "test_macros.h"
struct convertible_to_int_ref {
int val = 0;
operator int&() { return val; }
operator int const&() const { return val; }
};
template <bool IsNothrow>
struct nothrow_convertible {
int val = 0;
operator int&() TEST_NOEXCEPT_COND(IsNothrow) { return val; }
};
struct convertible_from_int {
convertible_from_int(int) {}
};
void meow(std::reference_wrapper<int>) {}
void meow(convertible_from_int) {}
int main(int, char**)
{
{
convertible_to_int_ref t;
std::reference_wrapper<convertible_to_int_ref> r(t);
assert(&r.get() == &t);
}
{
const convertible_to_int_ref t;
std::reference_wrapper<const convertible_to_int_ref> r(t);
assert(&r.get() == &t);
}
{
using Ref = std::reference_wrapper<int>;
ASSERT_NOEXCEPT(Ref(nothrow_convertible<true>()));
ASSERT_NOT_NOEXCEPT(Ref(nothrow_convertible<false>()));
}
{
meow(0);
}
{
extern std::reference_wrapper<int> purr();
ASSERT_SAME_TYPE(decltype(true ? purr() : 0), int);
}
#if TEST_STD_VER > 14
{
int i = 0;
std::reference_wrapper ri(i);
static_assert((std::is_same<decltype(ri), std::reference_wrapper<int>>::value), "" );
const int j = 0;
std::reference_wrapper rj(j);
static_assert((std::is_same<decltype(rj), std::reference_wrapper<const int>>::value), "" );
}
#endif
return 0;
}
@@ -0,0 +1,65 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
// <functional>
//
// reference_wrapper
//
// template <class U>
// reference_wrapper(U&&);
#include <functional>
#include <cassert>
#include "test_macros.h"
struct B {};
struct A1 {
mutable B b_;
TEST_CONSTEXPR operator B&() const { return b_; }
};
struct A2 {
mutable B b_;
TEST_CONSTEXPR operator B&() const TEST_NOEXCEPT { return b_; }
};
void implicitly_convert(std::reference_wrapper<B>) TEST_NOEXCEPT;
TEST_CONSTEXPR_CXX20 bool test()
{
{
A1 a;
ASSERT_NOT_NOEXCEPT(implicitly_convert(a));
std::reference_wrapper<B> b1 = a;
assert(&b1.get() == &a.b_);
ASSERT_NOT_NOEXCEPT(b1 = a);
b1 = a;
assert(&b1.get() == &a.b_);
}
{
A2 a;
ASSERT_NOEXCEPT(implicitly_convert(a));
std::reference_wrapper<B> b2 = a;
assert(&b2.get() == &a.b_);
ASSERT_NOEXCEPT(b2 = a);
b2 = a;
assert(&b2.get() == &a.b_);
}
return true;
}
int main(int, char**) {
test();
#if TEST_STD_VER > 17
static_assert(test());
#endif
return 0;
}
@@ -0,0 +1,23 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
// <functional>
// reference_wrapper
// reference_wrapper(T&&) = delete;
#include <functional>
#include <cassert>
int main(int, char**)
{
std::reference_wrapper<const int> r(3);
return 0;
}
@@ -0,0 +1,64 @@
//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
// <functional>
// reference_wrapper
// reference_wrapper(T& t);
#include <functional>
#include <cassert>
#include <type_traits>
#include "test_macros.h"
class functor1
{
};
template <class T>
void
test(T& t)
{
std::reference_wrapper<T> r(t);
assert(&r.get() == &t);
}
void f() {}
int main(int, char**)
{
void (*fp)() = f;
test(fp);
test(f);
functor1 f1;
test(f1);
int i = 0;
test(i);
const int j = 0;
test(j);
{
using Ref = std::reference_wrapper<int>;
static_assert((std::is_constructible<Ref, int&>::value), "");
static_assert((!std::is_constructible<Ref, int>::value), "");
static_assert((!std::is_constructible<Ref, int&&>::value), "");
}
#if TEST_STD_VER >= 11
{
using Ref = std::reference_wrapper<int>;
static_assert((std::is_nothrow_constructible<Ref, int&>::value), "");
static_assert((!std::is_nothrow_constructible<Ref, int>::value), "");
static_assert((!std::is_nothrow_constructible<Ref, int&&>::value), "");
}
#endif
return 0;
}