Click on the banner to return to the class reference home page.

char_traits

Summary

A traits class providing types and operations to the basic_string container and iostream classes.

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

Synopsis

#include <string>
template<class charT>
struct char_traits

Description

The template structure char_traits<charT> defines the types and functions necessary to implement the iostreams and string template classes. It is templatized on charT, which represents the character container type. Each specialized version of char_traits<charT> provides the default definitions corresponding to the specialized character container type.

Users have to provide specialization for char_traits if they use other character types than char and wchar_t.

Interface

template<class charT> 
struct char_traits {

  typedef charT                     char_type;
  typedef INT_T                     int_type;
  typedef POS_T                     pos_type;
  typedef OFF_T                     off_type;
  typedef STATE_T                   state_type;

  static char_type        to_char_type(const int_type&); 
  static int_type         to_int_type(const char_type&);
  static bool             eq(const char_type&,const char_type& );
  static bool             eq_int_type(const int_type&,const int_type&);

  static int_type         eof();
  static int_type         not_eof(const int_type&);

  static void             assign(char_type&,const char_type&);
  static bool             lt(const char_type&,const char_type&);
  static int              compare(const char_type*,const char_type*,size_t);
  static size_t           length(const char_type*);
  static const char_type* find(const char_type*,int n,const char_type&);

  static char_type*       move(char_type*,const char_type*,size_t);
  static char_type*       copy(char_type*,const char_type*, size_t);
  static char_type*       assign(char_type*,size_t,const char_type&);

};

Types

char_type
int_type
off_type
pos_type
state_type

Types Default-Values

specialization type
on char
on wchar_t
char_type
char
wchar_t
int_type
int
wint_t
off_type
streamoff
wstreamoff
pos_type
streampos
wstreampos
state_type
mbstate_t
mbstate_t

Value Functions

void 
assign(char_type& c1, const char_type& c2);
char_type*
assign(char_type* s,size_t n,const char_type& a);
char_type* 
copy(char_type* s1, const char_type* s2, size_t n);
int_type 
eof();
const char_type* 
find(const char_type* s, int n, const char_type& a);
size_t 
length(const char_type* s);
char_type* 
move(char_type* s1, const char_type* s2, size_t n);
int_type 
not_eof(const int_type& c);

Test Functions

int 
compare(const char_type* s1,const char_type* s2,size_t n);
bool 
eq(const char_type& c1, const char_type& c2);
bool 
eq_int_type(const int_type& c1, const int_type& c2);
bool 
lt(const char_type& c1,const char_type& c2);

Conversion Functions

char_type 
to_char_type(const int_type& c);
int_type 
to_int_type(const char_type& c);

See Also

iosfwd(3C++), fpos(3C++)

Working Paper for Draft Proposed International Standard for Information Systems--Programming Language C++, Section 21.1.4, 21.1.5, 27.1.2.

Standards Conformance

ANSI X3J16/ISO WG21 Joint C++ Committee


©Copyright 1996, Rogue Wave Software, Inc.