This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Series and gcc
- To: perlman at merl dot com (Barry Perlman)
- Subject: Re: Series and gcc
- From: Joe Buck <jbuck at synopsys dot COM>
- Date: Fri, 23 Feb 2001 15:07:03 -0800 (PST)
- Cc: gcc at gcc dot gnu dot org, imarkov at umich dot edu (Igor Markov), perlman at merl dot com (Barry Perlman)
> Comparison with the STL is natural, but there are some significant
> differences. The STL provides aggregate functions ( transform(),
> for_each() ) that hide loops, but they require the existence of
> containers of data.
Not true. transform() and for_each() only require iterators, not
containers. Consider
int main(int argc, char** argv)
{
transform(istream_iterator<int>(cin),
istream_iterator<int>(),
ostream_iterator<int>(cout, "\n"),
functional);
}
> Series operate on aggregate data, but require no memory for the data.
> Instead, each data element is calculated on an as-needed basis.
This can be done in the STL framework as well, by defining iterators
that generate data on an as-needed basis.
You don't need to change the compiler to do what you want to do. All
you need to do is to learn to understand generic programming concepts
more thoroughly.
All of your examples can be implemented in the STL framework with very
similar-looking code. You don't need any compiler changes. Just create
an iterator that generates consecutive integers.