## 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.

      // construct/copy/destruct
      attribute_name() noexcept;
      attribute_name(const char *);
      attribute_name(string_type const &);

      // public member functions
      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 construct/copy/destruct

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

### `attribute_name` public member functions

1.     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.

2.     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.

3.     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.

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

   Compares the attribute names

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

5.     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.

6.     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.

7.     explicit operator bool() const noexcept;

   Checks if the object was default-constructed

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

8.     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

9.     id_type id() const noexcept;

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

10.     string_type const & string() const;

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