Skip to content

Instantly share code, notes, and snippets.

@yifu
Created September 21, 2012 15:08
Show Gist options
  • Select an option

  • Save yifu/3762058 to your computer and use it in GitHub Desktop.

Select an option

Save yifu/3762058 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
// ---------------------------------------------------------------------------
std::ostream& operator << ( std::ostream& os, const std::vector<char>& vec )
{
for( std::vector<char>::const_iterator it = vec.begin(); it != vec.end(); ++it )
{
os << *it << " ";
}
return os;
}
template < typename T >
std::string StringFrom( const T& t )
{
std::ostringstream oss;
oss << t;
return oss.str();
}
int main()
{
std::cout << "Hello world" << std::endl;
std::vector < char > test;
test.push_back( 'a' );
test.push_back( 'b' );
std::cout << test << std::endl;
std::string result = StringFrom( test );
std::cout << "re " << result << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment