Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Question about C++ references
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Charanpal Dhanjal  
View profile  
 More options Apr 19 2012, 3:25 pm
From: Charanpal Dhanjal <charan...@gmail.com>
Date: Thu, 19 Apr 2012 21:25:29 +0200
Local: Thurs, Apr 19 2012 3:25 pm
Subject: Question about C++ references

Hi all,

I am trying to wrap some C++ code in Cython and am having trouble with
references. Here is a code snippet:

cdef extern from "mapped_matrix_ext.h":

cdef cppclass mapped_matrix_ext[T]:

mapped_matrix_ext(int, int, int)

mapped_matrix_ext[T]& add(mapped_matrix_ext[T]&)

cdef mapped_matrix_ext[double] *A = new mapped_matrix_ext[double](3, 3, 5)

cdef mapped_matrix_ext[double] *B = new mapped_matrix_ext[double](3, 3, 5)
cdef mapped_matrix_ext[double] *C

C = A.add(deref(B))

I get the error "Cannot assign type 'mapped_matrix_ext<double> &' to
'mapped_matrix_ext<double> *'" for the last line which I think means
that I need to find the reference of the value returned by the add
method. I wasn't able to find how to do this in the documentation
however (I think it's meant to be in "Declaring/Using References" which
hasn't yet been written). Could someone please help me out?

Thanks for any help,
Charanpal


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bradley Froehle  
View profile  
 More options Apr 20 2012, 11:21 am
From: Bradley Froehle <brad.froe...@gmail.com>
Date: Fri, 20 Apr 2012 08:21:37 -0700 (PDT)
Local: Fri, Apr 20 2012 11:21 am
Subject: Re: Question about C++ references

You have defined "add" to return a reference (mapped_matrix_ext[T]&) but
are assigning the result to a pointer (mapped_matrix_ext[double]*).


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Charanpal Dhanjal  
View profile  
 More options Apr 20 2012, 2:48 pm
From: Charanpal Dhanjal <charan...@gmail.com>
Date: Fri, 20 Apr 2012 20:48:54 +0200
Local: Fri, Apr 20 2012 2:48 pm
Subject: Re: [cython-users] Re: Question about C++ references

Thanks. Sorry if this is a silly question - is there a simple way I can
convert the reference into a pointer?
Charanpal

On 20/04/12 17:21, Bradley Froehle wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »