Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | 5b08a8a | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <array> |
| 11 | |
| 12 | // template <class T, size_t N> void swap(array<T,N>& x, array<T,N>& y); |
| 13 | |
| 14 | #include <array> |
| 15 | #include <cassert> |
| 16 | |
| 17 | int main() |
| 18 | { |
| 19 | { |
| 20 | typedef double T; |
| 21 | typedef std::array<T, 3> C; |
| 22 | C c1 = {1, 2, 3.5}; |
| 23 | C c2 = {4, 5, 6.5}; |
| 24 | swap(c1, c2); |
| 25 | assert(c1.size() == 3); |
| 26 | assert(c1[0] == 4); |
| 27 | assert(c1[1] == 5); |
| 28 | assert(c1[2] == 6.5); |
| 29 | assert(c2.size() == 3); |
| 30 | assert(c2[0] == 1); |
| 31 | assert(c2[1] == 2); |
| 32 | assert(c2[2] == 3.5); |
| 33 | } |
| 34 | { |
| 35 | typedef double T; |
| 36 | typedef std::array<T, 0> C; |
| 37 | C c1 = {}; |
| 38 | C c2 = {}; |
| 39 | swap(c1, c2); |
| 40 | assert(c1.size() == 0); |
| 41 | assert(c2.size() == 0); |
| 42 | } |
| 43 | } |