\(\newcommand{\W}[1]{ \; #1 \; }\) \(\newcommand{\R}[1]{ {\rm #1} }\) \(\newcommand{\B}[1]{ {\bf #1} }\) \(\newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} }\) \(\newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} }\) \(\newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} }\) \(\newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }\)
valvector_output.cpp¶
View page sourceExample 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;
}