Boost GIL


apply_operation.hpp
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 
11 #include <boost/gil/detail/mp11.hpp>
12 
13 #include <boost/variant/apply_visitor.hpp>
14 
15 namespace boost { namespace gil {
16 
19 template <typename Types, typename UnaryOp>
20 BOOST_FORCEINLINE
21 auto apply_operation(variant<Types>& arg, UnaryOp op)
22 #if defined(BOOST_NO_CXX14_DECLTYPE_AUTO) || defined(BOOST_NO_CXX11_DECLTYPE_N3276)
23  -> typename UnaryOp::result_type
24 #endif
25 {
26  return apply_visitor(op, arg);
27 }
28 
31 template <typename Types, typename UnaryOp>
32 BOOST_FORCEINLINE
33 auto apply_operation(variant<Types> const& arg, UnaryOp op)
34 #if defined(BOOST_NO_CXX14_DECLTYPE_AUTO) || defined(BOOST_NO_CXX11_DECLTYPE_N3276)
35  -> typename UnaryOp::result_type
36 #endif
37 {
38  return apply_visitor(op, arg);
39 }
40 
43 template <typename Types1, typename Types2, typename BinaryOp>
44 BOOST_FORCEINLINE
46  variant<Types1> const& arg1,
47  variant<Types2> const& arg2,
48  BinaryOp op)
49 #if defined(BOOST_NO_CXX14_DECLTYPE_AUTO) || defined(BOOST_NO_CXX11_DECLTYPE_N3276)
50  -> typename BinaryOp::result_type
51 #endif
52 {
53  return apply_visitor(op, arg1, arg2);
54 }
55 
56 }} // namespace boost::gil
57 
58 #endif
BOOST_FORCEINLINE auto apply_operation(variant< Types1 > const &arg1, variant< Types2 > const &arg2, BinaryOp op)
Invokes a generic constant operation (represented as a binary function object) on two variants.
Definition: apply_operation.hpp:45