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 

Repeating index - Indirect arrays - valarray

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
suresh
Guest





PostPosted: Fri Aug 19, 2005 3:14 pm    Post subject: Repeating index - Indirect arrays - valarray Reply with quote



Namasivayah,

Stroustrup says when indirect array is used for reordering a valarray
the index cannot be repeated twice(page 679). But Nicolai Josuttis in
his book on C++ standard library, page 567, says, index may occur
twice.

g++ version 3.3.5 compiles code with repeated index without any
complaint.

My questions are

1. Can we repeat the index in the index array for reordering a
valarray?
2. Can I get a reordered array which is larger than the original array
by repeating indices. (It works in g++, but I am not sure of
portability)

Thank you,
suresh


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Carl Barron
Guest





PostPosted: Tue Aug 23, 2005 6:47 am    Post subject: Re: Repeating index - Indirect arrays - valarray Reply with quote



In article <1124437899.494084.326510 (AT) g44g2000cwa (DOT) googlegroups.com>,
suresh <suresh.amritapuri (AT) gmail (DOT) com> wrote:

Quote:
Namasivayah,

Stroustrup says when indirect array is used for reordering a valarray
the index cannot be repeated twice(page 679). But Nicolai Josuttis in
his book on C++ standard library, page 567, says, index may occur
twice.

g++ version 3.3.5 compiles code with repeated index without any
complaint.

My questions are

1. Can we repeat the index in the index array for reordering a
valarray?
2. Can I get a reordered array which is larger than the original array
by repeating indices. (It works in g++, but I am not sure of
portability)

section 26.3.9.2 states its undefined behavior in the example in par

3:
[ Example:
int addr [] = {2 , 3 , 1 , 4 , 4};
valarray <size_t > indirect (addr , 5);
valarray <double > a (0. , 10) , b (1. , 5);
a[ indirect ] = b;
results in undefined behavior since element 4 is specified twice in the
indirection. ‹end example ]

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) 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.