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/extension/dynamic_image/apply_operation_base.hpp>
12 #include <boost/gil/extension/dynamic_image/variant.hpp>
13 
14 #ifdef BOOST_GIL_DOXYGEN_ONLY
15 #undef BOOST_GIL_REDUCE_CODE_BLOAT
16 #endif
17 
18 // Implements apply_operation for variants.
19 // Optionally performs type reduction.
20 #ifdef BOOST_GIL_REDUCE_CODE_BLOAT
21 
22 #include <boost/gil/extension/dynamic_image/reduce.hpp>
23 
24 #else
25 
26 namespace boost { namespace gil {
27 
30 template <typename Types, typename UnaryOp>
31 BOOST_FORCEINLINE
32 auto apply_operation(variant<Types>& arg, UnaryOp op)
33  -> typename UnaryOp::result_type
34 {
35  return apply_operation_base<Types>(arg._bits, arg._index ,op);
36 }
37 
40 template <typename Types, typename UnaryOp>
41 BOOST_FORCEINLINE
42 auto apply_operation(variant<Types> const& arg, UnaryOp op)
43  -> typename UnaryOp::result_type
44 {
45  return apply_operation_basec<Types>(arg._bits, arg._index ,op);
46 }
47 
50 template <typename Types1, typename Types2, typename BinaryOp>
51 BOOST_FORCEINLINE
53  variant<Types1> const& arg1,
54  variant<Types2> const& arg2,
55  BinaryOp op)
56  -> typename BinaryOp::result_type
57 {
58  return apply_operation_base<Types1, Types2>(
59  arg1._bits, arg1._index, arg2._bits, arg2._index, op);
60 }
61 
62 }} // namespace boost::gil
63 
64 #endif // defined(BOOST_GIL_REDUCE_CODE_BLOAT)
65 
66 #endif
Represents a concrete instance of a run-time specified type from a set of typesA concept is typically...
Definition: variant.hpp:80
BOOST_FORCEINLINE auto apply_operation(variant< Types1 > const &arg1, variant< Types2 > const &arg2, BinaryOp op) -> typename BinaryOp::result_type
Invokes a generic constant operation (represented as a binary function object) on two variants...
Definition: apply_operation.hpp:52