#include #include #include #include #include #include #include using namespace std; void workerFuncBoost() { std::chrono::seconds workTime(3); cout << "boost worker thread started" << endl; std::this_thread::sleep_for(workTime); // TODO something useful will be nice cout << "boost worker thread finished" << endl; } void workerFuncCpp() { std::chrono::seconds workTime(3); cout << "C++11 worker thread started" << endl; std::this_thread::sleep_for(workTime); // TODO something useful will be nice cout << "C++11 worker thread finished" << endl; } int main() { cout << "main: starting threads" << endl; std::thread workerThreadBoost(workerFuncBoost); std::thread workerThreadCpp(workerFuncCpp); cout << "main: waiting for thread" << endl; workerThreadBoost.join(); workerThreadCpp.join(); cout << "main: done" << endl; // construction uses aggregate initialization std::array a1{ {1, 2, 3} }; // double-braces required in C++11 (not in C++14) std::array a2 = {1, 2, 3}; // never required after = std::array a3 = { std::string("a"), "b" }; // container operations are supported std::sort(a1.begin(), a1.end()); std::reverse_copy(a2.begin(), a2.end(), std::ostream_iterator(std::cout, " ")); std::cout << '\n'; // ranged for loop is supported for(const auto& s: a3) std::cout << s << ' '; }