xref: /llvm-project/clang/test/SemaCXX/dependent-noexcept-unevaluated.cpp (revision 0b3a46247edbb6a058288234fb105f3607262603)
19ca5c425SRichard Smith // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s
2414e3e3cSAlexis Hunt 
3414e3e3cSAlexis Hunt template <class T>
4414e3e3cSAlexis Hunt T&&
5414e3e3cSAlexis Hunt declval() noexcept;
6414e3e3cSAlexis Hunt 
7414e3e3cSAlexis Hunt template <class T>
8414e3e3cSAlexis Hunt struct some_trait
9414e3e3cSAlexis Hunt {
10414e3e3cSAlexis Hunt     static const bool value = false;
11414e3e3cSAlexis Hunt };
12414e3e3cSAlexis Hunt 
13414e3e3cSAlexis Hunt template <class T>
swap(T & x,T & y)14414e3e3cSAlexis Hunt void swap(T& x, T& y) noexcept(some_trait<T>::value)
15414e3e3cSAlexis Hunt {
16414e3e3cSAlexis Hunt     T tmp(static_cast<T&&>(x));
17414e3e3cSAlexis Hunt     x = static_cast<T&&>(y);
18414e3e3cSAlexis Hunt     y = static_cast<T&&>(tmp);
19414e3e3cSAlexis Hunt }
20414e3e3cSAlexis Hunt 
21414e3e3cSAlexis Hunt template <class T, unsigned N>
22414e3e3cSAlexis Hunt struct array
23414e3e3cSAlexis Hunt {
24414e3e3cSAlexis Hunt     T data[N];
25414e3e3cSAlexis Hunt 
26*0b3a4624SRichard Smith   void swap(array& a) noexcept(noexcept(::swap(declval<T&>(), declval<T&>())));
27414e3e3cSAlexis Hunt };
28414e3e3cSAlexis Hunt 
29414e3e3cSAlexis Hunt struct DefaultOnly
30414e3e3cSAlexis Hunt {
31414e3e3cSAlexis Hunt     DefaultOnly() = default;
32414e3e3cSAlexis Hunt     DefaultOnly(const DefaultOnly&) = delete;
33414e3e3cSAlexis Hunt     DefaultOnly& operator=(const DefaultOnly&) = delete;
34414e3e3cSAlexis Hunt     ~DefaultOnly() = default;
35414e3e3cSAlexis Hunt };
36414e3e3cSAlexis Hunt 
main()37414e3e3cSAlexis Hunt int main()
38414e3e3cSAlexis Hunt {
39414e3e3cSAlexis Hunt     array<DefaultOnly, 1> a, b;
40414e3e3cSAlexis Hunt }
41*0b3a4624SRichard Smith 
42