Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Class template basic_clock

boost::log::attributes::basic_clock — A class of an attribute that makes an attribute value of the current date and time.


// In header: <boost/log/attributes/clock.hpp>

template<typename TimeTraitsT> 
class basic_clock : public attribute {
  // types
  typedef TimeTraitsT::time_type value_type;  // Generated value type. 

  // member classes/structs/unions

  // Attribute factory implementation.

  struct impl : public attribute::impl {

    // public member functions
    virtual attribute_value get_value();

  // construct/copy/destruct
  explicit basic_clock(cast_source const &);


The attribute generates current time stamp as a value. The type of the attribute value is determined with time traits passed to the class template as a template parameter. The time traits provided by the library use boost::posix_time::ptime as the time type.

Time traits also determine the way time is acquired. There are two types of time traits provided by the library: utc_time_traits and local_time_traits. The first returns UTC time, the second returns local time.

basic_clock public construct/copy/destruct

  1. basic_clock();

    Default constructor

  2. explicit basic_clock(cast_source const & source);

    Constructor for casting support