Revert r290750 - Fix PR19460 - std::ios is convertible to int.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@290752 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
17
include/ios
17
include/ios
@@ -585,22 +585,9 @@ public:
|
|||||||
typedef typename traits_type::pos_type pos_type;
|
typedef typename traits_type::pos_type pos_type;
|
||||||
typedef typename traits_type::off_type off_type;
|
typedef typename traits_type::off_type off_type;
|
||||||
|
|
||||||
#if defined(_LIBCPP_CXX03_LANG)
|
|
||||||
private:
|
|
||||||
struct __bool_tag {};
|
|
||||||
typedef void (basic_ios::*_BoolType)(__bool_tag) const;
|
|
||||||
void __true_value(__bool_tag) const {}
|
|
||||||
|
|
||||||
public:
|
|
||||||
_LIBCPP_ALWAYS_INLINE
|
_LIBCPP_ALWAYS_INLINE
|
||||||
operator _BoolType() const {
|
_LIBCPP_EXPLICIT
|
||||||
return !fail() ? &basic_ios::__true_value : nullptr;
|
operator bool() const {return !fail();}
|
||||||
}
|
|
||||||
#else
|
|
||||||
_LIBCPP_ALWAYS_INLINE
|
|
||||||
_LIBCPP_EXPLICIT operator bool() const {return !fail();}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_LIBCPP_ALWAYS_INLINE bool operator!() const {return fail();}
|
_LIBCPP_ALWAYS_INLINE bool operator!() const {return fail();}
|
||||||
_LIBCPP_ALWAYS_INLINE iostate rdstate() const {return ios_base::rdstate();}
|
_LIBCPP_ALWAYS_INLINE iostate rdstate() const {return ios_base::rdstate();}
|
||||||
_LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) {ios_base::clear(__state);}
|
_LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) {ios_base::clear(__state);}
|
||||||
|
|||||||
@@ -14,21 +14,12 @@
|
|||||||
// operator unspecified-bool-type() const;
|
// operator unspecified-bool-type() const;
|
||||||
|
|
||||||
#include <ios>
|
#include <ios>
|
||||||
#include <type_traits>
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include "test_macros.h"
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::ios ios(0);
|
std::ios ios(0);
|
||||||
assert(static_cast<bool>(ios) == !ios.fail());
|
assert(static_cast<bool>(ios) == !ios.fail());
|
||||||
ios.setstate(std::ios::failbit);
|
ios.setstate(std::ios::failbit);
|
||||||
assert(static_cast<bool>(ios) == !ios.fail());
|
assert(static_cast<bool>(ios) == !ios.fail());
|
||||||
static_assert((!std::is_convertible<std::ios, void*>::value), "");
|
|
||||||
static_assert((!std::is_convertible<std::ios, int>::value), "");
|
|
||||||
static_assert((!std::is_convertible<std::ios const&, int>::value), "");
|
|
||||||
#if TEST_STD_VER >= 11
|
|
||||||
static_assert((!std::is_convertible<std::ios, bool>::value), "");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user