Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
IOstream Library
manipulators
classes:
filebuf
fstream
ifstream
ios
iostream
ios_base
istream
istringstream
ofstream
ostream
ostringstream
streambuf
stringbuf
stringstream
objects:
cerr
cin
clog
cout
types:
fpos
streamoff
streampos
streamsize
ios
ios::ios
ios::~ios
member functions:
ios::bad
ios::clear
ios::copyfmt
ios::eof
ios::exceptions
ios::fail
ios::fill
ios::good
ios::imbue
ios::init
ios::narrow
ios::operator!
ios::operator void*
ios::rdbuf
ios::rdstate
ios::setstate
ios::tie
ios::widen


ios::operator void*

public member function
operator void * ( ) const;

Convert to pointer

A stream object derived from ios can be casted to a pointer. This pointer is a null pointer if either one of the error flags (failbit or badbit) is set, otherwise it is a non-zero pointer.

The pointer returned is not intended to be referenced, it just indicates success when none of the error flags are set.

Parameters

none

Return Value

null pointer if either failbit or badbit is set.
A non-null pointer otherwise.

Example

1
2
3
4
5
6
7
8
9
10
11
12
// ios, casting to pointer
#include <iostream>
#include <fstream>
using namespace std;
int main () {
  ifstream is;
  is.open ("test.txt");
  if ( (void*)is == 0)
    cerr << "Error opening 'test.txt'\n";
  return 0;
}


Basic template member declaration

( basic_ios<charT,traits> )
 
operator void * () const;


See also