## Class attribute_name

boost::log::attribute_name — The class represents an attribute name in containers used by the library.

## Synopsis

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

    class attribute_name {
    public:
      // types
      typedef std::string string_type;  // String type.
      typedef unspecified id_type;      // Associated identifier.

      // public member functions
      attribute_name() noexcept;
      attribute_name(const char *);
      attribute_name(string_type const &);
      bool operator==(attribute_name const &) const noexcept;
      bool operator!=(attribute_name const &) const noexcept;
      bool operator==(const char *) const;
      bool operator!=(const char *) const;
      bool operator==(string_type const &) const;
      bool operator!=(string_type const &) const;
      explicit operator bool() const noexcept;
      bool operator!() const noexcept;
      id_type id() const noexcept;
      string_type const & string() const;
    };

## Description

The class mostly serves for optimization purposes. Each attribute name that is used with the library is automatically associated with a unique identifier, which is much lighter in terms of memory footprint and operations complexity. This is done transparently by this class, on object construction. Passing objects of this class to other library methods, such as attribute lookup functions, will not require this translation and/or string copying and thus will result in a more efficient code.

### `attribute_name` public member functions

1.     attribute_name() noexcept;

   Default constructor. Creates an object that does not refer to any attribute name.

2.     attribute_name(const char * name);

   Constructs an attribute name from the specified string

   Parameters:

   `name` | An attribute name

   Requires: | name is not NULL and points to a zero-terminated string

3.     attribute_name(string_type const & name);

   Constructs an attribute name from the specified string

   Parameters:

   `name` | An attribute name

4.     bool operator==(attribute_name const & that) const noexcept;

   Compares the attribute names

   Returns: | `true` if `*this` and `that` refer to the same attribute name, and `false` otherwise.

5.     bool operator!=(attribute_name const & that) const noexcept;

   Compares the attribute names

   Returns: | `true` if `*this` and `that` refer to different attribute names, and `false` otherwise.

6.     bool operator==(const char * that) const;

   Compares the attribute names

   Returns: | `true` if `*this` and `that` refer to the same attribute name, and `false` otherwise.

7.     bool operator!=(const char * that) const;

   Compares the attribute names

   Returns: | `true` if `*this` and `that` refer to different attribute names, and `false` otherwise.

8.     bool operator==(string_type const & that) const;

   Compares the attribute names

   Returns: | `true` if `*this` and `that` refer to the same attribute name, and `false` otherwise.

9.     bool operator!=(string_type const & that) const;

   Compares the attribute names

   Returns: | `true` if `*this` and `that` refer to different attribute names, and `false` otherwise.

10.     explicit operator bool() const noexcept;

    Checks if the object was default-constructed

    Returns: | `true` if `*this` was constructed with an attribute name, `false` otherwise

11.     bool operator!() const noexcept;

    Checks if the object was default-constructed

    Returns: | `true` if `*this` was default-constructed and does not refer to any attribute name, `false` otherwise

12.     id_type id() const noexcept;

    Requires: | `(!*this) == false`
    Returns: | The associated id value

13.     string_type const & string() const;

    Requires: | `(!*this) == false`
    Returns: | The attribute name string that was used during the object construction