Subject: Re: [Boost-bugs] [Boost C++ Libraries] #7828: use BOOST_FOREACH push_back some thing into vector, the first value is blank.
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-02-18 00:30:41
#7828: use BOOST_FOREACH push_back some thing into vector,the first value is
blank.
-----------------------------------+----------------------------------------
Reporter: yuanzhan@⦠| Owner: eric_niebler
Type: Bugs | Status: closed
Milestone: To Be Determined | Component: foreach
Version: Boost 1.50.0 | Severity: Problem
Resolution: worksforme | Keywords: BOOST_FOREACH
-----------------------------------+----------------------------------------
Changes (by eric_niebler):
* status: new => closed
* resolution: => worksforme
Comment:
I tested the following code against Boost trunk:
{{{
#include <iostream>
#include <vector>
#include <string>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/foreach.hpp>
int main()
{
std::vector<std::string> ClientSet;
boost::property_tree::ptree pt;
try
{
boost::property_tree::read_xml("C:\\axml.xml",pt);
BOOST_FOREACH(
boost::property_tree::ptree::value_type &v,
pt.get_child("client_set"))
{
ClientSet.push_back(v.second.data());
}
std::cout << "client_set size = " << ClientSet.size() <<
std::endl;
std::cout << "client_set[0] = " << ClientSet[0] << std::endl;
std::cout << "client_set[1] = " << ClientSet[1] << std::endl;
std::cout << "client_set[2] = " << ClientSet[2] << std::endl;
}
catch(std::exception & e)
{ }
}
}}}
I used a data file `C:\axml.xml` that contains this:
{{{
<?xml version="1.0" encoding="UTF-8"?>
<client_set>
<client>00801038</client>
<client>00802980</client>
<client>01600817</client>
</client_set>
}}}
I get this:
{{{
client_set size = 3
client_set[0] = 00801038
client_set[1] = 00802980
client_set[2] = 01600817
}}}
Looks ok to me.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/7828#comment:6> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:12 UTC