bool

Is a bool read/write atomic in C#

Is accessing a bool field atomic in C#? In particular, do I need to put a lock around: class Foo { private bool _bar; //... in some function on any thread (or many threads) _bar = true; //... same for a read if (_bar) { ... } } ...

What is the difference between Bool and Boolean types in C#

What is the difference between Bool and Boolean types in C#? ...

Compiling in c++ with mysql, pthreads and gtk

Have someone ever done this before??? I am trying to use MinGW to compile a program using the MySQL libraries. I keep getting the message that the function 'rint' is redefined. Ok it's true that the function is in both files config-win.h, from MySQL and math.h from the standard library, but both of them are suppose to be libraries with ...

How do I cast a bool to a BOOL ?

Am I safe in casting a C++ bool to a Windows API BOOL via this construct bool mybool = true; BOOL apiboolean = mybool ? TRUE : FALSE; I'd assume this is a yes because I don't see any obvious problems but I wanted to take a moment to ask only because this may be more subtle than it appears. Thanks to Dima for (gently) pointing out my...

Which MySQL Datatype to use for storing boolean values from/to PHP?

Since MySQL doesn't seem to have any 'boolean' datatype, which datatype do you 'abuse' for storing true/false information in MySQL? Especially in the context of writing and reading from/to a PHP-Script. Over time I have used and seen several approaches: tinyint, varchar fields containing the values 0/1, varchar fields containing the...

FormatException: Html.CheckBox(), UpdateModel() and the hidden input

i have my checkbox for a bool field like so in my view: =Html.CheckBox("Active", ViewData["Active"] != null ? ViewData["Active"] : (ViewData.Model.Active != null ? ViewData.Model.Active : false) you can forget the fluff if you like: =Html.CheckBox("Active", ViewData.Model.Active) ..causes the same problem. when i try to update my mo...

BOOL changing value in objective-C?

I am having trouble with a BOOL property and I can't quite figure it out. I have the following set in my .h file: BOOL myVar; @property BOOL myVar; Then in my .m file I synthesize myVar and have a method that set myVar=YES; and also starts a timer. The timer then calls another method that tries to read the value of myVar. To test f...

boolean datatype question

Is it acceptable to assign 'NULL' to a boolean datatype? ...

Alternative to vector<bool>

As (hopefully) we all know, vector<bool> is totally broken and can't be treated as a c array. What is the best way to get this functionality? So far, the ideas I have thought of are: Use a vector<char> instead, or Use a wrapper class and have vector<bool_wrapper> How do you guys handle this problem? I need the c_array() functionality...

Why SS generated all Int data type to bool ?

Hi, My Db have some fields using Integer data type, but after SS generated them, all of them 're Boolean db type. Please tell me how to fix it ! Thanks ! ...

Default value for bool in C++

I'm redesigning a class constructor in C++ and need it to catch an unspecified bool. I have used default values for all of the other parameters, but from my understanding bool can only be initialized to true or false. Since both of those cases have meaning in the class, how should I handle checking for change from a default value? ...

How would std::ostringstream convert to bool?

I stumbled across this code. std::ostringstream str; /// (some usage) assert( ! str ); What does ostringstream signify when used in a bool context? Is this possibly an incorrect usage that happens to compile and run? ...

NSTableColumn bound to a BOOL value

i have NSTableView bound to an NSArrayController. in my model i have a BOOL field. i'm trying to bind that value to the column. it displays correctly (1 where value is YES and 0 where value is NO), but it's readonly. =( when i'm trying to edit a value i can't submit it -- when i press enter nothing happens, setter is never invoked. colum...

Why does a quoted string match bool method signature before a std::string?

Given the following methods: // Method 1 void add(const std::string& header, bool replace); //Method 2 void add(const std::string& name, const std::string& value); It would appear that the following code will end up calling method 1 instead of method 2: something.add("Hello", "World"); I ended up creating another method that looks...

MS VC++ 6 : Why return !false rather than true?

Looking at some code I noticed that another dev had changed every instance of true to !false. Why would you do that? thx ...

Ways to indicate a BOOL wrapper?

In Objective-C, are there any ways to indicate that an NSNumber* should actually be a BOOL? Right now my code looks like: NSNumber *audio; // BOOL wrapper Without the comment, it is not immediately obvious that *audio is a boolean value. My first thought was to try typedef NSNumber* BOOL; but this gave a compiler error apparently ...

error: property 'myBoolVariableName' with 'retain' attribute must be of object type

I have a BOOL value inside my @interface definition in my .h file. Here it is below. It has the same problem whether it's a pointer or not. @interface myCustomViewController : UIViewController <UIWebViewDelegate> { { //...more iboutlets defined above BOOL *myBoolVariableName; } When I compile, I get "error: property 'myBoolVariabl...

Cast bool to T where T is int

How can I make this function reliably cast sourceValue to type T where sourceValue is bool and T is int? public static T ConvertTo<T>(Object sourceValue) { // IF IS OF THE SAME TYPE --> RETURN IMMEDIATELY if (sourceValue is T) return (T) sourceValue; var val = ConvertTo(sourceValue, typeof (T)); return (T) val; } Curren...

SQLite3 with NSMutableArray

In my app the user will be able to make/load configurations and each configuration is made up of NSStrings and BOOL values. I need to be able to store the users configurations into a NSMutableArray (there is no set limit to how many rows can be in the array) and store that NSMutableArray into a database. I don't know enough about obj-c ...

Are Python's bools passed by value?

I sent a reference to a bool object, and I modified it within a method. After the method finished it's execution, the value of the bool outside the method was unchanged. This leads me to believe that Python's bools are passed by value. Is that true? What other Python types behave that way? ...