[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Toon-members] Re: STL containers with TooN
From: |
Gerhard Reitmayr |
Subject: |
Re: [Toon-members] Re: STL containers with TooN |
Date: |
Tue, 12 Jan 2010 14:24:59 +0100 |
Hi,
On 11 Jan 2010, at 22:05, Gabriel Nützi wrote:
> This code works:
>
> list<Vector<Dynamic,double> > la;
> la.push_back(makeVector(3,1,2,3,4));
> la.push_back(makeVector(3,1,3,4));
> la.push_back(makeVector(4,2,1,2,3,4));
> la.push_back(makeVector(4,3,4));
> la.push_back(makeVector(4,2,1,2,3,4,9,2,1));
> la.push_back(makeVector(3,1,2,3,4));
> la.push_back(makeVector(3,1,3,4));
> la.push_back(makeVector(4,2,1,2,3,4));
> la.push_back(makeVector(4,3,4));
> la.push_back(makeVector(4,2,1,2,3,4,9,2,1));
>
> list<Vector<Dynamic,double> >::iterator it;
>
> for(it = la.begin();it!=la.end();it++){
> cout << *it <<endl;
> }
>
> advance(it,8);
> it = la.erase(la.begin(),it);
> cout <<"erase"<<endl;
> for(it = la.begin();it!=la.end();it++){
> cout << *it <<endl;
> }
>
> but the code from Gerhard, gives the fallowing error (resizable works):
> /Users/gabrielnutzi/Desktop/TooNTest/TooN/internal/vbase.hh:96: error: no
> matching function for call to
> 'TooN::Internal::VectorAlloc<-0x00000000000000001, double>::VectorAlloc()'
> /Users/gabrielnutzi/Desktop/TooNTest/TooN/internal/allocator.hh:167: note:
> candidates are: TooN::Internal::VectorAlloc<-0x00000000000000001,
> Precision>::VectorAlloc(int) [with Precision = double]
> /Users/gabrielnutzi/Desktop/TooNTest/TooN/internal/allocator.hh:160: note:
> TooN::Internal::VectorAlloc<-0x00000000000000001,
> Precision>::VectorAlloc(const
> TooN::Internal::VectorAlloc<-0x00000000000000001, Precision>&) [with
> Precision = double]
>
> What is the difference in allocation when it comes to a resizable ?
>
most likely list.push_back uses a copy constructor (creates a new list element
that has as a member a Vector<Dynamic>) then the size is set at construction
time and everything works.
push_back should not work for a vector as typically elements are already
allocated and constructed and only assigned...
actually my code seems to fail, as there is no default constructor for
Vector<Dynamic>, is that right ?
but another list implementation might work differently...
cheers,
Gerhard
> Thanks!
>
>
>
>
> Am 11.01.2010 um 18:09 schrieb Gerhard Reitmayr:
>
>> vector<Vector<Dynamic> > v(10); // 10 dynamic vectors
>> v[0] = Vector<Dynamic>(10); // set first to a vector with 10 els
>> v[1] = Vector<Dynamic>(20); // set second to a vector with 20 els
>
--
Gerhard Reitmayr
Institute for Computer Graphics and Vision
http://www.icg.tugraz.at/Members/gerhard
tel: ++43 316 873 5082
- [Toon-members] STL containers with TooN, Gabriel Nützi, 2010/01/10
- [Toon-members] Re: STL containers with TooN, Gabriel Nützi, 2010/01/11
- Re: [Toon-members] Re: STL containers with TooN, Gerhard Reitmayr, 2010/01/13
- Re: [Toon-members] Re: STL containers with TooN, E. Rosten, 2010/01/13
- Re: [Toon-members] Re: STL containers with TooN, Gerhard Reitmayr, 2010/01/13
- Re: [Toon-members] Re: STL containers with TooN, E. Rosten, 2010/01/18