This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
int main() | |
{ | |
std::vector<int> vec {1,2,3}; | |
if (std::all_of(std::begin(vec), std::end(vec), [](const auto& arg) { return arg < 10; })) | |
{ | |
std::cout << "All less than 10" << std::endl; | |
} | |
else | |
{ | |
std::cout << "Some greater than 10" << std::endl; | |
} | |
return 0; | |
} |
To compile and run this code in Linux:
g++-5 -std=c++14 cpp14.cpp && ./a.out
Of course, you need to install g++-5 first in order to use C++14. In Ubuntu:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-5
No comments:
Post a Comment