0

I`m currently trying something with C++ and want to make the code a bit cleaner.

My if-statement is

if(value1 < 1 || value2 < 1)  

My question is if there is a way to make this shorter like

if(value1 or value2 < 1)

Do I already have the shortest solution or is there a better way to make it?

Thanks in advance Tim

Tim B.
  • 88
  • 2
  • 11
  • 2
    There's no such short cut in c++. – πάντα ῥεῖ Jun 04 '17 at 07:54
  • What's cleaner than a binary yes/no answer... You think too much like a human... – DeiDei Jun 04 '17 at 08:01
  • Why does it need to be shorter? Write code so that it is *clear*. With C++, you're ultimately running the code through an optimizing compiler, so there is no possible speed improvement to be had for "compressing" (obfuscating) the code. So while yes, this can be done with bitwise tricks, it shouldn't be. – Cody Gray - on strike Jun 04 '17 at 11:38
  • Thanks for your answers! I thought that it is better if all is shorter, but it's right. If it is good to read for me it should be the best solution. – Tim B. Jun 04 '17 at 13:54

0 Answers0