Click here to Skip to main content
15,911,848 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Windows message, Pin
Stuart Dootson23-Jun-09 23:02
professionalStuart Dootson23-Jun-09 23:02 
GeneralRe: Windows message, Pin
birajendu24-Jun-09 1:30
birajendu24-Jun-09 1:30 
QuestionHow to redirect Telnet and Ftp in windows Pin
ssm198411923-Jun-09 20:03
ssm198411923-Jun-09 20:03 
AnswerRe: How to redirect Telnet and Ftp in windows Pin
Stuart Dootson23-Jun-09 21:37
professionalStuart Dootson23-Jun-09 21:37 
GeneralRe: How to redirect Telnet and Ftp in windows Pin
ssm198411924-Jun-09 3:02
ssm198411924-Jun-09 3:02 
GeneralRe: How to redirect Telnet and Ftp in windows Pin
Stuart Dootson24-Jun-09 3:08
professionalStuart Dootson24-Jun-09 3:08 
QuestionGetActiveWindow Pin
prithaa23-Jun-09 19:15
prithaa23-Jun-09 19:15 
AnswerRe: GetActiveWindow Pin
Naveen23-Jun-09 20:02
Naveen23-Jun-09 20:02 
GeneralRe: GetActiveWindow Pin
prithaa24-Jun-09 1:53
prithaa24-Jun-09 1:53 
Questionconvert wchar to CString& Pin
Rakesh523-Jun-09 18:59
Rakesh523-Jun-09 18:59 
AnswerRe: convert wchar to CString& Pin
«_Superman_»23-Jun-09 19:21
professional«_Superman_»23-Jun-09 19:21 
GeneralRe: convert wchar to CString& Pin
Rakesh523-Jun-09 19:36
Rakesh523-Jun-09 19:36 
GeneralRe: convert wchar to CString& Pin
Cedric Moonen23-Jun-09 20:10
Cedric Moonen23-Jun-09 20:10 
GeneralRe: convert wchar to CString& Pin
Rajesh R Subramanian23-Jun-09 20:13
professionalRajesh R Subramanian23-Jun-09 20:13 
AnswerRe: convert wchar to CString& Pin
Cedric Moonen23-Jun-09 20:07
Cedric Moonen23-Jun-09 20:07 
GeneralRe: convert wchar to CString& Pin
Rakesh523-Jun-09 20:20
Rakesh523-Jun-09 20:20 
AnswerRe: convert wchar to CString& Pin
Rajesh R Subramanian23-Jun-09 20:12
professionalRajesh R Subramanian23-Jun-09 20:12 
QuestionTabbed control from Win 32 Pin
birajendu23-Jun-09 18:05
birajendu23-Jun-09 18:05 
QuestionC++ Compiler Warnings Pin
dipuks23-Jun-09 13:37
dipuks23-Jun-09 13:37 
AnswerRe: C++ Compiler Warnings Pin
Luc Pattyn23-Jun-09 14:09
sitebuilderLuc Pattyn23-Jun-09 14:09 
AnswerRe: C++ Compiler Warnings Pin
N a v a n e e t h23-Jun-09 15:56
N a v a n e e t h23-Jun-09 15:56 
GeneralRe: C++ Compiler Warnings Pin
David Crow24-Jun-09 3:11
David Crow24-Jun-09 3:11 
AnswerRe: C++ Compiler Warnings Pin
«_Superman_»23-Jun-09 16:26
professional«_Superman_»23-Jun-09 16:26 
AnswerRe: C++ Compiler Warnings Pin
KarstenK23-Jun-09 21:31
mveKarstenK23-Jun-09 21:31 
QuestionConsiderations and implementation of a method to copy the vector<t>::iterator</t> Pin
Cyrilix23-Jun-09 9:23
Cyrilix23-Jun-09 9:23 
My title is probably not very well phrased, but here is the problem. Let's say I've got functions a(), b(), where a() calls b(), and b() calls vector<T>::iterator iter = someVector.begin().

b() needs to pass this iterator down to a() via a void* mechanism, without returning it (essentially using reference passing), so more explicitly, the two functions are:

void a(void*& param);
void b(void*& param);

The problem is, we can't simply do something like this:

vector<T>::iterator iter = someVector.begin();
param = reinterpret_cast<void*>(iter)

This is because the compiler (MSVC9) will complain about trying to cast an iterator to a void*:

error C2440: 'reinterpret_cast' : cannot convert from 'std::_Vector_iterator<_Ty,_Alloc>' to 'void *'

Likewise, I can't do something like...

vector&lt;T&gt;::iterator iter = someVector.begin();
param = reinterpret_cast<void*>(&iter)

...because even though this will compile, it will not work because begin() actually returns an iterator object and not a pointer to some memory location, so the memory address of that object will go out of scope (not sure when, but I'm guessing when you leave b()). So, because I can't do any of this, I thought that maybe I could do a memory copy of the iterator, pass it up as a void*, and then cast it back to an iterator, so something along these lines:

vector<T>::iterator iter = someVector.begin();
void* mem = malloc(sizeof(vector<T>::iterator));
//memcpy starting from &iter up to the size, into the malloc memory
param = mem;

And on the flip side, in order to decode my data, I'd do something like this:

vector<T>::iterator = reinterpret_cast<vector<T>::iterator>(param);

I'm wondering whether or not this idea of mine is feasible or will cause me many problems, or if there is a better way of doing what I'd like to do, given the limitations (can only pass by void* reference).

Thanks.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.