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/gil/detail/mp11.hpp>
13 #include <boost/variant/apply_visitor.hpp>
15 #ifdef BOOST_GIL_DOXYGEN_ONLY
16 #undef BOOST_GIL_REDUCE_CODE_BLOAT
19 // Implements apply_operation for variants.
20 // Optionally performs type reduction.
21 #ifdef BOOST_GIL_REDUCE_CODE_BLOAT
23 #include <boost/gil/extension/dynamic_image/reduce.hpp>
27 namespace boost { namespace gil {
30 /// \brief Invokes a generic mutable operation (represented as a unary function object) on a variant
31 template <typename Types, typename UnaryOp>
33 auto apply_operation(variant<Types>& arg, UnaryOp op)
34 #if defined(BOOST_NO_CXX14_DECLTYPE_AUTO) || defined(BOOST_NO_CXX11_DECLTYPE_N3276)
35 -> typename UnaryOp::result_type
38 return apply_visitor(op, arg);
42 /// \brief Invokes a generic constant operation (represented as a unary function object) on a variant
43 template <typename Types, typename UnaryOp>
45 auto apply_operation(variant<Types> const& arg, UnaryOp op)
46 #if defined(BOOST_NO_CXX14_DECLTYPE_AUTO) || defined(BOOST_NO_CXX11_DECLTYPE_N3276)
47 -> typename UnaryOp::result_type
50 return apply_visitor(op, arg);
54 /// \brief Invokes a generic constant operation (represented as a binary function object) on two variants
55 template <typename Types1, typename Types2, typename BinaryOp>
58 variant<Types1> const& arg1,
59 variant<Types2> const& arg2,
61 #if defined(BOOST_NO_CXX14_DECLTYPE_AUTO) || defined(BOOST_NO_CXX11_DECLTYPE_N3276)
62 -> typename BinaryOp::result_type
65 return apply_visitor(op, arg1, arg2);
68 }} // namespace boost::gil
70 #endif // defined(BOOST_GIL_REDUCE_CODE_BLOAT)