apply_operation.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // Copyright 2005-2007 Adobe Systems Incorporated
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. #ifndef BOOST_GIL_EXTENSION_DYNAMIC_IMAGE_APPLY_OPERATION_HPP
  9. #define BOOST_GIL_EXTENSION_DYNAMIC_IMAGE_APPLY_OPERATION_HPP
  10. #include <boost/gil/detail/mp11.hpp>
  11. #include <boost/variant/apply_visitor.hpp>
  12. namespace boost { namespace gil {
  13. /// \ingroup Variant
  14. /// \brief Invokes a generic mutable operation (represented as a unary function object) on a variant
  15. template <typename Types, typename UnaryOp>
  16. BOOST_FORCEINLINE
  17. auto apply_operation(variant<Types>& arg, UnaryOp op)
  18. #if defined(BOOST_NO_CXX14_DECLTYPE_AUTO) || defined(BOOST_NO_CXX11_DECLTYPE_N3276)
  19. -> typename UnaryOp::result_type
  20. #endif
  21. {
  22. return apply_visitor(op, arg);
  23. }
  24. /// \ingroup Variant
  25. /// \brief Invokes a generic constant operation (represented as a unary function object) on a variant
  26. template <typename Types, typename UnaryOp>
  27. BOOST_FORCEINLINE
  28. auto apply_operation(variant<Types> const& arg, UnaryOp op)
  29. #if defined(BOOST_NO_CXX14_DECLTYPE_AUTO) || defined(BOOST_NO_CXX11_DECLTYPE_N3276)
  30. -> typename UnaryOp::result_type
  31. #endif
  32. {
  33. return apply_visitor(op, arg);
  34. }
  35. /// \ingroup Variant
  36. /// \brief Invokes a generic constant operation (represented as a binary function object) on two variants
  37. template <typename Types1, typename Types2, typename BinaryOp>
  38. BOOST_FORCEINLINE
  39. auto apply_operation(
  40. variant<Types1> const& arg1,
  41. variant<Types2> const& arg2,
  42. BinaryOp op)
  43. #if defined(BOOST_NO_CXX14_DECLTYPE_AUTO) || defined(BOOST_NO_CXX11_DECLTYPE_N3276)
  44. -> typename BinaryOp::result_type
  45. #endif
  46. {
  47. return apply_visitor(op, arg1, arg2);
  48. }
  49. }} // namespace boost::gil
  50. #endif