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 type_info_wrapper

boost::log::type_info_wrapper — A simple std::type_info wrapper that implements value semantic for type information objects.

Synopsis

// In header: <boost/log/utility/type_info_wrapper.hpp>


class type_info_wrapper {
public:
  // construct/copy/destruct
  type_info_wrapper();
  type_info_wrapper(type_info_wrapper const &);
  type_info_wrapper(std::type_info const &);

  // public member functions
  explicit operator bool() const;
  std::type_info const & get() const;
  void swap(type_info_wrapper &);
  std::string pretty_name() const;
  bool operator!() const;
  bool operator==(type_info_wrapper const &) const;
  bool operator<(type_info_wrapper const &) const;
};

Description

The type info wrapper is very useful for storing type information objects in containers, as a key or value. It also provides a number of useful features, such as default construction and assignment support, an empty state and extended support for human-friendly type names.

type_info_wrapper public construct/copy/destruct

  1. type_info_wrapper();

    Default constructor

    Postconditions:

    !*this == true

  2. type_info_wrapper(type_info_wrapper const & that);

    Copy constructor

    Parameters:

    that

    Source type info wrapper to copy from

    Postconditions:

    *this == that

  3. type_info_wrapper(std::type_info const & that);

    Conversion constructor

    Parameters:

    that

    Type info object to be wrapped

    Postconditions:

    *this == that && !!*this

type_info_wrapper public member functions

  1. explicit operator bool() const;

    Returns:

    true if the type info wrapper was initialized with a particular type, false if the wrapper was default-constructed and not yet initialized

  2. std::type_info const & get() const;

    Stored type info getter

    Requires:

    !!*this

    Returns:

    Constant reference to the wrapped type info object

  3. void swap(type_info_wrapper & that);

    Swaps two instances of the wrapper

  4. std::string pretty_name() const;

    The method returns the contained type name string in a possibly more readable format than get().name()

    Requires:

    !!*this

    Returns:

    Type name string

  5. bool operator!() const;

    Returns:

    false if the type info wrapper was initialized with a particular type, true if the wrapper was default-constructed and not yet initialized

  6. bool operator==(type_info_wrapper const & that) const;

    Equality comparison

    Parameters:

    that

    Comparand

    Returns:

    If either this object or comparand is in empty state and the other is not, the result is false. If both arguments are empty, the result is true. If both arguments are not empty, the result is true if this object wraps the same type as the comparand and false otherwise.

  7. bool operator<(type_info_wrapper const & that) const;

    Ordering operator

    [Note] Note

    The results of this operator are only consistent within a single run of application. The result may change for the same types after rebuilding or even restarting the application.

    Parameters:

    that

    Comparand

    Requires:

    !!*this && !!that

    Returns:

    true if this object wraps type info object that is ordered before the type info object in the comparand, false otherwise


PrevUpHomeNext