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.

Struct sentry

boost::log::attributes::named_scope::sentry — Sentry object class to automatically push and pop scopes.


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

// Sentry object class to automatically push and pop scopes.

struct sentry {
  // construct/copy/destruct
  sentry(string_literal const &, string_literal const &, unsigned int, 
         scope_entry::scope_name_type = scope_entry::general) noexcept;
  sentry(sentry const &) = delete;
  sentry & operator=(sentry const &) = delete;


sentry public construct/copy/destruct

  1. sentry(string_literal const & sn, string_literal const & fn, unsigned int ln, 
           scope_entry::scope_name_type t = scope_entry::general) noexcept;

    Constructor. Pushes the specified scope to the end of the thread-local list of scopes.



    File name, in which the scope is located.


    Line number in the file.


    Scope name.

  2. sentry(sentry const &) = delete;
  3. sentry & operator=(sentry const &) = delete;
  4. ~sentry();

    Destructor. Removes the last pushed scope from the thread-local list of scopes.