bind_assign.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright Andrey Semashev 2007 - 2015.
  3. * Distributed under the Boost Software License, Version 1.0.
  4. * (See accompanying file LICENSE_1_0.txt or copy at
  5. * http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. /*!
  8. * \file bind_assign.hpp
  9. * \author Andrey Semashev
  10. * \date 30.03.2008
  11. *
  12. * This header contains a function object that assigns the received value to the bound object.
  13. * This is a lightweight alternative to what Boost.Phoenix and Boost.Lambda provides.
  14. */
  15. #ifndef BOOST_LOG_UTILITY_FUNCTIONAL_BIND_ASSIGN_HPP_INCLUDED_
  16. #define BOOST_LOG_UTILITY_FUNCTIONAL_BIND_ASSIGN_HPP_INCLUDED_
  17. #include <boost/log/detail/config.hpp>
  18. #include <boost/log/utility/functional/bind.hpp>
  19. #include <boost/log/detail/header.hpp>
  20. #ifdef BOOST_HAS_PRAGMA_ONCE
  21. #pragma once
  22. #endif
  23. namespace boost {
  24. BOOST_LOG_OPEN_NAMESPACE
  25. //! The function object that assigns its second operand to the first one
  26. struct assign_fun
  27. {
  28. typedef void result_type;
  29. template< typename LeftT, typename RightT >
  30. void operator() (LeftT& assignee, RightT const& val) const
  31. {
  32. assignee = val;
  33. }
  34. };
  35. template< typename AssigneeT >
  36. BOOST_FORCEINLINE binder1st< assign_fun, AssigneeT& > bind_assign(AssigneeT& assignee)
  37. {
  38. return binder1st< assign_fun, AssigneeT& >(assign_fun(), assignee);
  39. }
  40. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  41. } // namespace boost
  42. #include <boost/log/detail/footer.hpp>
  43. #endif // BOOST_LOG_UTILITY_FUNCTIONAL_BIND_ASSIGN_HPP_INCLUDED_