std::cout << rpnList;The text member function was moved from the RPN List class source file to the Tester class source file (the only current caller) and renamed to the put operator (operator<<). The return value and first argument was changed to an output stream reference. A second argument was added for a constant reference to the RPN list instance. Normally these put stream operator function are made friend functions of the class so that private members can be accessed, but the RPN List class already provides the necessary access functions.
A few changes made to the new. The output stream argument is used to output to instead of the local string stream variable, which was removed. The local index variable (used to create an RPN item pointer to index map) is used to detect the first item in the list instead of the number of characters written to the output stream. And the output stream argument is returned instead of the contents of the local string stream.
If there is a future need for this operator beyond the Tester class, the function can be moved and a function prototype provided in a header file. If this future need is for a string, the string can be obtained by using an output string stream and getting its string:
std::ostringstream oss;[branch stl commit 365d20b2b]
oss << rpnList;
std::string string = oss.str();
No comments:
Post a Comment
All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)