brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 3fe50c6 Raw
40 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// <ios>10 11// template <class charT, class traits> class basic_ios12 13// operator unspecified-bool-type() const;14 15#include <ios>16#include <type_traits>17#include <cassert>18 19#include "test_macros.h"20 21int main(int, char**)22{23    std::ios ios(0);24    assert(static_cast<bool>(ios) == !ios.fail());25    ios.setstate(std::ios::failbit);26    assert(static_cast<bool>(ios) == !ios.fail());27    static_assert((!std::is_convertible<std::ios, int>::value), "");28    static_assert((!std::is_convertible<std::ios const&, int>::value), "");29#if TEST_STD_VER >= 1130    static_assert(!std::is_convertible<std::ios, void*>::value, "");31    static_assert(!std::is_convertible<std::ios, bool>::value, "");32#else33    static_assert(std::is_convertible<std::ios, void*>::value, "");34    static_assert(std::is_convertible<std::ios, bool>::value, "");35    (void)(ios == 0);  // SPEC2006 apparently relies on this to compile36#endif37 38  return 0;39}40