Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9123939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:27:33+00:00 2026-06-17T06:27:33+00:00

bool OrderUtils::shouldCptyAutoexecute(int Id) { bool res = dummyCache::instance().getVal(Id).getWhitelabelType() == ABCD; if (!res) res |=

  • 0
bool OrderUtils::shouldCptyAutoexecute(int Id)
{

bool res = 
    dummyCache::instance().getVal(Id).getWhitelabelType() == "ABCD";
if (!res)
    res |= dummyCache::instance().getVal(Id).getIsPlc() == 1;

return res;
}

The above code checks for 2 Id’s and returns true to res if any of the id is present in the database.

Can you suggest a way in which I can compare one more value from the databse table and return true to the value res..Also can you explain what does the second if statement do and the bitwise OR operator?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:27:35+00:00Added an answer on June 17, 2026 at 6:27 am

    Sir, just let the short-circuit eval do this for you:

    return dummyCache::instance().getVal(Id).getWhitelabelType() == "ABCD" ||
           dummyCache::instance().getVal(Id).getIsPlc() == 1;
    

    If the first is true, the second will not fire. Moreover, I assure you a remotely-reasonable optimizing compiler will not re-fire instance().getVal(id) if the returned object has not changed between the getWhitelabelType() and getisPlc() calls. In fact, i would all-but-guarantee it if getWhiteLabelType() is const. (and it certainly looks like it should be).

    Regarding the bit work. The expression was pretty-much whacked. though it will work. Unless I read it wrong (and trust me, the list of people that will tell me I am will let me know quickly) it is performing a boolean eval, promoting the resulting true/false bool to an int, promoting the current value of res from bool to int (which is zero, so nothing special there), bitwise-OR-ing that with the expression int, then demoting the final int back to a bool to store in res . I’m surprised this doesn’t flag at least a warning on the compiler.

    It likely should have been if (!res) res ||= expr, and even then, it is pointless, as you can just use short circuit eval as in the top of this answer to cut out the local res entirely. Consider if res were false. Then the equivalent expression would be res = false || expr. But thats just res = expr. In the !res state it executes in, you may as well just use an assignment.

    Finally, regarding adding a third field to your eval, it depends entirely on how you want it added. for an additional logical OR it is pretty simple.

    For an expression like (A || B || C) you can just

    return dummyCache::instance().getVal(Id).AField() == ATestValue ||
           dummyCache::instance().getVal(Id).BField() == BTestValue ||
           dummyCache::instance().getVal(Id).CField() == CTestValue;
    

    For more complex operations, some judicious use of parenthesis will go a long way. For example, to return (A || B) && C:

    return (dummyCache::instance().getVal(Id).AField() == ATestValue ||
            dummyCache::instance().getVal(Id).BField() == BTestValue) &&
           dummyCache::instance().getVal(Id).CField() == CTestValue;
    

    Or perhaps (A && C) || (B && !C) (ok this is getting a little overboard…)

    return (dummyCache::instance().getVal(Id).CField() == CTestValue) 
           ? (dummyCache::instance().getVal(Id).AField() == ATestValue)
           : (dummyCache::instance().getVal(Id).BField() == BTestValue);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

bool isValidId(int* id) { if(log10(*id) != 6) { return false; } return true; }
bool pred(int k, int l, int num1, int num2) { return (num1 < num2);
bool takeInt(int a,int b) { cout << a << << b << endl; return
(BOOL)isSupportAutoLayOut { int version = [[[UIDevice currentDevice].systemVersion substringToIndex:1] intValue]; if(version == 6) { return
bool somemethod(int number){ return true; } I keep getting this error message when I
bool foo( int* p ) { return false; } int* bar ( ) {
bool is_sentinel() const { return milliseconds==~uintmax_t(0); } I have found this line of code
With this code: private bool AtLeastOnePlatypusChecked() { return ((ckbx1.IsChecked) || (ckbx2.IsChecked) || (ckbx3.IsChecked) ||
Public bool SqlCheck(string username, string password) { // sql checks here return true }
My code is -(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { NSLog(@%@,petTypeTextFeild.text); return YES; } when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.