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

STL iterator conversions in VC.NET

Hi!
I just moved from VC++ 6.0 to VS.NET and my project no longer compiles
properly. Why this doesn't work anymore (I get C2679 error):

---
std::vector<int> intVec;
int *p;

p = intVec.begin(); // C2679
Nov 17 '05 #1
3 1260
Dr. Proton wrote:
Hi!
I just moved from VC++ 6.0 to VS.NET and my project no longer compiles
properly. Why this doesn't work anymore (I get C2679 error):

---
std::vector<int> intVec;
int *p;

p = intVec.begin(); // C2679


intVec.begin() returns a 'std::vector<int>::iterator', not a 'int *' .
Nov 17 '05 #2
Edward Diener wrote:
Dr. Proton wrote:
Hi!
I just moved from VC++ 6.0 to VS.NET and my project no longer compiles
properly. Why this doesn't work anymore (I get C2679 error):

---
std::vector<int> intVec;
int *p;

p = intVec.begin(); // C2679


intVec.begin() returns a 'std::vector<int>::iterator', not a 'int *' .


Right, and there never was a guarantee that vector<T>::iterator is the same
as T*, though it was T* in VC6. There's a simple, portable workaround:

p = &*intVec.begin();

--
Doug Harrison
Microsoft MVP - Visual C++
Nov 17 '05 #3
On Mon, 22 Dec 2003 10:30:04 -0600, "Doug Harrison [MVP]"
<ds*@mvps.org> wrote:

intVec.begin() returns a 'std::vector<int>::iterator', not a 'int *' .


Right, and there never was a guarantee that vector<T>::iterator is the same
as T*, though it was T* in VC6. There's a simple, portable workaround:

p = &*intVec.begin();


Thanks for the info! It compiles fine now.
Nov 17 '05 #4

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

Similar topics

3
by: Reneé | last post by:
I wanted to know the order of implicit conversions and which sort of values allow them. From searching around in books and the archive of this mailing list, it seems to be that only numbers are...
38
by: Grant Edwards | last post by:
In an interview at http://acmqueue.com/modules.php?name=Content&pa=showpage&pid=273 Alan Kay said something I really liked, and I think it applies equally well to Python as well as the languages...
26
by: Michael Klatt | last post by:
I am trying to write an iterator for a std::set that allows the iterator target to be modified. Here is some relvant code: template <class Set> // Set is an instance of std::set<> class...
15
by: buda | last post by:
Let me see if I got this :) 1. I know the rules for type conversions in arithmetic expressions 2. I know that an implicit type conversion is done at assignment, so float x = 1.23; int t = (int)...
2
by: Lorenzo Castelli | last post by:
This is an old problem of mine. Basically I have an abstract base class which represents a generic iterator over a collection of elements, and various derived classes that implement the...
14
by: shawnk | last post by:
I searched the net to see if other developers have been looking for a writable iterator in C#. I found much discussion and thus this post. Currently (C# 2) you can not pass ref and out arguments...
0
by: mailforpr | last post by:
Hi. Let me introduce an iterator to you, the so-called "Abstract Iterator" I developed the other day. I actually have no idea if there's another "Abstract Iterator" out there, as I have never...
16
by: mailforpr | last post by:
How do I do that? The thing is, the only information I have about the iterator is the iterator itself. No container it is belonging to or anything. Like template<Iteratorvoid...
3
by: bb | last post by:
Hi, Please could you clarify why 'implicit conversion' does not take place while assigning an iterator to reverse_iterator. However, it happens while initializing/constructing. e.g. typedef...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.