Boost C++ Libraries

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

PrevUpHomeNext

Class template counter

boost::log::attributes::counter — A class of an attribute that counts an integral value.

Synopsis

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

template<typename T> 
class counter : public attribute {
public:
  // types
  typedef T value_type;  // A counter value type. 

  // member classes/structs/unions

  // Factory implementation.

  class impl : public attribute::impl {
  public:

    // public member functions
    impl(value_type, value_type) noexcept;
    virtual attribute_value get_value();
  };

  // public member functions
  explicit counter(value_type = (value_type) 0, value_type = (value_type) 1);
  explicit counter(cast_source const &);
};

Description

This attribute acts as a counter - it returns a monotonously changing value each time requested. The attribute value type can be specified as a template parameter. The type must be an integral type.

counter public member functions

  1. explicit counter(value_type initial = (value_type) 0, 
                     value_type step = (value_type) 1);

    Constructor

    Parameters:

    initial

    Initial value of the counter

    step

    Changing step of the counter. Each value acquired from the attribute will be greater than the previous one by this amount.

  2. explicit counter(cast_source const & source);

    Constructor for casting support


PrevUpHomeNext