This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Apr 1st, 2011  |  syntax: C++  |  size: 0.73 KB  |  views: 51  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. template<typename C>
  2. void test_custom(string const& s, C& ret) {
  3.   C output;
  4.  
  5.   typedef string::const_iterator iter;
  6.   iter beg;
  7.   bool in_token = false;
  8.   for( string::const_iterator it = s.begin(), end = s.end();
  9.     it != end; ++it )
  10.   {
  11.     void* t = strpbrk(&*it, "[],-'/\\!\"ยง$%&=()<>?");
  12.     if ( t != NULL )
  13.     {
  14.       if( in_token )
  15.       {
  16.         output.push_back(typename C::value_type(beg, it));
  17.         in_token = false;
  18.       }
  19.     }
  20.     else if( !in_token )
  21.     {
  22.       beg = it;
  23.       in_token = true;
  24.     }
  25.   }
  26.   if( in_token )
  27.     output.push_back(typename C::value_type(beg, s.end()));
  28.   ret.swap(output);
  29. }
  30.  
  31. // in this state only parts of the strings are spliced up. What can I do to fix it?
clone this paste RAW Paste Data