- chrono[meta header]
- std::chrono_literals[meta namespace]
- function[meta id-type]
- cpp14[meta cpp]
namespace std {
inline namespace literals {
inline namespace chrono_literals {
constexpr chrono::nanoseconds
operator "" ns(unsigned long long x); // (1)
constexpr chrono::duration<unspecified, nano>
operator "" ns(long double x); // (2)
}}
namespace chrono {
using namespace literals::chrono_literals;
} // namespace chrono
} // namespace std
- nano[link /reference/ratio/si_prefix.md]
- unspecified[italic]
ナノ秒単位の値を表すduration
クラスのリテラル。
- (1) : 整数型のナノ秒リテラル
- (2) : 浮動小数点型のナノ秒リテラル
- (1) :
chrono::nanoseconds(x)
- (2) :
chrono::duration<unspecified, nano>(x)
#include <iostream>
#include <chrono>
int main()
{
using namespace std::literals::chrono_literals;
auto nanoseconds_i = 3ns; // 整数型の3ナノ秒
auto nanoseconds_f = 3.1ns; // 浮動小数点型の3.1ナノ秒
std::cout << nanoseconds_i.count() << std::endl;
std::cout << nanoseconds_f.count() << std::endl;
}
- 3ns[color ff0000]
- 3.1ns[color ff0000]
- count()[link count.md]
3
3.1
- C++14
- Clang: 3.4
- GCC: 4.9.0
- ICC: ??
- Visual C++: 2015