Skip to content

Latest commit

 

History

History
154 lines (122 loc) · 3.87 KB

ios-typedefs.md

File metadata and controls

154 lines (122 loc) · 3.87 KB
title ms.custom ms.date ms.reviewer ms.suite ms.tgt_pltfrm ms.topic f1_keywords ms.assetid caps.latest.revision manager
<ios> typedefs | Microsoft Docs
11/04/2016
article
iosfwd/std::ios
iosfwd/std::streamoff
iosfwd/std::streampos
iosfwd/std::streamsize
iosfwd/std::wios
iosfwd/std::wstreampos
0b962632-3439-44de-bf26-20c67a7f0ff3
13
ghogen

<ios> typedefs

ios streamoff streampos
streamsize wios wstreampos

ios

Supports the ios class from the old iostream library.

typedef basic_ios<char, char_traits<char>> ios;  

Remarks

The type is a synonym for template class basic_ios, specialized for elements of type char with default character traits.

streamoff

Supports internal operations.

#ifdef _WIN64  
    typedef __int64 streamoff;  
#else  
    typedef long streamoff;  
#endif  

Remarks

The type is a signed integer that describes an object that can store a byte offset involved in various stream positioning operations. Its representation has at least 32 value bits. It is not necessarily large enough to represent an arbitrary byte position within a stream. The value streamoff(-1) generally indicates an erroneous offset.

streampos

Holds the current position of the buffer pointer or file pointer.

typedef fpos<mbstate_t> streampos;  

Remarks

The type is a synonym for fpos< mbstate_t>.

Example

// ios_streampos.cpp  
// compile with: /EHsc  
#include <iostream>  
#include <fstream>  
  
int main( )   
{  
   using namespace std;  
  
   ofstream x( "iostream.txt" );  
   x << "testing";  
   streampos y = x.tellp( );  
   cout << y << endl;  
}  
7  

streamsize

Denotes the size of the stream.

#ifdef _WIN64  
    typedef __int64 streamsize;  
#else  
    typedef int streamsize;  
#endif  

Remarks

The type is a signed integer that describes an object that can store a count of the number of elements involved in various stream operations. Its representation has at least 16 bits. It is not necessarily large enough to represent an arbitrary byte position within a stream.

Example

After compiling and running the following program, look at the file test.txt to see the effect of setting streamsize.

// ios_streamsize.cpp  
// compile with: /EHsc  
#include <iostream>  
#include <fstream>  
  
int main( )   
{  
   using namespace std;  
   char a[16] = "any such text";  
   ofstream x( "test.txt" );  
   streamsize y = 6;  
   x.write( a, y );  
}  

wios

Supports the wios class from the old iostream library.

typedef basic_ios<wchar_t, char_traits<wchar_t>> wios;  

Remarks

The type is a synonym for template class basic_ios, specialized for elements of type wchar_t with default character traits.

wstreampos

Holds the current position of the buffer pointer or file pointer.

typedef fpos<mbstate_t> wstreampos;  

Remarks

The type is a synonym for fpos< mbstate_t>.

Example

// ios_wstreampos.cpp  
// compile with: /EHsc  
#include <iostream>  
#include <fstream>  
  
int main( )   
{  
   using namespace std;  
   wofstream xw( "wiostream.txt" );  
   xw << L"testing";  
   wstreampos y = xw.tellp( );  
   cout << y << endl;  
}  
7  

See Also

<ios>