brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · ea258de Raw
71 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++0310 11// <tuple>12 13// inline constexpr ignore-type ignore;14 15#include <cassert>16#include <cstdint>17#include <tuple>18#include <type_traits>19 20#include "test_macros.h"21 22static_assert(std::is_trivially_copyable<decltype(std::ignore)>::value, "");23static_assert(std::is_trivially_default_constructible<decltype(std::ignore)>::value, "");24 25#if TEST_STD_VER >= 1726[[nodiscard]] constexpr int test_nodiscard() { return 8294; }27#endif28 29TEST_CONSTEXPR_CXX14 bool test() {30  { [[maybe_unused]] auto& ignore_v = std::ignore; }31 32  { // Test that std::ignore provides converting assignment.33    auto& res = (std::ignore = 42);34    static_assert(noexcept(res = (std::ignore = 42)), "Must be noexcept");35    assert(&res == &std::ignore);36  }37  { // Test bit-field binding.38    struct S {39      unsigned int bf : 3;40    };41    S s{0b010};42    auto& res = (std::ignore = s.bf);43    assert(&res == &std::ignore);44  }45  { // Test that std::ignore provides copy/move constructors46    auto copy                   = std::ignore;47    [[maybe_unused]] auto moved = std::move(copy);48  }49  { // Test that std::ignore provides copy/move assignment50    auto copy  = std::ignore;51    copy       = std::ignore;52    auto moved = std::ignore;53    moved      = std::move(copy);54  }55 56#if TEST_STD_VER >= 1757  { std::ignore = test_nodiscard(); }58#endif59 60  return true;61}62 63int main(int, char**) {64  test();65#if TEST_STD_VER >= 1466  static_assert(test(), "");67#endif68 69  return 0;70}71