[memprof] Move YAML traits to MemProf.h (NFC) (#118668)
[llvm-project.git] / libcxx / test / std / utilities / meta / meta.rel / is_nothrow_convertible.pass.cpp
blob935d789332fab93ba94e2096ac69fd14e99a7120
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
10 // <type_traits>
11 // UNSUPPORTED: c++03, c++11, c++14, c++17
13 #include <type_traits>
15 #include "test_macros.h"
17 struct A {};
18 struct B {
19 public:
20 operator A() { return a; } A a;
23 class C { };
24 class D {
25 public:
26 operator C() noexcept { return c; } C c;
29 int main(int, char**) {
30 static_assert((std::is_nothrow_convertible<int, double>::value), "");
31 static_assert(!(std::is_nothrow_convertible<int, char*>::value), "");
33 static_assert(!(std::is_nothrow_convertible<A, B>::value), "");
34 static_assert((std::is_nothrow_convertible<D, C>::value), "");
36 static_assert((std::is_nothrow_convertible_v<int, double>), "");
37 static_assert(!(std::is_nothrow_convertible_v<int, char*>), "");
39 static_assert(!(std::is_nothrow_convertible_v<A, B>), "");
40 static_assert((std::is_nothrow_convertible_v<D, C>), "");
42 static_assert((std::is_nothrow_convertible_v<const void, void>), "");
43 static_assert((std::is_nothrow_convertible_v<volatile void, void>), "");
44 static_assert((std::is_nothrow_convertible_v<void, const void>), "");
45 static_assert((std::is_nothrow_convertible_v<void, volatile void>), "");
47 static_assert(!(std::is_nothrow_convertible_v<int[], double[]>), "");
48 static_assert(!(std::is_nothrow_convertible_v<int[], int[]>), "");
49 static_assert(!(std::is_nothrow_convertible_v<int[10], int[10]>), "");
50 static_assert(!(std::is_nothrow_convertible_v<int[10], double[10]>), "");
51 static_assert(!(std::is_nothrow_convertible_v<int[5], double[10]>), "");
52 static_assert(!(std::is_nothrow_convertible_v<int[10], A[10]>), "");
54 typedef void V();
55 typedef int I();
56 static_assert(!(std::is_nothrow_convertible_v<V, V>), "");
57 static_assert(!(std::is_nothrow_convertible_v<V, I>), "");
59 return 0;