共用方式為


<sstream>

Defines several template classes that support iostreams operations on sequences stored in an allocated array object. Such sequences are easily converted to and from objects of template class basic_string.

For a list of all members of this header, see <sstream> Members.

namespace std {
template<class CharType,
    class Traits = char_traits<CharType>,
    class Allocator = allocator<CharType> >
    class basic_stringbuf;
typedef basic_stringbuf<char> stringbuf;
typedef basic_stringbuf<wchar_t> wstringbuf;

template<class CharType,
    class Traits = char_traits<CharType>,
    class Allocator = allocator<CharType> >
    class basic_istringstream;
typedef basic_istringstream<char> istringstream;
typedef basic_istringstream<wchar_t> wistringstream;

template<class CharType,
    class Traits = char_traits<CharType>,
    class Allocator = allocator<CharType> >
    class basic_ostringstream;
typedef basic_ostringstream<char> ostringstream;
typedef basic_ostringstream<wchar_t> wostringstream;

template<class CharType,
    class Traits = char_traits<CharType>,
    class Allocator = allocator<CharType> >
    class basic_stringstream;
typedef basic_stringstream<char> stringstream;
typedef basic_stringstream<wchar_t> wstringstream;

        // TEMPLATE FUNCTIONS
template<class CharType, class Traits, class Allocator>
    void swap(
        basic_stringbuf<CharType, Traits, Allocator>& _Left,
        basic_stringbuf<CharType, Traits, Allocator>& _Right
    ); 
template<class CharType, class Traits, class Allocator>
    void swap(
        basic_istringstream<CharType, Traits, Allocator>& _Left,
        basic_istringstream<CharType, Traits, Allocator>& _Right
    );
template<class CharType, class Traits, class Allocator>
    void swap(
        basic_ostringstream<CharType, Traits, Allocator>& _Left,
        basic_ostringstream<CharType, Traits, Allocator>& _Right
    );
template<class CharType, class Traits, class Allocator>
    void swap (
        basic_stringstream<CharType, Traits, Allocator>& _Left,
        basic_stringstream<CharType, Traits, Allocator>& _Right
    );
}  // namespace std

Parameters

Parameter

Description

_Left

Reference to an sstream object.

_Right

Reference to an sstream object.

Remarks

Objects of type char * can use the functionality in <strstream> for streaming. However, <strstream> is deprecated and the use of <sstream> is encouraged.

Requirements

  • Header: <sstream>

  • Namespace: std

See Also

Reference

Thread Safety in the Standard C++ Library

iostream Programming

iostreams Conventions

Other Resources

<sstream> Members

Header Files