/usr/include/boost/log/attributes/function.hpp is in libboost1.54-dev 1.54.0-4ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | /*
* Copyright Andrey Semashev 2007 - 2013.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*/
/*!
* \file function.hpp
* \author Andrey Semashev
* \date 24.06.2007
*
* The header contains implementation of an attribute that calls a third-party function on value acquisition.
*/
#ifndef BOOST_LOG_ATTRIBUTES_FUNCTION_HPP_INCLUDED_
#define BOOST_LOG_ATTRIBUTES_FUNCTION_HPP_INCLUDED_
#include <boost/static_assert.hpp>
#include <boost/utility/result_of.hpp>
#include <boost/type_traits/is_void.hpp>
#include <boost/type_traits/remove_cv.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <boost/log/detail/config.hpp>
#include <boost/log/attributes/attribute.hpp>
#include <boost/log/attributes/attribute_cast.hpp>
#include <boost/log/attributes/attribute_value_impl.hpp>
#include <boost/log/detail/header.hpp>
#ifdef BOOST_LOG_HAS_PRAGMA_ONCE
#pragma once
#endif
namespace boost {
BOOST_LOG_OPEN_NAMESPACE
namespace attributes {
/*!
* \brief A class of an attribute that acquires its value from a third-party function object
*
* The attribute calls a stored nullary function object to acquire each value.
* The result type of the function object is the attribute value type.
*
* It is not recommended to use this class directly. Use \c make_function convenience functions
* to construct the attribute instead.
*/
template< typename R >
class function :
public attribute
{
BOOST_STATIC_ASSERT_MSG(!is_void< R >::value, "Boost.Log: Function object return type must not be void");
public:
//! The attribute value type
typedef R value_type;
protected:
//! Base class for factory implementation
class BOOST_LOG_NO_VTABLE BOOST_LOG_VISIBLE impl :
public attribute::impl
{
};
//! Factory implementation
template< typename T >
class impl_template :
public impl
{
private:
//! Functor that returns attribute values
/*!
* \note The constness signifies that the function object should avoid
* modifying its state since it's not protected against concurrent calls.
*/
const T m_Functor;
public:
/*!
* Constructor with the stored delegate initialization
*/
explicit impl_template(T const& fun) : m_Functor(fun) {}
attribute_value get_value()
{
return attributes::make_attribute_value(m_Functor());
}
};
public:
/*!
* Initializing constructor
*/
template< typename T >
explicit function(T const& fun) : attribute(new impl_template< T >(fun))
{
}
/*!
* Constructor for casting support
*/
explicit function(cast_source const& source) :
attribute(source.as< impl >())
{
}
};
#ifndef BOOST_NO_RESULT_OF
/*!
* The function constructs \c function attribute instance with the provided function object.
*
* \param fun Nullary functional object that returns an actual stored value for an attribute value.
* \return Pointer to the attribute instance
*/
template< typename T >
inline function<
typename remove_cv<
typename remove_reference<
typename boost::result_of< T() >::type
>::type
>::type
> make_function(T const& fun)
{
typedef typename remove_cv<
typename remove_reference<
typename boost::result_of< T() >::type
>::type
>::type result_type;
typedef function< result_type > function_type;
return function_type(fun);
}
#endif // BOOST_NO_RESULT_OF
#ifndef BOOST_LOG_DOXYGEN_PASS
/*!
* The function constructs \c function attribute instance with the provided function object.
* Use this version if your compiler fails to determine the result type of the function object.
*
* \param fun Nullary functional object that returns an actual stored value for an attribute value.
* \return Pointer to the attribute instance
*/
template< typename R, typename T >
inline function<
typename remove_cv<
typename remove_reference< R >::type
>::type
> make_function(T const& fun)
{
typedef typename remove_cv<
typename remove_reference< R >::type
>::type result_type;
typedef function< result_type > function_type;
return function_type(fun);
}
#endif // BOOST_LOG_DOXYGEN_PASS
} // namespace attributes
BOOST_LOG_CLOSE_NAMESPACE // namespace log
} // namespace boost
#include <boost/log/detail/footer.hpp>
#endif // BOOST_LOG_ATTRIBUTES_FUNCTOR_HPP_INCLUDED_
|