...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::log::fallback_to_default
// In header: <boost/log/attributes/fallback_policy.hpp> template<typename DefaultT> struct fallback_to_default { // types typedef remove_cv< typenameremove_reference< DefaultT >::type >::type default_type; // Default value type. enum { guaranteed_result = true }; // public member functions fallback_to_default(); explicit fallback_to_default(default_type const &); template<typename FunT> bool apply_default(FunT &) const; template<typename FunT> bool apply_default(FunT const &) const; // public static functions static void on_invalid_type(typeindex::type_index const &); static void on_missing_value(); };
The fallback_to_default
policy results in a default value if the attribute value cannot be extracted.
fallback_to_default
public member functionsfallback_to_default();
Default constructor.
explicit fallback_to_default(default_type const & def_val);
Initializing constructor.
template<typename FunT> bool apply_default(FunT & fun) const;
The method is called in order to apply a function object to the default value.
template<typename FunT> bool apply_default(FunT const & fun) const;
The method is called in order to apply a function object to the default value.