Click here to Skip to main content
15,896,201 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: MFC how to popup menu when i right click leaf node which is under the root node Pin
Richard MacCutchan29-Aug-12 23:29
mveRichard MacCutchan29-Aug-12 23:29 
GeneralRe: MFC how to popup menu when i right click leaf node which is under the root node Pin
Member 934498630-Aug-12 22:12
Member 934498630-Aug-12 22:12 
QuestionHow to avoid message Queue on click event? Pin
Le@rner29-Aug-12 19:34
Le@rner29-Aug-12 19:34 
AnswerRe: How to avoid message Queue on click event? Pin
Jochen Arndt30-Aug-12 0:53
professionalJochen Arndt30-Aug-12 0:53 
GeneralRe: How to avoid message Queue on click event? Pin
Le@rner31-Aug-12 20:35
Le@rner31-Aug-12 20:35 
QuestionEnumFontFamiliesEx only returns one font -- SOLVED Pin
Alan Balkany29-Aug-12 8:49
Alan Balkany29-Aug-12 8:49 
AnswerRe: EnumFontFamiliesEx only returns one font -- SOLVED Pin
Alan Balkany29-Aug-12 8:53
Alan Balkany29-Aug-12 8:53 
Questionfunny with boost::tribool Pin
Robin Imrie29-Aug-12 6:44
professionalRobin Imrie29-Aug-12 6:44 
can any one explain why this code...

C++
#include <boost\logic\tribool.hpp>

using namespace boost;
using namespace std;

tribool test1();
tribool test2();

int _tmain(int argc, _TCHAR* argv[])
{
	if( !test1() || !test2() )
		cout << "test failed" << endl;
	
	return 0;
}

tribool test1()
{
	cout << "test1" << endl;
	return true;
}

tribool test2()
{
	cout << "test2" << endl;
	return false;
}


gives the following output..
test2
test1
test failed

According to the documentation on the || operator the
The operands of logical-AND and logical-OR expressions are evaluated from left to right. If the value of the first operand is sufficient to determine the result of the operation, the second operand is not evaluated. This is called "short-circuit evaluation." There is a sequence point after the first operand. See Sequence Points for more information. 


I fixed the "bug" by changing my if statement to

C++
if( !static_cast<bool>(test1()) || !static_cast<bool>(test2()) )


I did notice in the disassembly that the boost function boost::logic::operator|| was being called and wonder if this what was effecting my logic.

Thanks in advance
Thanks,
Robin.

AnswerRe: funny with boost::tribool (modified) Pin
Chris Meech29-Aug-12 7:14
Chris Meech29-Aug-12 7:14 
GeneralRe: funny with boost::tribool (modified) Pin
Robin Imrie30-Aug-12 2:31
professionalRobin Imrie30-Aug-12 2:31 
GeneralRe: funny with boost::tribool (modified) Pin
Chris Meech30-Aug-12 3:16
Chris Meech30-Aug-12 3:16 
GeneralRe: funny with boost::tribool Pin
CPallini29-Aug-12 11:09
mveCPallini29-Aug-12 11:09 
GeneralRe: funny with boost::tribool Pin
Robin Imrie30-Aug-12 23:28
professionalRobin Imrie30-Aug-12 23:28 
GeneralRe: funny with boost::tribool Pin
Chris Meech31-Aug-12 2:16
Chris Meech31-Aug-12 2:16 
Questionhow to share data between two dlls.? Pin
mbatra3128-Aug-12 1:08
mbatra3128-Aug-12 1:08 
AnswerRe: how to share data between two dlls.? Pin
Maximilien28-Aug-12 3:06
Maximilien28-Aug-12 3:06 
GeneralRe: how to share data between two dlls.? Pin
mbatra3128-Aug-12 19:30
mbatra3128-Aug-12 19:30 
QuestionIs it possible to use std::wstring parameter type in DLL? Pin
Falconapollo27-Aug-12 23:57
Falconapollo27-Aug-12 23:57 
AnswerRe: Is it possible to use std::wstring parameter type in DLL? Pin
CPallini28-Aug-12 0:29
mveCPallini28-Aug-12 0:29 
AnswerRe: Is it possible to use std::wstring parameter type in DLL? Pin
Richard MacCutchan28-Aug-12 7:41
mveRichard MacCutchan28-Aug-12 7:41 
QuestionIPreviewHandler generate BEX error Pin
Le@rner27-Aug-12 22:19
Le@rner27-Aug-12 22:19 
QuestionSending preformed UDP Packets to localhost with C++ Pin
Member 936259727-Aug-12 12:31
Member 936259727-Aug-12 12:31 
QuestionC++ : pass a string array to LPARAM Pin
Atlence27-Aug-12 6:57
Atlence27-Aug-12 6:57 
AnswerRe: C++ : pass a string array to LPARAM Pin
Richard MacCutchan27-Aug-12 7:17
mveRichard MacCutchan27-Aug-12 7:17 
GeneralRe: C++ : pass a string array to LPARAM Pin
Atlence27-Aug-12 11:07
Atlence27-Aug-12 11:07 

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.