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

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Function template extract_or_default

boost::log::extract_or_default

Synopsis

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


template<typename T, typename TagT = void, typename DefaultT> 
  result_of::extract_or_default< T, DefaultT, TagT >::type 
  extract_or_default(attribute_name const & name, record const & rec, 
                     DefaultT const & def_val);

Description

The function extracts an attribute value from the view. The user has to explicitly specify the type or set of possible types of the attribute value to be visited.

[Note] Note

Caution must be exercised if the default value is a temporary object. Because the function returns a reference, if the temporary object is destroyed, the reference may become dangling.

Parameters:

def_val

The default value

name

The name of the attribute value to extract.

rec

A log record. The attribute value will be sought among those associated with the record.

Returns:

The extracted value, if found. The default value otherwise.


PrevUpHomeNext