473,320 Members | 1,951 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,320 software developers and data experts.

difference between return &*i and return i;

Hi All,

At some places in code, I see following statements,

const XMLCh* some_func()
{
return &*(*i)->m_Value.begin();
}

Is that any different from following syntax ?

const XMLCh* some_func()
{
return (*i)->m_value.begin();
}

Thanks
Ganesh.
Jul 22 '05 #1
4 1809
Ganesh Gella wrote:
At some places in code, I see following statements,

const XMLCh* some_func()
{
return &*(*i)->m_Value.begin();
}

Is that any different from following syntax ?

const XMLCh* some_func()
{
return (*i)->m_value.begin();
}
...


'i' could easily be different from '&*i' if the '*' operator is
overloaded in 'i'. That appears to be the case in the code above.

--
Best regards,
Andrey Tarasevich
Jul 22 '05 #2
Ganesh Gella wrote:
Hi All,

At some places in code, I see following statements,

const XMLCh* some_func()
{
return &*(*i)->m_Value.begin();
}


If the value returned by begin() has an overload for operator*
(or the result of *begin() has an overload for &), it's not the
same as omitting the &*.

For example if m_Value is list<XMLCh> type, then begin() returns
list<XLMCh>::iterator which is NOT the same as XMLCh*. It does
however have an operator* that reutrns XMLCh& and you can take the
address of that to get the adderss of the XMLCh object in the list.
Jul 22 '05 #3

"Ganesh Gella" <gk******@yahoo.com> wrote in message
news:d3**************************@posting.google.c om...
Hi All,

At some places in code, I see following statements,

const XMLCh* some_func()
{
return &*(*i)->m_Value.begin();
}

Is that any different from following syntax ?

const XMLCh* some_func()
{
return (*i)->m_value.begin();
}

Thanks
Ganesh.


Yes, the return from begin() is (presumably) an iterator, and the return
from &* ... begin() is (presumably) a pointer.

john
Jul 22 '05 #4
gk******@yahoo.com (Ganesh Gella) wrote in message news:<d3**************************@posting.google. com>...
Hi All,

At some places in code, I see following statements,

const XMLCh* some_func()
{
return &*(*i)->m_Value.begin();
}

Is that any different from following syntax ?

const XMLCh* some_func()
{
return (*i)->m_value.begin();
}

Thanks
Ganesh.


outside of operator loading, yes. but with operator overloading it can be anything
Jul 22 '05 #5

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

Similar topics

13
by: Mattias Campe | last post by:
Hi, Depending on if I get an image or a text of a certain URL, I want to do something different. I don't know in advance whether I'll get an image or a text. This is a URL that returns an...
19
by: John Keeling | last post by:
Dear all, I tried the test program below. My interest is to examine timing differences between insert vs. append & reverse for a list. My results on my XP Python 2.3.4 are as follows:...
1
by: learning_C++ | last post by:
Hi, I compiled some code. In the function friend ostream& operator<<(ostream& os, const complex c); I use the later argument complex c and complex& c. I can get the same values and there is no...
4
by: Joel | last post by:
Run this method: public void test() { bool b; int i=0; b=false; i=0; b=(b && i++==1);
16
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
1
by: Thomas D. | last post by:
Hello all, I'm using the IXmlSerializable interface for a project and encounter some problems when testing my webservice in a client application. I know this interface is undocumented and not...
3
by: gevadas | last post by:
sample program #include <iostream> #include <vector> using namespace std; int find(char*& value,char** arr,int size) { for(int i = 0;i < size;i++)
33
by: onkar | last post by:
#include<stdio.h> int main(int argc,char **argv){ int a={1,2,3,4,5}; printf("%p\n%p\n",a,&a); return 0; } gives me : 0xbfe837a0
4
by: Jane T | last post by:
I appreciate how difficult it is to resolve a problem without all the information but maybe someone has come across a similar problem. I have an 'extract' table which has 1853 rows when I ask for...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...

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.