Hi, I want to make this function to check if all the arguments are true but this doesn't work and from compiler warning I can really understand the problem.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
constexprbool All() { returntrue; }
template<typename... Args>
constexprbool All(bool b, Args...)
{
return b && All(static_cast<bool>(Args)...);
}
int main()
{
bool b = All(true, true, true);
std::cout << "All true = " << b << std::endl;
system("pause");
}
Here are the warnings
In function 'constexpr bool All(bool, Args ...)':
8:40: error: expected primary-expression before ')' token
In instantiation of 'constexpr bool All(bool, Args ...) [with Args = {bool, bool}]':
13:31: required from here
9:1: error: body of constexpr function 'constexpr bool All(bool, Args ...) [with Args = {bool, bool}]' not a return-statement
9:1: warning: no return statement in function returning non-void [-Wreturn-type]
Visual Studio 2015:
Compile with the Clang 3.7 with Microsoft CodeGen (v140_clang_3_7) tool-chain;
specify -std=c++1z in Project => Properties => C/C++ => Command Line => Additional options.
Tnx man for the information but now I'm not that good with installing and using different compilers unless its just
sudo apt-get install ...
:D. It would take like a day or more for me now talking from experience.
For now will just stay with my current compiler (don't really know what it is) but when I'll finish with my (old pre c++17) books I'll have to install something better anyway.