As of C++17 what you were trying to do is finally possible:
if (int a = Func1(), b = Func2(); a && b)
{
// Do stuff with a and b.
}
Note the use of ;
of instead of ,
to separate the declaration and the actual condition.
More Related Contents:
- if / else at compile time in C++?
- String return from member function in C++
- c++ if specific words from string
- Compilation error: expected constructor, destructor, or type conversion before ‘;’ token [closed]
- Error when building a C++ program for the second time [closed]
- How do I prevent program from running BOTH an IF and ELSE statement with C++?
- Using G++ to compile multiple .cpp and .h files
- Most efficient way to compare a variable to multiple values?
- Advantage of switch over if-else statement
- Declaring variables inside loops, good practice or bad practice?
- How to enable C++17 compiling in Visual Studio?
- Why does C++ compilation take so long?
- What is the difference between these (bCondition == NULL) and (NULL==bCondition)?
- Difference between “if constexpr()” Vs “if()”
- Why is initialization of a new variable by itself valid? [duplicate]
- Variable assignment in an “if” condition
- What do compilers do with compile-time branching?
- Using assignment as a condition expression?
- Parsing strings of user input using the cparse library from git
- Undefined reference error for template method [duplicate]
- Profiling the C++ compilation process
- “IF” argument evaluation order?
- How Switch case Statement Implemented or works internally?
- C++11 – declaring non-static data members as ‘auto’
- Can I declare variables of different types in the initialization of a for loop? [duplicate]
- Why does this if condition fail for comparison of negative and positive integers [duplicate]
- comma operator in if condition
- if statement not working right?
- Do I need to put constexpr after else-if?
- Can I use Qt without qmake or Qt Creator?