valvector_output.cpp

View page source

Example and Test of Outputting a valvector

# include <sstream>
# include <string>
# include <cppad/example/valvector/class.hpp>
//
bool output(void)
{  //
   // ok
   bool ok = true;
   //
   // x
   valvector x( {4, 6, 8} );
   //
   // s
   std::stringstream ss;
   ss << x;
   std::string s = ss.str();
   //
   // q
   std::string q;
   for(auto itr = s.begin(); itr != s.end(); ++itr)
      if( *itr != ' ')
         q.push_back( *itr ); 
   // 
   ok &= q == "{4,6,8}";
   //
   return ok;
}