vendredi 22 mai 2020

Need to write nested for loop using range based for loop

std::string convertojason( const std::vector< V>& V1)
{
rapidjson::StringBuffer s;
rapidjson::Writer< rapidjson::StringBuffer > writer( s );

writer.StartObject();

writer.Key( "Final" );

writer.StartArray();

for ( size_t j = 0; j < V1.size(); j++ ) {
    writer.StartArray();

    for ( size_t i = 0; i < V1[ j ].size(); i++ )
        writer.Int( V1[ j ][ i ] );
    writer.EndArray();
}
writer.EndArray();
// writer.EndArray();
writer.EndObject();

return ( s.GetString() );
}

i want to replace two for loops i & j with range based for loop keeping in mind that writer.Int() should accept that value.

Aucun commentaire:

Enregistrer un commentaire