brintos

brintos / llvm-project-archived public Read only

0
0
Text · 938 B · 0abed99 Raw
41 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++1410 11// <any>12 13// void swap(any &, any &) noexcept14 15// swap(...) just wraps any::swap(...). That function is tested elsewhere.16 17#include <any>18#include <cassert>19 20#include "test_macros.h"21 22int main(int, char**)23{24 25    { // test noexcept26        std::any a;27        static_assert(noexcept(swap(a, a)), "swap(any&, any&) must be noexcept");28    }29    {30        std::any a1 = 1;31        std::any a2 = 2;32 33        swap(a1, a2);34 35        assert(std::any_cast<int>(a1) == 2);36        assert(std::any_cast<int>(a2) == 1);37    }38 39  return 0;40}41