Re: [boost] [algorithm] About the documentation of boost::algorithm::string.

Pavol, Here is an example of what we observed. This program compiles and runs without error. The point here is that, if the behaviour is as described in the documentation, then we would expect the last assert to fail, but is succeeds. #include <vector> #include <string> #include <iostream> #include <cassert> #include <boost/algorithm/string.hpp> int main() { std::string test_string("a,b,c,d,e"); std::vector<std::string> test_vector; test_vector.push_back("X"); assert( test_vector.size() == 1 ); boost::algorithm::split(test_vector,test_string,boost::algorithm::is_any_of(",")); assert( test_vector.size() == 5 ); } regards, Matthew Henderson On Tue, Jan 17, 2006 at 12:04:09PM +0000, Matthew Henderson wrote:
There are two minor problems with the documentation which I have noticed.
1. Undocumented headers. boost/algorithm/string/config.hpp boost/algorithm/string/iter_find.hpp
2. The statement "Each part is copied and added as a new element to the output container." which appears both in the documentation of boost/algorithm/string /split.hpp and in comments of that header file is not an accurate description of what actually happens. Some testing by myself suggests that, in fact, the contents of the original container are overwritten.
This is definitely not what the split is supposed to do. Could you please send some examples proving your claim. Algorithms in split.hpp does not contain any mutating code that I'm aware of. Regards, Pavol

Hi, Please see to documentation for the split() http://www.boost.org/doc/html/id2580251.html There is explicit notice: "Notes: Prior content of the result will be overwritten." So I think, that the documentation is correct. Best regards, Pavol On Wed, Jan 25, 2006 at 11:26:11AM +0000, Matthew Henderson wrote:
Pavol,
Here is an example of what we observed. This program compiles and runs without error. The point here is that, if the behaviour is as described in the documentation, then we would expect the last assert to fail, but is succeeds.
#include <vector> #include <string> #include <iostream> #include <cassert> #include <boost/algorithm/string.hpp>
int main() { std::string test_string("a,b,c,d,e"); std::vector<std::string> test_vector; test_vector.push_back("X"); assert( test_vector.size() == 1 ); boost::algorithm::split(test_vector,test_string,boost::algorithm::is_any_of(",")); assert( test_vector.size() == 5 ); }
regards, Matthew Henderson
On Tue, Jan 17, 2006 at 12:04:09PM +0000, Matthew Henderson wrote:
There are two minor problems with the documentation which I have noticed.
1. Undocumented headers. boost/algorithm/string/config.hpp boost/algorithm/string/iter_find.hpp
2. The statement "Each part is copied and added as a new element to the output container." which appears both in the documentation of boost/algorithm/string /split.hpp and in comments of that header file is not an accurate description of what actually happens. Some testing by myself suggests that, in fact, the contents of the original container are overwritten.
This is definitely not what the split is supposed to do. Could you please send some examples proving your claim. Algorithms in split.hpp does not contain any mutating code that I'm aware of.
Regards,
Pavol _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Pavol, Nevertheless, in several places the statement that the elements are added to the vector is used without the comment that the vector is overwritten. It seems likely that this could cause some confusion. Also, originally you said that the algorithm shouldn't have this behaviour. So is it now that the documentation is correct and the implementation wrong? regards, Matthew Henderson On Wed, Jan 25, 2006 at 01:16:02PM +0100, Pavol Droba wrote:
Hi,
Please see to documentation for the split() http://www.boost.org/doc/html/id2580251.html
There is explicit notice:
"Notes: Prior content of the result will be overwritten."
So I think, that the documentation is correct.
Best regards, Pavol
On Wed, Jan 25, 2006 at 11:26:11AM +0000, Matthew Henderson wrote:
Pavol,
Here is an example of what we observed. This program compiles and runs without error. The point here is that, if the behaviour is as described in the documentation, then we would expect the last assert to fail, but is succeeds.
#include <vector> #include <string> #include <iostream> #include <cassert> #include <boost/algorithm/string.hpp>
int main() { std::string test_string("a,b,c,d,e"); std::vector<std::string> test_vector; test_vector.push_back("X"); assert( test_vector.size() == 1 ); boost::algorithm::split(test_vector,test_string,boost::algorithm::is_any_of(",")); assert( test_vector.size() == 5 ); }
regards, Matthew Henderson
On Tue, Jan 17, 2006 at 12:04:09PM +0000, Matthew Henderson wrote:
There are two minor problems with the documentation which I have noticed.
1. Undocumented headers. boost/algorithm/string/config.hpp boost/algorithm/string/iter_find.hpp
2. The statement "Each part is copied and added as a new element to the output container." which appears both in the documentation of boost/algorithm/string /split.hpp and in comments of that header file is not an accurate description of what actually happens. Some testing by myself suggests that, in fact, the contents of the original container are overwritten.
This is definitely not what the split is supposed to do. Could you please send some examples proving your claim. Algorithms in split.hpp does not contain any mutating code that I'm aware of.
Regards,
Pavol _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Hi, I have misunderstood your comment. It is very natural, that the result vector is altered. However, from your comment I thought that you mean that input container is changed. The statement in the documentation is suposed to described the behaviour of the algorithm. And indeed, during the process, the elements are added to the container. I will try to review the docs once more and add the clarification if it is missing. Regards, Pavol. On Wed, Jan 25, 2006 at 06:05:45PM +0000, Matthew Henderson wrote:
Pavol,
Nevertheless, in several places the statement that the elements are added to the vector is used without the comment that the vector is overwritten. It seems likely that this could cause some confusion.
Also, originally you said that the algorithm shouldn't have this behaviour. So is it now that the documentation is correct and the implementation wrong?
regards, Matthew Henderson
On Wed, Jan 25, 2006 at 01:16:02PM +0100, Pavol Droba wrote:
Hi,
Please see to documentation for the split() http://www.boost.org/doc/html/id2580251.html
There is explicit notice:
"Notes: Prior content of the result will be overwritten."
So I think, that the documentation is correct.
Best regards, Pavol
On Wed, Jan 25, 2006 at 11:26:11AM +0000, Matthew Henderson wrote:
Pavol,
Here is an example of what we observed. This program compiles and runs without error. The point here is that, if the behaviour is as described in the documentation, then we would expect the last assert to fail, but is succeeds.
#include <vector> #include <string> #include <iostream> #include <cassert> #include <boost/algorithm/string.hpp>
int main() { std::string test_string("a,b,c,d,e"); std::vector<std::string> test_vector; test_vector.push_back("X"); assert( test_vector.size() == 1 ); boost::algorithm::split(test_vector,test_string,boost::algorithm::is_any_of(",")); assert( test_vector.size() == 5 ); }
regards, Matthew Henderson
On Tue, Jan 17, 2006 at 12:04:09PM +0000, Matthew Henderson wrote:
There are two minor problems with the documentation which I have noticed.
1. Undocumented headers. boost/algorithm/string/config.hpp boost/algorithm/string/iter_find.hpp
2. The statement "Each part is copied and added as a new element to the output container." which appears both in the documentation of boost/algorithm/string /split.hpp and in comments of that header file is not an accurate description of what actually happens. Some testing by myself suggests that, in fact, the contents of the original container are overwritten.
This is definitely not what the split is supposed to do. Could you please send some examples proving your claim. Algorithms in split.hpp does not contain any mutating code that I'm aware of.
Regards,
Pavol _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (2)
-
Matthew Henderson
-
Pavol Droba