QtCreator 4.2.1
#include <iostream>
#include <chrono>
#include <thread>
#include <future>
#include <map>
using namespace std::chrono;
using namespace std::chrono_literals;
using namespace std;
int find_answer_to_the_ultimate_question_of_life()
{
std::map<int, int> mp;
decltype(mp)::mapped_type t; // <-- unexpected token t
//Поиск ответа
std::this_thread::sleep_for(5s); // <-- unexpected token ';' got '<error>'
return 42;
}
int main()
{
std::future<int> f = std::async(std::launch::async,
find_answer_to_the_ultimate_question_of_life);
if (f.wait_for(5500ms) == std::future_status::ready ) <-- unexpected token ')' got '<error>'
std::cout << "Answer is: " << f.get() << "\n";
else
std::cout << "Can't wait anymore\n";
return 0;
}
Юзаю qmake, поэтому вот pro-файл:
TEMPLATE = app
CONFIG += console
CONFIG += c++14
SOURCES += main.cpp
QMAKE_CXXFLAGS=-std=c++14