Click here to Skip to main content
15,915,702 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Dynamic Views Pin
Yulianto.12-Jan-05 15:31
Yulianto.12-Jan-05 15:31 
GeneralMSVC 2003 GUI Help Pin
c++code10112-Jan-05 14:31
c++code10112-Jan-05 14:31 
GeneralSending output to a printer Pin
BRIMID12-Jan-05 13:29
BRIMID12-Jan-05 13:29 
GeneralMFC socket programing problem Pin
shaihnc12-Jan-05 12:39
shaihnc12-Jan-05 12:39 
GeneralRe: MFC socket programing problem Pin
shaihnc13-Jan-05 5:32
shaihnc13-Jan-05 5:32 
GeneralSpeed of operators Pin
Malcolm Smart12-Jan-05 11:57
Malcolm Smart12-Jan-05 11:57 
GeneralRe: Speed of operators Pin
Rick York12-Jan-05 12:18
mveRick York12-Jan-05 12:18 
GeneralRe: Speed of operators Pin
Mike Dimmick12-Jan-05 12:19
Mike Dimmick12-Jan-05 12:19 
It very much depends on the compiler. I would actually expect an optimising compiler to generate the same code for A and C, and also the same code (possibly different from A/C) for B and D. B and D have an extra 'sequence point' according to the C++ specification, where all externally visible side-effects must be complete from evaluating the left side of || before any side-effects from the right-hand side are visible. However since they're just tests with no observable side-effects this rule doesn't really apply.

Atomic operations - operations that are all-or-nothing. Either the whole operation succeeds, or none of it succeeds. The term is usually used to mean that operations appear as if they occurred in a particular sequence. Assignment of simple, register-size values is an atomic operation - it cannot be broken up. However, incrementing is not atomic - the processor must read the existing value, increment it and write it back. Another thread could read the value before the write-back occurs, increment that and write it back. Two threads have tried to increment, but the value is only one greater than before.

The issue isn't relevant here, because you're only dealing with local variables and parameters, which will be on your thread's stack. It's very unlikely that another thread will be writing to those values. C and C++ offer no support for atomic operations. The most they provide is the volatile keyword, which tells the compiler that it must read from the memory location every time, it cannot cache the value in a register and reuse it.

They're all O(1). There's no polynomial complexity at all. The time taken will never vary (disregarding the possibility of system context switches, e.g. handling an interrupt, switching to a different thread) regardless of the value of n.

If you want to know more, I suggest compiling the code using the Listing generation options and examine the generated assembly.

Stability. What an interesting concept. -- Chris Maunder
GeneralRe: Speed of operators Pin
Mike Dimmick12-Jan-05 12:59
Mike Dimmick12-Jan-05 12:59 
GeneralRe: Speed of operators Pin
Ryan Binns12-Jan-05 16:58
Ryan Binns12-Jan-05 16:58 
GeneralOnSize Function : Positioning Static Controls Pin
tnguyen44412-Jan-05 11:50
tnguyen44412-Jan-05 11:50 
GeneralRe: OnSize Function : Positioning Static Controls Pin
User 1278212-Jan-05 16:13
User 1278212-Jan-05 16:13 
GeneralRe: OnSize Function : Positioning Static Controls Pin
Ryan Binns12-Jan-05 17:01
Ryan Binns12-Jan-05 17:01 
GeneralRe: OnSize Function : Positioning Static Controls Pin
tnguyen44413-Jan-05 6:10
tnguyen44413-Jan-05 6:10 
GeneralForms Problem (new to Win32 programming) Pin
LighthouseJ12-Jan-05 11:30
LighthouseJ12-Jan-05 11:30 
GeneralChecking Namedpipe Access Pin
humps12-Jan-05 10:43
humps12-Jan-05 10:43 
GeneralSetActivePage in property page Pin
DanYELL12-Jan-05 9:58
DanYELL12-Jan-05 9:58 
GeneralRe: SetActivePage in property page Pin
Michael Dunn12-Jan-05 10:23
sitebuilderMichael Dunn12-Jan-05 10:23 
GeneralRe: SetActivePage in property page Pin
DanYELL12-Jan-05 12:28
DanYELL12-Jan-05 12:28 
GeneralRe: SetActivePage in property page Pin
Michael Dunn12-Jan-05 14:50
sitebuilderMichael Dunn12-Jan-05 14:50 
Generalbrowsing DLL resource files through CFileDialog Pin
(Steven Hicks)n+112-Jan-05 8:13
(Steven Hicks)n+112-Jan-05 8:13 
GeneralRe: browsing DLL resource files through CFileDialog Pin
Neville Franks12-Jan-05 8:57
Neville Franks12-Jan-05 8:57 
GeneralRe: browsing DLL resource files through CFileDialog Pin
Ryan Binns12-Jan-05 17:06
Ryan Binns12-Jan-05 17:06 
GeneralWinsock recv help Pin
KnaveR77712-Jan-05 7:19
KnaveR77712-Jan-05 7:19 
GeneralRe: Winsock recv help Pin
greba12-Jan-05 7:58
greba12-Jan-05 7:58 

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.