1// boost auto_timers_construction.cpp ------------------------------------------------//
2
3// Copyright Beman Dawes 2007, 2011
4
5// Distributed under the Boost Software License, Version 1.0.
6// See http://www.boost.org/LICENSE_1_0.txt)
7
8// See http://www.boost.org/libs/timer for documentation.
9
10//--------------------------------------------------------------------------------------//
11
12// These constructors are in a separate file so that this translation unit will
13// not be linked in except when one of the constructors is actually used. This
14// is important since header <iostream> is required, and it incurs the cost of
15// the standard stream objects even if they are not used.
16
17//--------------------------------------------------------------------------------------//
18
19// define BOOST_TIMER_SOURCE so that <boost/timer/config.hpp> knows
20// the library is being built (possibly exporting rather than importing code)
21#ifndef BOOST_TIMER_SOURCE
22# define BOOST_TIMER_SOURCE
23#endif
24
25#include <boost/timer/timer.hpp>
26#include <iostream>
27
28namespace
29{
30 // CAUTION: must be identical to same constant in cpu_timer.cpp
31 const std::string default_fmt(" %ws wall, %us user + %ss system = %ts CPU (%p%)\n");
32}
33
34namespace boost
35{
36 namespace timer
37 {
38 auto_cpu_timer::auto_cpu_timer(short places) // #1
39 : m_places(places), m_os(&std::cout), m_format(default_fmt) { start(); }
40
41 auto_cpu_timer::auto_cpu_timer(short places, const std::string& format) // #2
42 : m_places(places), m_os(&std::cout), m_format(format) { start(); }
43
44 auto_cpu_timer::auto_cpu_timer(const std::string& format) // #3
45 : m_places(default_places), m_os(&std::cout), m_format(format) { start(); }
46
47 } // namespace timer
48} // namespace boost
49

source code of boost/libs/timer/src/auto_timers_construction.cpp