473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Pointer as Array reference

In my current project I used templates to provide an
universial interface to vector objects. For this purpose I declared
two methods with an additional template argument:

template<class Vector> void transform(const Vector &x)
template<class Vector> void inv_transform(Vector &x)

Doing it this way I can use it on all data containers
providing index array access via []:

Transform<float> T;
valarray<float> x(16);
float data[16];
float stream[64];

T.transform(x); // works
T.transform(data); // works too
T.inv_transform(x); // works
T.inv_transform(&stream[32]); // error: no matching function for call to
`StreamWaveletTransform<float, HaarFilterBank>:: inv_transform(float (*
[])'
candidates are: void StreamWaveletTransform<T,
FilterBank>::inv_transform(Vector&) [with Vector = float (*)[], T = float,
FilterBank = HaarFilterBank]

The problem is that the compiler won't take a "float *"
for an "float *&". If I do this conversion expilitly I get:
"conversion to non-const reference type `float*&' from rvalue of type
`float*'".

Any suggestions? :-(
Jul 22 '05 #1
1 1491
Ruediger Knoerig wrote:

The problem is that the compiler won't take a "float *"
for an "float *&". If I do this conversion expilitly I get:
"conversion to non-const reference type `float*&' from rvalue of type
`float*'".

Any suggestions? :-(


the epxression

&stream[32]

yields a temporary (the address of the element 32).
You are not allowed to bind a temporary to a non const reference.

template<class Vector> void inv_transform( const Vector &x)
*****
--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Steven T. Hatton | last post by:
I mistakenly set this to the comp.std.c++ a few days back. I don't believe it passed the moderator's veto - and I did not expect or desire anything different. But the question remains: ISO/IEC...
41
by: Berk Birand | last post by:
Hi, I am just learning about the array/pointer duality in C/C++. I couldn't help wondering, is there a way to pass an array by value? It seems like the only way to do is to pass it by...
27
by: Riaan Cillié | last post by:
Hi I'm trying to learn C, but I am struggling with using scanf and a struct. I want to define a structure and declare a variable of that type in int main. This has to be passed to a function and...
2
by: dam_fool_2003 | last post by:
Array element's memory reference is continuous. What happens when I treat a pointer as an array? Is the pointer now used, as an array element memory reference is continuous? int main(void) {...
5
by: Cancerbero | last post by:
Hi (first, excuse me for my bad english) As I know, the semantics for typedef is: typedef A B; I think this makes B a synonym of A, where A is an existing data type. Is that right? Based...
4
by: Kobu | last post by:
I've read the FAQ and several posts on multidimensional arrays and how their names decay to pointer to arrays (not pointer to pointers). If this is so, why does the following code fragment...
6
by: mann! | last post by:
hi can some one please explain how int (*x) declares a pointer to an array and int *x declares an array of pointers?
53
by: Tomás | last post by:
Some programmers treat arrays just like pointers (and some even think that they're exactly equivalent). I'm going to demonstrate the differences. Firstly, let's assume that we're working on a...
29
by: shuisheng | last post by:
Dear All, The problem of choosing pointer or reference is always confusing me. Would you please give me some suggestion on it. I appreciate your kind help. For example, I'd like to convert a...
2
by: Howard | last post by:
Hi, I've got a program whose main object contains an array of "cells", each of which contains an array of "sub-cells", each of which contains an array of "sub-sub-cells". The cells, subcells...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.