Skip to content

Instantly share code, notes, and snippets.

@engelmarkus
Created March 21, 2016 01:48
Show Gist options
  • Save engelmarkus/f66f1b8956e4ed5b239a to your computer and use it in GitHub Desktop.
Save engelmarkus/f66f1b8956e4ed5b239a to your computer and use it in GitHub Desktop.
Test of C++ fold expressions.
#include <iostream>
using namespace std;
constexpr auto all(auto&&... args) {
return (args && ...);
}
int main() {
cout << boolalpha;
cout << all() << endl;
cout << all(true) << endl;
cout << all(false) << endl;
cout << all(true, true) << endl;
cout << all(true, false) << endl;
cout << all(false, true, true) << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment