Documentation error?

I was looking in the Boost Assignment library and I noticed this code under the "Function operator+=()" heading: [CODE] #include <boost/assign/std/vector.hpp> // for 'operator+=()' #include <boost/assert.hpp>; using namespace std; using namespace boost::assign; // bring 'operator+=()' into scope { vector<int> values; values += 1,2,3,4,5,6,7,8,9; // insert values at the end of the container BOOST_ASSERT( values.size() == 9 ); BOOST_ASSERT( values[0] == 1 ); BOOST_ASSERT( values[9] == 9 ); } [CODE] Shouldn't the last assertion be BOOST_ASSERT(values[8]==9)? Unless my brain is tricking me, the last element in the container should be at the 8th slot. -- ------------------------------------------- Dan Day http://razzerblog.blogspot.com

On Fri, 27 May 2005 22:26:55 -0500, Raz wrote
I was looking in the Boost Assignment library and I noticed this code under the "Function operator+=()" heading:
[CODE] #include <boost/assign/std/vector.hpp> // for 'operator+=()' #include <boost/assert.hpp>; using namespace std; using namespace boost::assign; // bring 'operator+=()' into scope
{ vector<int> values; values += 1,2,3,4,5,6,7,8,9; // insert values at the end of the container BOOST_ASSERT( values.size() == 9 ); BOOST_ASSERT( values[0] == 1 ); BOOST_ASSERT( values[9] == 9 ); } [CODE]
Shouldn't the last assertion be BOOST_ASSERT(values[8]==9)? Unless my brain is tricking me, the last element in the container should be at the 8th slot.
It's helpful to add the library name to these kind of posts so the appropriate library maintainer will see them. Jeff

"Jeff Garland" <jeff@crystalclearsoftware.com> wrote in message news:20050528140533.M68667@crystalclearsoftware.com... | On Fri, 27 May 2005 22:26:55 -0500, Raz wrote | > BOOST_ASSERT( values[9] == 9 ); | > } | > [CODE] | > | > Shouldn't the last assertion be BOOST_ASSERT(values[8]==9)? Unless my | > brain is tricking me, the last element in the container should be at | > the 8th slot. yes. It's already fixed in the cvs version. Thanks anyway. | It's helpful to add the library name to these kind of posts so the appropriate | library maintainer will see them. oh yeah, I almost missed this one. -Thorsten
participants (3)
-
Jeff Garland
-
Raz
-
Thorsten Ottosen