472,353 Members | 959 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 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 1756
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...
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...
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...
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...
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....
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 <...
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...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.