apply_operation.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. Copyright 2005-2007 Adobe Systems Incorporated
  3. Use, modification and distribution are subject to the Boost Software License,
  4. Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt).
  6. See http://opensource.adobe.com/gil for most recent version including documentation.
  7. */
  8. /*************************************************************************************************/
  9. #ifndef GIL_APPLY_OPERATION_HPP
  10. #define GIL_APPLY_OPERATION_HPP
  11. ////////////////////////////////////////////////////////////////////////////////////////
  12. /// \file
  13. /// \brief Implements apply_operation for variants. Optionally performs type reduction
  14. /// \author Lubomir Bourdev and Hailin Jin \n
  15. /// Adobe Systems Incorporated
  16. /// \date 2005-2007 \n Last updated on May 4, 2006
  17. ///
  18. ////////////////////////////////////////////////////////////////////////////////////////
  19. #include "apply_operation_base.hpp"
  20. #include "variant.hpp"
  21. #ifndef GIL_REDUCE_CODE_BLOAT
  22. namespace boost { namespace gil {
  23. /// \ingroup Variant
  24. /// \brief Invokes a generic mutable operation (represented as a unary function object) on a variant
  25. template <typename Types, typename UnaryOp> GIL_FORCEINLINE
  26. typename UnaryOp::result_type apply_operation(variant<Types>& arg, UnaryOp op) {
  27. return apply_operation_base<Types>(arg._bits, arg._index ,op);
  28. }
  29. /// \ingroup Variant
  30. /// \brief Invokes a generic constant operation (represented as a unary function object) on a variant
  31. template <typename Types, typename UnaryOp> GIL_FORCEINLINE
  32. typename UnaryOp::result_type apply_operation(const variant<Types>& arg, UnaryOp op) {
  33. return apply_operation_basec<Types>(arg._bits, arg._index ,op);
  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> GIL_FORCEINLINE
  38. typename BinaryOp::result_type apply_operation(const variant<Types1>& arg1, const variant<Types2>& arg2, BinaryOp op) {
  39. return apply_operation_base<Types1,Types2>(arg1._bits, arg1._index, arg2._bits, arg2._index, op);
  40. }
  41. } } // namespace boost::gil
  42. #else
  43. #include "reduce.hpp"
  44. #endif
  45. #endif