Does the C ++ standard include what standard headers should include?

In visualstudio, the thread heading includes all of the following headings:

#include <exception>
#include <iosfwd>
#include <functional>
#include <chrono>
#include <memory>
#include <tuple>

So now we can just use this:

#include <thread>
using namespace std;
this_thread::sleep_for(1s);

So, on VS, you no longer need to enable chrono to use 1s 1000 ms, etc. Can we assume that it is always enabled on all platforms? Or more generally, does the standard mean which headings should include standard headings?

+4
source share
1 answer

, . , . [thread.threads] , #include. , , , ., , [bitset].

, thread TDM GCC 4.9.2 , iosfwd exception.

GCC 5, GCC 7, GCC , algorithm numeric.

#include <algorithm>
#include <vector>

int main()
{
    std::vector<int> v = {1,2,3,4};
    int sum = std::accumulate(std::begin(v), std::end(v), int{0});
}

, .

+7

Source: https://habr.com/ru/post/1683210/


All Articles