Apache C++ Standard Library Reference Guide

## <string>

Library: Strings

    Header

- Local Index
- Summary
- Synopsis
- See Also
- Standards Conformance

### Local Index

No Entries

### Summary

The header `<string>` represents the Strings library of the Standard C++ Library. It defines the following entities:

- the class template char_traits, and the specializations of char_traits on `char` and `wchar_t`

- the class template basic_string, and the types string and wstring

- a set of relational operators that C++ programs may use to perform equality and inequality tests on specializations of basic_string

- a number of overloads of the function template `operator+()` specialized for basic_string

- a specialization of the `swap()` algorithm for basic_string

- specializations of `operator<<()` and `operator>>()` for basic_string, and two overloads of the function template `getline()` for basic_string

### Synopsis

    namespace std {
      template<class charT>
      struct char_traits;
      template <> struct char_traits<char>;
      template <> struct char_traits<wchar_t>;

      template<class charT, class traits = char_traits<charT>,
               class Allocator = allocator<charT> >
      class basic_string;

      template<class charT, class traits, class Allocator>
      basic_string<charT, traits, Allocator>
      operator+(const basic_string<charT, traits, Allocator>&,
                const basic_string<charT, traits, Allocator>&);

      template<class charT, class traits, class Allocator>
      basic_string<charT, traits, Allocator>
      operator+(const charT*,
                const basic_string<charT, traits, Allocator>&);

      template<class charT, class traits, class Allocator>
      basic_string<charT, traits, Allocator>
      operator+(charT, const basic_string<charT,
                traits, Allocator>&);

      template<class charT, class traits, class Allocator>
      basic_string<charT, traits, Allocator>
      operator+(const basic_string<charT, traits, Allocator>&,
                const charT*);

      template<class charT, class traits, class Allocator>
      basic_string<charT, traits, Allocator>
      operator+(const basic_string<charT, traits,
                Allocator>&, charT);

      template<class charT, class traits, class Allocator>
      bool operator==(const basic_string<charT, traits,
                                         Allocator>&,
                      const basic_string<charT, traits,
                                         Allocator>&);

      template<class charT, class traits, class Allocator>
      bool operator==(const charT*,
                      const basic_string<charT, traits,
                                         Allocator>&);

      template<class charT, class traits, class Allocator>
      bool operator==(const basic_string<charT, traits,
                                         Allocator>&,
                      const charT*);

      template<class charT, class traits, class Allocator>
      bool operator!=(const basic_string<charT, traits,
                                         Allocator>&,
                      const basic_string<charT, traits,
                                         Allocator>&);

      template<class charT, class traits, class Allocator>
      bool operator!=(const charT*, const basic_string<charT,
                      traits, Allocator>&);

      template<class charT, class traits, class Allocator>
      bool operator!=(const basic_string<charT, traits,
                                         Allocator>&,
                      const charT*);

      template<class charT, class traits, class Allocator>
      bool operator<(const basic_string<charT, traits,
                                        Allocator>&,
                     const basic_string<charT, traits,
                                        Allocator>&);

      template<class charT, class traits, class Allocator>
      bool operator<(const basic_string<charT, traits,
                                        Allocator>&,
                      const charT*);

      template<class charT, class traits, class Allocator>
      bool operator<(const charT*,
                     const basic_string<charT, traits,
                                        Allocator>&);

      template<class charT, class traits, class Allocator>
      bool operator>(const basic_string<charT, traits,
                                        Allocator>&,
                     const basic_string<charT, traits,
                                        Allocator>&);

      template<class charT, class traits, class Allocator>
      bool operator>(const basic_string<charT, traits,
                                        Allocator>&,
                     const charT*);

      template<class charT, class traits, class Allocator>
      bool operator>(const charT*,
                     const basic_string<charT, traits,
                                        Allocator>&);

      template<class charT, class traits, class Allocator>
      bool operator<=(const basic_string<charT, traits,
                                         Allocator>&,
                      const basic_string<charT, traits,
                                         Allocator>&);

      template<class charT, class traits, class Allocator>
      bool operator<=(const basic_string<charT, traits,
                                         Allocator>&,
                      const charT*);

      template<class charT, class traits, class Allocator>
      bool operator<=(const charT*,
                      const basic_string<charT, traits,
                                         Allocator>&);

      template<class charT, class traits, class Allocator>
      bool operator>=(const basic_string<charT, traits,
                                         Allocator>&,
                      const basic_string<charT, traits,
                                         Allocator>&);

      template<class charT, class traits, class Allocator>
      bool operator>=(const basic_string<charT, traits,
                                         Allocator>&,
                      const charT*);

      template<class charT, class traits, class Allocator>
      bool operator>=(const charT*,
                     const basic_string<charT, traits,
                                        Allocator>&);

      template<class charT, class traits, class Allocator>
      void swap(basic_string<charT, traits, Allocator>&,
                basic_string<charT, traits, Allocator>&);

      template<class charT, class traits, class Allocator>
      basic_istream<charT, traits>&
      operator>>(basic_istream<charT, traits>&,
                 basic_string<charT, traits, Allocator>& );

      template<class charT, class traits, class Allocator>
      basic_ostream<charT, traits>&
      operator<<(basic_ostream<charT, traits>&,
                 const basic_string<charT, traits, Allocator>&);

      template<class charT, class traits, class Allocator>
      basic_istream<charT, traits>&
      getline(basic_istream<charT, traits>&,
              basic_string<charT, traits, Allocator>&, charT);

      template<class charT, class traits, class Allocator>
      basic_istream<charT, traits>&
      getline(basic_istream<charT, traits>&,
              basic_string<charT, traits, Allocator>&);

      typedef basic_string<char> string;
      typedef basic_string<wchar_t> wstring;
    }

### See Also

Sequences, char_traits, basic_string

### Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems --Programming Language C++, Section 21.2