{"id":2989,"date":"2017-04-27T12:17:12","date_gmt":"2017-04-27T11:17:12","guid":{"rendered":"http:\/\/roboblog.fatal-fury.de\/?p=2989"},"modified":"2017-04-28T09:03:23","modified_gmt":"2017-04-28T08:03:23","slug":"c-guns-record-the-result-of-a-boolen-expression","status":"publish","type":"post","link":"http:\/\/roboblog.fatal-fury.de\/?p=2989","title":{"rendered":"C++ Guns -  Record the result of a boolean expression"},"content":{"rendered":"<p>Habt ihr euch schon immer einmal gefragt, welche Bedingung in einer if() denn letztlich wahr wurde? Hier ist ein einfacher Weg das zu protokollieren.<\/p>\n<pre><code>\r\ninline bool test(const bool b, bool& p) {\r\n  p = b;\r\n  return b;\r\n};\r\n\r\nvoid func() {\r\n  double x = 7;\r\n\r\n\/\/ I thinks this is the best\r\n    bool p1 = x>5;\r\n    bool p2 = x<10;\r\n    if(p1 and p2) {\r\n\r\n\/\/ Or choose from this\r\n\/\/  bool p1 = false, p2 = false;\r\n\/\/  if(p=x>5 and p2=x<10) {\r\n\/\/  if(test(x>5, p1) and test(x<10, p2)) {\r\n    if(p1) {\r\n      cout << \"p1 was true\\n\";\r\n    }\r\n    if(p2) {\r\n      cout << \"p2 was true\\n\";\r\n    }\r\n  }\r\n}\r\n<\/code><\/pre>\n<p>Thanks to Juan Jimenez.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Habt ihr euch schon immer einmal gefragt, welche Bedingung in einer if() denn letztlich wahr wurde? Hier ist ein einfacher Weg das zu protokollieren. inline bool test(const bool b, bool&#038; p) { p = b; return b; }; void func() { double x = 7; \/\/ I thinks this is the best bool p1 = [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[17],"class_list":["post-2989","post","type-post","status-publish","format-standard","hentry","category-allgemein","tag-cpp"],"_links":{"self":[{"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/posts\/2989","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2989"}],"version-history":[{"count":5,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/posts\/2989\/revisions"}],"predecessor-version":[{"id":2994,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=\/wp\/v2\/posts\/2989\/revisions\/2994"}],"wp:attachment":[{"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2989"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2989"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/roboblog.fatal-fury.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2989"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}