Click here to Skip to main content
16,017,707 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Vector of Pointers Pin
Kevin Brydon4-Jun-07 2:23
Kevin Brydon4-Jun-07 2:23 
GeneralRe: Vector of Pointers Pin
Maximilien4-Jun-07 3:05
Maximilien4-Jun-07 3:05 
AnswerRe: Vector of Pointers Pin
Rajkumar R4-Jun-07 3:41
Rajkumar R4-Jun-07 3:41 
GeneralRe: Vector of Pointers Pin
Kevin Brydon4-Jun-07 5:16
Kevin Brydon4-Jun-07 5:16 
GeneralRe: Vector of Pointers Pin
Stephen Hewitt4-Jun-07 15:04
Stephen Hewitt4-Jun-07 15:04 
GeneralRe: Vector of Pointers Pin
led mike3-Mar-08 6:32
led mike3-Mar-08 6:32 
GeneralRe: Vector of Pointers Pin
Stephen Hewitt4-Jun-07 15:01
Stephen Hewitt4-Jun-07 15:01 
AnswerRe: Vector of Pointers [modified] Pin
Rajkumar R4-Jun-07 18:49
Rajkumar R4-Jun-07 18:49 
Hi Steve,
Thanks for your comments,

But I would like you to see the code in low level,
This is the dissasembly of code for vector and normal array

simple array
 c = Array[2];
00411A2F  mov         al,byte ptr [ebp-0DAh] 
00411A35  mov         byte ptr [ebp-0A5h],al 


vector
 c = vecObj[2];
00411A1A  push        2    
00411A1C  lea         ecx,[ebp-0D0h] 
00411A22  call        std::vector<int,std::allocator<int> >::operator[] (4114ECh) 
00411A27  mov         al,byte ptr [eax] 
00411A29  mov         byte ptr [ebp-0A5h],al 

and the call to operator [] disassembles to
reference operator[](size_type _Pos)
		{	// subscript mutable sequence
00411E40  push        ebp  
00411E41  mov         ebp,esp 
00411E43  sub         esp,0CCh 
00411E49  push        ebx  
00411E4A  push        esi  
00411E4B  push        edi  
00411E4C  push        ecx  
00411E4D  lea         edi,[ebp-0CCh] 
00411E53  mov         ecx,33h 
00411E58  mov         eax,0CCCCCCCCh 
00411E5D  rep stos    dword ptr es:[edi] 
00411E5F  pop         ecx  
00411E60  mov         dword ptr [ebp-8],ecx 

 #if _HAS_ITERATOR_DEBUGGING
		if (size() <= _Pos)
00411E63  mov         ecx,dword ptr [this] 
00411E66  call        std::vector<int,std::allocator<int> >::size (41159Bh) 
00411E6B  cmp         eax,dword ptr [_Pos] 
00411E6E  ja          std::vector<char,std::allocator<char> >::operator[]+0A8h (411EE8h) 
			{
			_DEBUG_ERROR("vector subscript out of range");
00411E70  mov         esi,esp 
00411E72  push        2F4h 
00411E77  push        offset string L"c:\\program files\\mic"... (41B8B0h) 
00411E7C  push        offset string L"vector subscript out"... (41B868h) 
00411E81  call        dword ptr [__imp_std::_Debug_message (41F3D0h)] 
00411E87  add         esp,0Ch 
00411E8A  cmp         esi,esp 
00411E8C  call        @ILT+835(__RTC_CheckEsp) (411348h) 
			_SCL_SECURE_OUT_OF_RANGE;
00411E91  xor         eax,eax 
00411E93  jne         std::vector<char,std::allocator<char> >::operator[]+80h (411EC0h) 
00411E95  mov         esi,esp 
00411E97  push        offset string L"("Standard C++ Libra"... (41B800h) 
00411E9C  push        0    
00411E9E  push        2F5h 
00411EA3  push        offset string L"c:\\program files\\mic"... (41B8B0h) 
00411EA8  push        2    
00411EAA  call        dword ptr [__imp___CrtDbgReportW (41F4D4h)] 
00411EB0  add         esp,14h 
00411EB3  cmp         esi,esp 
00411EB5  call        @ILT+835(__RTC_CheckEsp) (411348h) 
00411EBA  cmp         eax,1 
00411EBD  jne         std::vector<char,std::allocator<char> >::operator[]+80h (411EC0h) 
00411EBF  int         3    
00411EC0  mov         esi,esp 
00411EC2  push        0    
00411EC4  push        2F5h 
00411EC9  push        offset string L"c:\\program files\\mic"... (41B8B0h) 
00411ECE  push        offset string L"std::vector<char,cla"... (41B778h) 
00411ED3  push        offset string L""out of range"" (41B750h) 
00411ED8  call        dword ptr [__imp___invalid_parameter (41F4D8h)] 
00411EDE  add         esp,14h 
00411EE1  cmp         esi,esp 
00411EE3  call        @ILT+835(__RTC_CheckEsp) (411348h) 
			}
 #endif /* _HAS_ITERATOR_DEBUGGING */
		_SCL_SECURE_VALIDATE_RANGE(_Pos < size());
00411EE8  mov         ecx,dword ptr [this] 
00411EEB  call        std::vector<int,std::allocator<int> >::size (41159Bh) 
00411EF0  cmp         dword ptr [_Pos],eax 
00411EF3  jb          std::vector<char,std::allocator<char> >::operator[]+10Ch (411F4Ch) 
00411EF5  xor         eax,eax 
00411EF7  jne         std::vector<char,std::allocator<char> >::operator[]+0E4h (411F24h) 
00411EF9  mov         esi,esp 
00411EFB  push        offset string L"("_Pos < size()", 0)"... (41B71Ch) 
00411F00  push        0    
00411F02  push        2F8h 
00411F07  push        offset string L"c:\\program files\\mic"... (41B8B0h) 
00411F0C  push        2    
00411F0E  call        dword ptr [__imp___CrtDbgReportW (41F4D4h)] 
00411F14  add         esp,14h 
00411F17  cmp         esi,esp 
00411F19  call        @ILT+835(__RTC_CheckEsp) (411348h) 
00411F1E  cmp         eax,1 
00411F21  jne         std::vector<char,std::allocator<char> >::operator[]+0E4h (411F24h) 
00411F23  int         3    
00411F24  mov         esi,esp 
00411F26  push        0    
00411F28  push        2F8h 
00411F2D  push        offset string L"c:\\program files\\mic"... (41B8B0h) 
00411F32  push        offset string L"std::vector<char,cla"... (41B778h) 
00411F37  push        offset string L""out of range"" (41B750h) 
00411F3C  call        dword ptr [__imp___invalid_parameter (41F4D8h)] 
00411F42  add         esp,14h 
00411F45  cmp         esi,esp 
00411F47  call        @ILT+835(__RTC_CheckEsp) (411348h) 

		return (*(_Myfirst + _Pos));
00411F4C  mov         eax,dword ptr [this] 
00411F4F  mov         eax,dword ptr [eax+8] 
00411F52  add         eax,dword ptr [_Pos] 
	}


