C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Valarrays und normale arrays

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German)
View previous topic :: View next topic  
Author Message
Sebastian Thiebes
Guest





PostPosted: Wed Jun 09, 2004 8:54 am    Post subject: Valarrays und normale arrays Reply with quote



Hello allerseits,

Ich benutze in meinem Code valarrays, um Daten zu speichern und zu
bearbeiten. Manchmal muss ich diese Daten aber für andere Methoden in
Form von normalen arrays weitergeben. Bisher habe ich dafür folgende
Lösung verwendet:

valarray<double> vad;
// valarray wird mit Werten gefüllt
double* da = new double[vad.size()];

for (long i = 0; i < vad.size(); ++i)
{
da[i] = vad[i];
}

Das funktioniert auch gut, aber ich habe das Gefühl, das ginge auch
wesentlich eleganter und wahrscheinlich auch effizienter. Kann man einen
valarray irgendwie direkt casten oder einfach als array behandeln?

Vielen Dank,

Sebastian

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
Back to top
Markus Schaaf
Guest





PostPosted: Wed Jun 09, 2004 12:25 pm    Post subject: Re: Valarrays und normale arrays Reply with quote



"Sebastian Thiebes" <thiebes (AT) hhi (DOT) de> schrieb:

Quote:
Ich benutze in meinem Code valarrays, um Daten zu speichern und zu
bearbeiten. Manchmal muss ich diese Daten aber für andere Methoden in
Form von normalen arrays weitergeben. Bisher habe ich dafür folgende
Lösung verwendet:

[elementweises Kopieren]

Quote:
Das funktioniert auch gut, aber ich habe das Gefühl, das ginge auch
wesentlich eleganter und wahrscheinlich auch effizienter. Kann man einen
valarray irgendwie direkt casten oder einfach als array behandeln?

Ein »valarray« ist auf eine bestimmte Art ein "normales" Array
(§26.3.2.3/3). Du kannst also einfach die Adresse des ersten
Elements nehmen.

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.