相关文章
EOF是什么? - 阮一峰的网络日志
http://www.ruanyifeng.com/blog/2011/11/eof.htmlconstant
<cstdio> EOF End-of-File It is a macro definition of type int that expands into(扩展成) a negative integral constant expression (generally, -1). It is used as the value returned by several functions in header <cstdio> to indicate that the End-of-File has been reached or to signal some other failure conditions. It is also used as the value to represent an invalid character. In C++, this macro corresponds to the value of char_traits<char>::eof().class template
<string>
std::char_traits
- C++98
- C++11
templatestruct char_traits;template <> struct char_traits ;template <> struct char_traits ;
Character traits
Character traits classes specify character properties and provide specific semantics for certain operations on characters and sequences of characters.
The standard library includes a standard set of character traits classes that can be instantiated from the char_traitstemplate, and which are used by default both for the objects and for the objects. But any other class that follows the requirements of a character traits class can be used instead. This reference attempts to describe both the definition of the standard char_traits and the requirements for custom character traits classes.
Template parameters
charT
Character type.
The class defines the standard character traits for this character type. This shall be one of the types for which an specialization is provided. Aliased as member type char_traits::char_type.
Template specializations
The char_traits standard template supports to be instantiated with at least the following character types:
- C++98
- C++11
type | Description |
---|---|
char | Basic character set (size of 1 byte) |
wchar_t | Wide character set (same size, signedness, and alignment as another integral type) |
Member types
- C++98
- C++11
member type | description for character traits types | definition | |
---|---|---|---|
char | wchar_t | ||
char_type | The template parameter (charT) | char | wchar_t |
int_type | Integral type that can represent all charT values, as well as | int | wint_t |
off_type | A type that behaves like | streamoff | streamoff |
pos_type | A type that behaves like | streampos | wstreampos |
state_type | Multibyte transformation state type, such as | mbstate_t | mbstate_t |
Member functions
Compare characters for equality ( public static member function )
Compare characters for inequality ( public static member function )
Get length of null-terminated string ( public static member function )
Assign character ( public static member function )
Compare sequences of characters ( public static member function )
Find first occurrence of character ( public static member function )
Move character sequence ( public static member function )
Copy character sequence ( public static member function )
End-of-File character ( public static member function )
Not End-of-File character ( public static member function )
To char type ( public static member function )
To int type ( public static member function )
Compare int_type values ( public static member function )