Skip to content

Instantly share code, notes, and snippets.

@ppLorins
Last active November 25, 2018 10:17
Show Gist options
  • Save ppLorins/c16331a8119504b491077158ed26957c to your computer and use it in GitHub Desktop.
Save ppLorins/c16331a8119504b491077158ed26957c to your computer and use it in GitHub Desktop.
A std::chrono::nanoseconds issue found under MSVC.
#include <stdio>
#include <chrono>
/* Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x86 */
int main(int argc, char** argv)
{
//auto _nano = std::chrono::nanoseconds(3 * 1000 * 1000 * 1000); //wrong
auto _nano = std::chrono::duration<uint32_t, std::ratio<1, 1000000000>>(3 * 1000 * 1000 * 1000); //right
std::cout << _nano.count() << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment