Series and gcc

Joe Buck jbuck@synopsys.COM
Fri Feb 23 15:07:00 GMT 2001


> 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.



More information about the Gcc mailing list