
christopher diggins wrote:
----- Original Message ----- From: "Jonathan Turkanis" <technews@kangaroologic.com> To: <boost@lists.boost.org> Sent: Tuesday, January 11, 2005 10:56 PM Subject: [boost] Re: Re: Re: Re: Re: Functions as Filters (was Program Reuse...)
Hi Christopher,
I think I haven't made my main point clear, so let me try to rephrase it.
Hi Jonathan,
I am pretty sure I understand you. Before I continue, I first want to know one thing, do you (or anyone else) see any value of being able to write C++ code like the following?
#include <iostream> #include <fstream> #include "fxn_filters.hpp"
using namespace std;
void ToUpper() { char c; while (cin.get(c)) cout.put(c); }
I don't see why this is better than struct toupper_filter : input_filter { template<typename Source> int get(Source& src) { return toupper(boost::io::get(src)); } }; and its cousins.
int main() { fstream("input.txt") > Filter(ToUpper); }
This won't work, since fstream("input.txt") produces a temporary object which cannot be used to initialize a non-const reference. Therefore operator< would have to be declared to take a const reference, and the non-const extraction functions would not be usable. I have to go no, but I'll continue this discussion later.
Christopher Diggins http://www.cdiggins.com
Jonathan