1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
// SPDX-FileCopyrightText: Bradley M. Bell <bradbell@seanet.com>
// SPDX-FileContributor: 2024 Bradley M. Bell
// ----------------------------------------------------------------------------
/*
{xrst_begin valvector_output.cpp}
Example and Test of Outputting a valvector
##########################################
{xrst_literal
// BEGIN C++
// END C++
}
{xrst_end valvector_output.cpp}
-------------------------------------------------------------------------------
*/
// BEGIN C++
# 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;
}
// END C++
|