[Gllug] OT(ish): Advice
rich at annexia.org
rich at annexia.org
Wed Dec 11 11:05:12 UTC 2002
On Wed, Dec 11, 2002 at 08:44:11AM +0000, Nix wrote:
> ... and what to do when designing a framework of generic algorithms and
> containers.
>
> Your challenge: rewrite the STL above a language with less expressive
> power (other than Ada, where it's been done, mostly). :)
----------------------------------------------------------------------
#include <vector>
#include <algorithm>
main ()
{
vector<int> v;
v.push_back (10);
vector<int> w;
copy (v.begin (), v.end (), w);
}
----------------------------------------------------------------------
g++ -Wall test.cpp -o test
results:
test.cpp:5: warning: ISO C++ forbids declaration of `main' with no type
/usr/include/g++-3/stl_algobase.h: In function `_OutputIter __copy
(_RandomAccessIter, _RandomAccessIter, _OutputIter,
random_access_iterator_tag, _Distance *) [with _RandomAccessIter = int
*, _OutputIter = vector<int, allocator<int> >, _Distance = ptrdiff_t]':
/usr/include/g++-3/stl_algobase.h:161: instantiated from `__copy_dispatch<_InputIter, _OutputIter, _BoolType>::copy (_InputIter, _InputIter, _OutputIter) [with _InputIter = int *, _OutputIter = vector<int, allocator<int> >, _BoolType = __true_type]'
/usr/include/g++-3/stl_algobase.h:188: instantiated from `copy (_InputIter, _InputIter, _OutputIter) [with _InputIter = int *, _OutputIter = vector<int, allocator<int> >]'
test.cpp:10: instantiated from here
/usr/include/g++-3/stl_algobase.h:139: no match for `*vector<int,
allocator<int> > &'
/usr/include/g++-3/stl_algobase.h:141: no match for `++vector<int,
allocator<int> > &'
Yes, elegant.
Rich.
--
Richard Jones, Red Hat Inc. (London, UK) http://www.redhat.com/software/ccm
http://www.annexia.org/ Freshmeat projects: http://freshmeat.net/users/rwmj
--
Gllug mailing list - Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug
More information about the GLLUG
mailing list