Prev: pros and cons of returning const ref to string instead of string by value
Next: pros and cons of returning const ref to string instead of string by value
From: Seungbeom Kim on 8 Dec 2009 07:33 itaj sherman wrote: > On Dec 5, 6:17 am, peter koch larsen <peter.koch.lar...(a)gmail.com> > wrote: >> >> void f(volatile bool b) > > btw, I hope I didn't miss something important: what is the point in > 'b' being volatile? My guess is that it is just meant to emphasize (to the human readers) that you cannot determine the value of b statically, which would of course hold even if volatile were not there. I haven't seen volatile as a top-level qualifier (i.e. not through a pointer or a reference), and I don't think it means anything significant. Please correct me if I'm wrong. -- Seungbeom Kim [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
From: Frank Birbacher on 9 Dec 2009 12:40
Hi! Seungbeom Kim schrieb: > I haven't seen volatile as a top-level qualifier (i.e. not through a > pointer or a reference), and I don't think it means anything significant. > Please correct me if I'm wrong. It means the value may change outside the program flow in this function. void changeBool(volatile bool& what) { what = true; } void doVolatile(volatile bool param) { boost::thread(bind(&changeBool, ref(param))); if(param) ... } I usually see volatile for global variables or class members. Frank -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |