bool

ICollectionView.SortDescriptions does not work for boolean

Hi ! myListBox.Items.SortDescriptions.Add( new SortDescription("BoolProperty", ListSortDirection.Descending)); This sorting works only for string properties of the underlying project. Not with boolean? Is there a reason for that ? Thanks ! UPDATE: Yep, your example really works. But what's wrong on my example ? public clas...

Can I write the contents of vector<bool> to a stream directly from the internal buffer?

I know vector< bool > is "evil", and dynamic_bitset is preferred (bitset is not suitable) but I am using C++ Builder 6 and I don't really want to pursue the Boost route for such an old version. I tried : int RecordLen = 1; int NoBits = 8; std::ofstream Binary( FileNameBinary ); vector< bool > CaseBits( NoBits, 0 ); Binary.write( ( const...

How to serialize Nullable<bool> ?

I want to serialize a nullable bool simply by converting it to a string public static string SerializeNullableBoolean(bool? b) { if (b == null) { return "null or -1 or .."; // What to return here? } else { return b.ToString(); } } What is the most appr...

How to access a variable's value from one class, if the variable is defined in another? (Objective-C)

I have two pairs (.m and .h) of files. In one's interface section, I've defined a global BOOL variable. I need to get it's value in another class. How can I do it? (I can't make one class a subclass of another). In one file I have @interface TabBarRotation : UITabBarController { BOOL portrait; } @end @implementation TabBarRota...

IPHONE SDK, How to put Void function into my BOOL??? PLEASE!

I am using the IPhone's Accelerometer to make a object move. I want to be able to make this function work and not work depending on different states. I have my code for my Accelerometer function and i want to put it into a BOOL so i can call on it when i need it, but i am having problems. Can anyone Help me put this code into a BOOL na...

display multiple errors via bool flag c++

Been a long night, but stuck on this and now am getting "segmentation fault" in my compiler.. Basically I'm trying to display all the errors (the cout) needed. If there is more than one error, I am to display all of them. bool validMove(const Square board[BOARD_SIZE][BOARD_SIZE], int x, int y, int value) { int index...

array loop not working correctly? c++

Trying to count how many elements within the array are not equal to 0, is something set up wrong? I'd like to check all values in the array (it's a sudoku board) and then when all elements are "full" I need to return true. Is something off? bool boardFull(const Square board[BOARD_SIZE][BOARD_SIZE]) { int totalCount=0; for (int ...

IPhone sdk stop the accelerometer from working when something happens.

Hi, I am using the accelerometer to move a few UIImageViews around the screen, at the moment the accelerometer only works when a NSTimer is at 0, this is fine. I would also like to make the accelerometer stop again when a different function happens. here is my code at the moment: -(BOOL) accelerometerWorks { return time == 0; } -(voi...

Errors not printing correctly..Is this logic flow correct? c++

Example user input: PA1 9 //correct PJ1 9 //wrong, error printed "Invalid row" because it is not between A and I PA11 9 //wrong, error printer "Invalid column" because it is not between 1 and 9. The problem I am having is that it should clear the remaining input and then ask for the user to enter the "move" again, and it is not. Wh...

Why .NET Boolean has TrueLiteral and TrueString?

Why in Boolean type there are two fields with the same value? internal const int True = 1; internal const int False = 0; internal const string TrueLiteral = "True"; internal const string FalseLiteral = "False"; and public static readonly string TrueString; public static readonly string FalseString; static Boolean() { TrueString ...

Can I assume (bool)true == (int)1 for any C++ compiler ?

Can I assume (bool)true == (int)1 for any C++ compiler ? ...

Python operators returning ints

Is there any way to have Python operators line "==" and ">" return ints instead of bools. I know that I could use the int function (int(1 == 1)) or add 0 ((1 == 1) + 0) but I was wondering if there was an easy way to do it. Like when you want division to return floats you could type from __future__ import division. Is there any way to do...

Extracting bool from istream in a templated function

I'm converting my fields class read functions into one template function. I have field classes for int, unsigned int, long, and unsigned long. These all use the same method for extracting a value from an istringstream (only the types change): template <typename Value_Type> Value_Type Extract_Value(const std::string& input_string) { ...

default value of BOOL in Objective-C?

Hello , What is the default value of BOOL in Objective-C? ...

determining True/False.

Hi there, the following code #include <iostream> using namespace std; int main(){ char greeting[50] = "goodmorning everyone"; char *s1 = greeting; char *s2 = &greeting[7]; bool test = s2-s1; cout << "s1 is: " << s1 << endl; cout << "s2 is: " << s2 << endl; if (test == true ){ cout << "test is true...

How to evaluate bool statements

I have a piece of code which is said to return a bool value. I am a new programmer, so could someone give me code that will determine if the file at the path exists? NSString *docsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *path = [docsDirectory stringByAppen...

Django filter bool not iterable

I want to filter all Relation Objects where (relation= following relation in a virtual community) the date one has initiated the following is in the past, related to the moment now. The following declaration seems to be wrong, as a bool object is not iterable. Is there another way to do that? d = Relations.objects.filter(date_follow < ...

Binding a Collection<bool> to togglebuttons/checkboxed

Hi, I have a collection of bools associated to days of the week - Collection() { true, false, false, false, false, false,false}; So whatever the bool represents means that this collection applies for sunday (sunday being the first day of week here). Now I have set the itemssource of my listbox, say, to be this collection. <ListBox Ite...

Usefulness of bool* in C#

Can I use bool* in any kind of meaningful way. How would I convert bool* to a byte for instance, or store bool* in a byte My goal is to manage my own memory in a project of mine, the specifics aren't important, just something id like to do. Now I would like to be able to store my own variables, and i happen to need to store a boolean va...

What _IS_ bool in C++?

I ran across some very interesting code that makes me wonder about what bool is. I've always considered it to be a primitive type, like int or char or long. But today, I saw something that looked like this: void boolPtrTest() { bool thisBool = true; boolPtrHere(thisBool); printf("thisBool is %s\n", thisBool ? "true" : "fal...