1// stopclock_perf.cpp ---------------------------------------------------//
2
3// Copyright 2009 Vicente J. Botet Escriba
4// Copyright 2009 Howard Hinnant
5
6// Distributed under the Boost Software License, Version 1.0.
7// See http://www.boost.org/LICENSE_1_0.txt
8
9// See http://www.boost.org/libs/chrono for documentation.
10
11#ifndef BOOST_CHRONO_CLOCK_NAME_HPP
12#define BOOST_CHRONO_CLOCK_NAME_HPP
13
14#include <boost/chrono/chrono.hpp>
15#include <boost/type_traits/is_same.hpp>
16
17template <typename Clock,
18 bool = boost::is_same<Clock, boost::chrono::system_clock>::value,
19#ifdef BOOST_CHRONO_HAS_CLOCK_STEADY
20 bool = boost::is_same<Clock, boost::chrono::steady_clock>::value,
21#else
22 bool = false,
23#endif
24 bool = boost::is_same<Clock, boost::chrono::high_resolution_clock>::value
25 >
26struct name;
27
28template <typename Clock>
29struct name<Clock, false, false, false> {
30 static const char* apply() { return "unknown clock";}
31};
32
33template <typename Clock>
34struct name<Clock, true, false, false> {
35 static const char* apply() { return "system_clock";}
36};
37
38template <typename Clock>
39struct name<Clock, false, true, false> {
40 static const char* apply() { return "steady_clock";}
41};
42
43template <typename Clock>
44struct name<Clock, false, false, true> {
45 static const char* apply() { return "high_resolution_clock";}
46};
47
48template <typename Clock>
49struct name<Clock, false, true, true> {
50 static const char* apply() { return "steady_clock and high_resolution_clock";}
51};
52
53template <typename Clock>
54struct name<Clock, true, false, true> {
55 static const char* apply() { return "system_clock and high_resolution_clock";}
56};
57
58template <typename Clock>
59struct name<Clock, true, true, false> {
60 static const char* apply() { return "system_clock and steady_clock";}
61};
62
63template <typename Clock>
64struct name<Clock, true, true, true> {
65 static const char* apply() { return "system_clock, steady_clock and high_resolution_clock";}
66};
67
68#endif
69

source code of boost/libs/chrono/example/clock_name.hpp