2 // Copyright 2005-2007 Adobe Systems Incorporated
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
8 #ifndef BOOST_GIL_EXTENSION_DYNAMIC_IMAGE_APPLY_OPERATION_HPP
9 #define BOOST_GIL_EXTENSION_DYNAMIC_IMAGE_APPLY_OPERATION_HPP
11 #include <boost/variant/apply_visitor.hpp>
13 #ifdef BOOST_GIL_DOXYGEN_ONLY
14 #undef BOOST_GIL_REDUCE_CODE_BLOAT
17 // Implements apply_operation for variants.
18 // Optionally performs type reduction.
19 #ifdef BOOST_GIL_REDUCE_CODE_BLOAT
21 #include <boost/gil/extension/dynamic_image/reduce.hpp>
25 namespace boost { namespace gil {
28 /// \brief Invokes a generic mutable operation (represented as a unary function object) on a variant
29 template <typename Types, typename UnaryOp>
31 auto apply_operation(variant<Types>& arg, UnaryOp op)
32 #if defined(BOOST_NO_CXX14_DECLTYPE_AUTO) || defined(BOOST_NO_CXX11_DECLTYPE_N3276)
33 -> typename UnaryOp::result_type
36 return apply_visitor(op, arg);
40 /// \brief Invokes a generic constant operation (represented as a unary function object) on a variant
41 template <typename Types, typename UnaryOp>
43 auto apply_operation(variant<Types> const& arg, UnaryOp op)
44 #if defined(BOOST_NO_CXX14_DECLTYPE_AUTO) || defined(BOOST_NO_CXX11_DECLTYPE_N3276)
45 -> typename UnaryOp::result_type
48 return apply_visitor(op, arg);
52 /// \brief Invokes a generic constant operation (represented as a binary function object) on two variants
53 template <typename Types1, typename Types2, typename BinaryOp>
56 variant<Types1> const& arg1,
57 variant<Types2> const& arg2,
59 #if defined(BOOST_NO_CXX14_DECLTYPE_AUTO) || defined(BOOST_NO_CXX11_DECLTYPE_N3276)
60 -> typename BinaryOp::result_type
67 }} // namespace boost::gil
69 #endif // defined(BOOST_GIL_REDUCE_CODE_BLOAT)