while in release build,
c = vecObj[2];
004011EC  mov         ecx,dword ptr [esp+20h] 
004011F0  cmp         ecx,ebx 
004011F2  je          main+12Bh (4011FBh) 
004011F4  sub         eax,ecx 
004011F6  cmp         eax,2 
004011F9  ja          main+12Dh (4011FDh) 
004011FB  call        ebp  


please comment,
Thank you,
Best Regards
Raj



-- modified at 0:54 Tuesday 5th June, 2007
GeneralRe: Vector of Pointers Pin
Stephen Hewitt4-Jun-07 19:00
Stephen Hewitt4-Jun-07 19:00 
GeneralRe: Vector of Pointers Pin
Rajkumar R4-Jun-07 19:18
Rajkumar R4-Jun-07 19:18 
GeneralRe: Vector of Pointers Pin
Stephen Hewitt4-Jun-07 19:29
Stephen Hewitt4-Jun-07 19:29 
GeneralRe: Vector of Pointers Pin
Rajkumar R4-Jun-07 19:57
Rajkumar R4-Jun-07 19:57 
GeneralRe: Vector of Pointers Pin
Stephen Hewitt4-Jun-07 20:11
Stephen Hewitt4-Jun-07 20:11 
Questionset 24 hr time format using Date Time Picker Control Pin
abhiakude4-Jun-07 0:28
abhiakude4-Jun-07 0:28 
AnswerRe: set 24 hr time format using Date Time Picker Control Pin
Rajkumar R4-Jun-07 0:40
Rajkumar R4-Jun-07 0:40 
GeneralRe: set 24 hr time format using Date Time Picker Control Pin
abhiakude4-Jun-07 1:31
abhiakude4-Jun-07 1:31 
QuestionChange view into MDIFrame Pin
baerten4-Jun-07 0:08
baerten4-Jun-07 0:08 
JokeRe: Change view into MDIFrame Pin
Jhony george4-Jun-07 1:43
Jhony george4-Jun-07 1:43 
GeneralRe: Change view into MDIFrame Pin
baerten4-Jun-07 2:28
baerten4-Jun-07 2:28 
QuestionHow to check wireless net connection? Pin
oustar3-Jun-07 23:57
oustar3-Jun-07 23:57 
QuestionRe: How to check wireless net connection? Pin
David Crow4-Jun-07 3:38
David Crow4-Jun-07 3:38 
QuestionCannot remove directory Pin
Wim Engberts3-Jun-07 23:54
Wim Engberts3-Jun-07 23:54 
AnswerRe: Cannot remove directory Pin
kakan4-Jun-07 0:13
professionalkakan4-Jun-07 0:13 
GeneralRe: Cannot remove directory Pin
Wim Engberts4-Jun-07 0:36
Wim Engberts4-Jun-07 0:36 
GeneralRe: Cannot remove directory Pin
kakan4-Jun-07 0:38
professionalkakan4-Jun-07 0:38 

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.