This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Series and gcc



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]