Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » Linking in the std library
Re: Linking in the std library [message #60727 is a reply to message #60720] Sun, 04 August 2024 17:08 Go to previous messageGo to previous message
koldo is currently offline  koldo
Messages: 3432
Registered: August 2008
Senior Veteran
Hi Awksed

I have tried the code in the second answer here (enclosed below) and it has worked in CLANG (W10 and W11) and MSVC (W10):

#include <iostream>
#include <chrono>
#include <thread>

int main()
{
    using namespace std::literals;
    namespace chrono = std::chrono;
    using clock_type = chrono::high_resolution_clock;

    auto start = clock_type::now();

    for(;;) {
        auto first = clock_type::now();

        // note use of literal - this is c++14
        std::this_thread::sleep_for(500ms);

        // c++11 would be this:
        //        std::this_thread::sleep_for(chrono::milliseconds(500));

        auto last = clock_type::now();
        auto interval = last - first;
        auto total = last - start;

        // integer cast
        std::cout << "we just slept for " << chrono::duration_cast<chrono::milliseconds>(interval).count() << "ms\n";

        // another integer cast
        std::cout << "also known as " << chrono::duration_cast<chrono::nanoseconds>(interval).count() << "ns\n";

        // floating point cast
        using seconds_fp = chrono::duration<double, chrono::seconds::period>;
        std::cout << "which is " << chrono::duration_cast<seconds_fp>(interval).count() << " seconds\n";

        std::cout << "  total time wasted: " << chrono::duration_cast<chrono::milliseconds>(total).count() << "ms\n";
        std::cout << "         in seconds: " << chrono::duration_cast<seconds_fp>(total).count() << "s\n";


        std::cout << std::endl;
    }
    return 0;
}


Best regards
IƱaki
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Shell variable substitution in package configuration flags
Next Topic: 17045 now refuses to build
Goto Forum:
  


Current Time: Mon Apr 28 23:08:19 CEST 2025

Total time taken to generate the page: 0.04271 seconds