PageRenderTime 54ms CodeModel.GetById 17ms app.highlight 29ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/gil/doc/html/g_i_l_0642.html

http://hadesmem.googlecode.com/
HTML | 295 lines | 276 code | 3 blank | 16 comment | 0 complexity | e88b0979f47cc4644a5ba4bdd8d73c61 MD5 | raw file
  1<!-- Copyright 2008 Lubomir Bourdev and Hailin Jin
  2
  3     Distributed under the Boost Software License, Version 1.0.
  4     (See accompanying file LICENSE_1_0.txt or copy at
  5     http://www.boost.org/LICENSE_1_0.txt)
  6  -->
  7
  8<!--
  9    Copyright 2005-2007 Adobe Systems Incorporated
 10    Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
 11    or a copy at http://stlab.adobe.com/licenses.html)
 12
 13    Some files are held under additional license.
 14    Please see "http://stlab.adobe.com/licenses.html" for more information.
 15-->
 16
 17<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 18        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 19<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
 20
 21<head>
 22    <TITLE>Generic Image Library: utilities.hpp Source File</TITLE>
 23    <META HTTP-EQUIV="content-type" CONTENT="text/html;charset=ISO-8859-1"/>
 24    <LINK TYPE="text/css" REL="stylesheet" HREF="adobe_source.css"/>
 25</head>
 26<body>
 27<table border="0" cellspacing="0" cellpadding="0" style='width: 100%; margin: 0; padding: 0'><tr>
 28<td width="100%" valign="top" style='padding-left: 10px; padding-right: 10px; padding-bottom: 10px'>
 29<div class="qindex"><a class="qindex" href="index.html">Modules</a> 
 30                  | <a class="qindex" href="classes.html">Alphabetical List</a> 
 31                  | <a class="qindex" href="annotated.html">Class List</a> 
 32                  | <a class="qindex" href="dirs.html">Directories</a> 
 33                  | <a class="qindex" href="files.html">File List</a> 
 34                  | <a class="qindex" href="../index.html">GIL Home Page</a> 
 35</div>
 36<!-- End Header -->
 37<!-- Generated by Doxygen 1.5.6 -->
 38  <div class="navpath"><a class="el" href="g_i_l_0076.html">boost</a>&nbsp;&raquo&nbsp;<a class="el" href="g_i_l_0079.html">gil</a>
 39  </div>
 40<div class="contents">
 41<h1>utilities.hpp</h1><a href="utilities_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
 42<a name="l00002"></a>00002 <span class="comment">    Copyright 2005-2007 Adobe Systems Incorporated</span>
 43<a name="l00003"></a>00003 <span class="comment">   </span>
 44<a name="l00004"></a>00004 <span class="comment">    Use, modification and distribution are subject to the Boost Software License,</span>
 45<a name="l00005"></a>00005 <span class="comment">    Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at</span>
 46<a name="l00006"></a>00006 <span class="comment">    http://www.boost.org/LICENSE_1_0.txt).</span>
 47<a name="l00007"></a>00007 <span class="comment"></span>
 48<a name="l00008"></a>00008 <span class="comment">    See http://opensource.adobe.com/gil for most recent version including documentation.</span>
 49<a name="l00009"></a>00009 <span class="comment">*/</span>
 50<a name="l00010"></a>00010 
 51<a name="l00011"></a>00011 <span class="comment">/*************************************************************************************************/</span>
 52<a name="l00012"></a>00012 
 53<a name="l00013"></a>00013 <span class="preprocessor">#ifndef GIL_UTILITIES_H</span>
 54<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define GIL_UTILITIES_H</span>
 55<a name="l00015"></a>00015 <span class="preprocessor"></span>
 56<a name="l00016"></a>00016 <span class="preprocessor">#include "<a class="code" href="g_i_l_0094.html" title="GIL configuration file.">gil_config.hpp</a>"</span>
 57<a name="l00017"></a>00017 <span class="preprocessor">#include &lt;functional&gt;</span>
 58<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;boost/config/no_tr1/cmath.hpp&gt;</span>
 59<a name="l00019"></a>00019 <span class="preprocessor">#include &lt;cstddef&gt;</span>
 60<a name="l00020"></a>00020 <span class="preprocessor">#include &lt;algorithm&gt;</span>
 61<a name="l00021"></a>00021 <span class="preprocessor">#include &lt;utility&gt;</span>
 62<a name="l00022"></a>00022 <span class="preprocessor">#include &lt;iterator&gt;</span>
 63<a name="l00023"></a>00023 <span class="preprocessor">#include &lt;boost/static_assert.hpp&gt;</span>
 64<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;boost/type_traits.hpp&gt;</span>
 65<a name="l00025"></a>00025 <span class="preprocessor">#include &lt;boost/mpl/size.hpp&gt;</span>
 66<a name="l00026"></a>00026 <span class="preprocessor">#include &lt;boost/mpl/distance.hpp&gt;</span>
 67<a name="l00027"></a>00027 <span class="preprocessor">#include &lt;boost/mpl/begin.hpp&gt;</span>
 68<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;boost/mpl/find.hpp&gt;</span>
 69<a name="l00029"></a>00029 <span class="preprocessor">#include &lt;boost/mpl/range_c.hpp&gt;</span>
 70<a name="l00030"></a>00030 <span class="preprocessor">#include &lt;boost/iterator/iterator_adaptor.hpp&gt;</span>
 71<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;boost/iterator/iterator_facade.hpp&gt;</span>
 72<a name="l00032"></a>00032 
 73<a name="l00042"></a>00042 
 74<a name="l00043"></a>00043 <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>gil {
 75<a name="l00044"></a>00044 
 76<a name="l00057"></a>00057 
 77<a name="l00058"></a>00058 <span class="comment">//                           CLASS point2</span>
 78<a name="l00065"></a>00065 <span class="comment"></span>
 79<a name="l00066"></a>00066 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
 80<a name="l00067"></a><a class="code" href="g_i_l_0060.html">00067</a> <span class="keyword">class </span><a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2</a> {
 81<a name="l00068"></a>00068 <span class="keyword">public</span>:
 82<a name="l00069"></a>00069     <span class="keyword">typedef</span> T value_type;
 83<a name="l00070"></a>00070     <span class="keyword">template</span> &lt;std::<span class="keywordtype">size_t</span> D&gt; <span class="keyword">struct </span>axis { <span class="keyword">typedef</span> value_type coord_t; };
 84<a name="l00071"></a>00071     <span class="keyword">static</span> <span class="keyword">const</span> std::size_t num_dimensions=2;
 85<a name="l00072"></a>00072 
 86<a name="l00073"></a>00073     <a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2</a>()                : x(0),     y(0)    {}
 87<a name="l00074"></a>00074     <a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2</a>(T newX, T newY)  : x(newX),  y(newY) {}
 88<a name="l00075"></a>00075     <a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2</a>(<span class="keyword">const</span> <a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2</a>&amp; p) : x(p.<a class="code" href="g_i_l_0060.html#9a4f74af87a76a4c3dcb729cb0e68f8d">x</a>), y(p.<a class="code" href="g_i_l_0060.html#1cb2b5ea04251d543e49356ef54eb853">y</a>) {}
 89<a name="l00076"></a>00076     ~<a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2</a>() {}
 90<a name="l00077"></a>00077 
 91<a name="l00078"></a>00078     <a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2</a>&amp; operator=(<span class="keyword">const</span> <a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2</a>&amp; p)            { x=p.<a class="code" href="g_i_l_0060.html#9a4f74af87a76a4c3dcb729cb0e68f8d">x</a>; y=p.<a class="code" href="g_i_l_0060.html#1cb2b5ea04251d543e49356ef54eb853">y</a>; <span class="keywordflow">return</span> *<span class="keyword">this</span>; }
 92<a name="l00079"></a>00079 
 93<a name="l00080"></a>00080     <a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2</a>        operator&lt;&lt;(std::ptrdiff_t shift)<span class="keyword">         const   </span>{ <span class="keywordflow">return</span> <a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2</a>(x&lt;&lt;shift,y&lt;&lt;shift); }
 94<a name="l00081"></a>00081     <a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2</a>        operator&gt;&gt;(std::ptrdiff_t shift)<span class="keyword">         const   </span>{ <span class="keywordflow">return</span> <a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2</a>(x&gt;&gt;shift,y&gt;&gt;shift); }
 95<a name="l00082"></a>00082     <a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2</a>&amp; operator+=(<span class="keyword">const</span> <a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2</a>&amp; p)           { x+=p.<a class="code" href="g_i_l_0060.html#9a4f74af87a76a4c3dcb729cb0e68f8d">x</a>; y+=p.<a class="code" href="g_i_l_0060.html#1cb2b5ea04251d543e49356ef54eb853">y</a>; <span class="keywordflow">return</span> *<span class="keyword">this</span>; }
 96<a name="l00083"></a>00083     <a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2</a>&amp; operator-=(<span class="keyword">const</span> <a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2</a>&amp; p)           { x-=p.<a class="code" href="g_i_l_0060.html#9a4f74af87a76a4c3dcb729cb0e68f8d">x</a>; y-=p.<a class="code" href="g_i_l_0060.html#1cb2b5ea04251d543e49356ef54eb853">y</a>; <span class="keywordflow">return</span> *<span class="keyword">this</span>; }
 97<a name="l00084"></a>00084     <a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2</a>&amp; operator/=(<span class="keywordtype">double</span> t)                  { x/=t; y/=t; <span class="keywordflow">return</span> *<span class="keyword">this</span>; }
 98<a name="l00085"></a>00085 
 99<a name="l00086"></a>00086     <span class="keyword">const</span> T&amp; operator[](std::size_t i)<span class="keyword">          const   </span>{ <span class="keywordflow">return</span> this-&gt;*mem_array[i]; }
100<a name="l00087"></a>00087           T&amp; operator[](std::size_t i)                  { <span class="keywordflow">return</span> this-&gt;*mem_array[i]; }
101<a name="l00088"></a>00088 
102<a name="l00089"></a>00089     T x,y;
103<a name="l00090"></a>00090 <span class="keyword">private</span>:
104<a name="l00091"></a>00091     <span class="comment">// this static array of pointers to member variables makes operator[] safe and doesn't seem to exhibit any performance penalty</span>
105<a name="l00092"></a>00092     <span class="keyword">static</span> T <a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2&lt;T&gt;</a>::* <span class="keyword">const</span> mem_array[num_dimensions];
106<a name="l00093"></a>00093 };
107<a name="l00094"></a>00094 
108<a name="l00095"></a>00095 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
109<a name="l00096"></a>00096 T <a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2&lt;T&gt;</a>::* <span class="keyword">const</span> <a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2&lt;T&gt;::mem_array</a>[<a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2&lt;T&gt;::num_dimensions</a>] = { &amp;<a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2&lt;T&gt;::x</a>, &amp;<a class="code" href="g_i_l_0060.html" title="2D point both axes of which have the same dimension typeModels: Point2DConcept">point2&lt;T&gt;::y</a> };
110<a name="l00097"></a>00097 
111<a name="l00099"></a>00099 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt; GIL_FORCEINLINE
112<a name="l00100"></a>00100 <span class="keywordtype">bool</span> operator==(<span class="keyword">const</span> point2&lt;T&gt;&amp; p1, <span class="keyword">const</span> point2&lt;T&gt;&amp; p2) { <span class="keywordflow">return</span> (p1.x==p2.x &amp;&amp; p1.y==p2.y); }
113<a name="l00102"></a>00102 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt; GIL_FORCEINLINE
114<a name="l00103"></a>00103 <span class="keywordtype">bool</span> operator!=(<span class="keyword">const</span> point2&lt;T&gt;&amp; p1, <span class="keyword">const</span> point2&lt;T&gt;&amp; p2) { <span class="keywordflow">return</span>  p1.x!=p2.x || p1.y!=p2.y; }
115<a name="l00105"></a>00105 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt; GIL_FORCEINLINE
116<a name="l00106"></a>00106 point2&lt;T&gt; operator+(<span class="keyword">const</span> point2&lt;T&gt;&amp; p1, <span class="keyword">const</span> point2&lt;T&gt;&amp; p2) { <span class="keywordflow">return</span> point2&lt;T&gt;(p1.x+p2.x,p1.y+p2.y); }
117<a name="l00108"></a>00108 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt; GIL_FORCEINLINE
118<a name="l00109"></a>00109 point2&lt;T&gt; operator-(<span class="keyword">const</span> point2&lt;T&gt;&amp; p) { <span class="keywordflow">return</span> point2&lt;T&gt;(-p.x,-p.y); }
119<a name="l00111"></a>00111 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt; GIL_FORCEINLINE
120<a name="l00112"></a>00112 point2&lt;T&gt; operator-(<span class="keyword">const</span> point2&lt;T&gt;&amp; p1, <span class="keyword">const</span> point2&lt;T&gt;&amp; p2) { <span class="keywordflow">return</span> point2&lt;T&gt;(p1.x-p2.x,p1.y-p2.y); }
121<a name="l00114"></a>00114 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt; GIL_FORCEINLINE
122<a name="l00115"></a>00115 point2&lt;double&gt; operator/(<span class="keyword">const</span> point2&lt;T&gt;&amp; p, <span class="keywordtype">double</span> t)      { <span class="keywordflow">return</span> t==0 ? point2&lt;double&gt;(0,0):point2&lt;double&gt;(p.x/t,p.y/t); }
123<a name="l00117"></a>00117 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt; GIL_FORCEINLINE
124<a name="l00118"></a>00118 point2&lt;T&gt; operator*(<span class="keyword">const</span> point2&lt;T&gt;&amp; p, std::ptrdiff_t t)      { <span class="keywordflow">return</span> point2&lt;T&gt;(p.x*t,p.y*t); }
125<a name="l00120"></a>00120 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt; GIL_FORCEINLINE
126<a name="l00121"></a>00121 point2&lt;T&gt; operator*(std::ptrdiff_t t, <span class="keyword">const</span> point2&lt;T&gt;&amp; p)      { <span class="keywordflow">return</span> point2&lt;T&gt;(p.x*t,p.y*t); }
127<a name="l00122"></a>00122 
128<a name="l00124"></a>00124 <span class="keyword">template</span> &lt;std::<span class="keywordtype">size_t</span> K, <span class="keyword">typename</span> T&gt; GIL_FORCEINLINE
129<a name="l00125"></a>00125 <span class="keyword">const</span> T&amp; axis_value(<span class="keyword">const</span> point2&lt;T&gt;&amp; p) { <span class="keywordflow">return</span> p[K]; }
130<a name="l00126"></a>00126 
131<a name="l00128"></a>00128 <span class="keyword">template</span> &lt;std::<span class="keywordtype">size_t</span> K, <span class="keyword">typename</span> T&gt; GIL_FORCEINLINE
132<a name="l00129"></a>00129       T&amp; axis_value(      point2&lt;T&gt;&amp; p) { <span class="keywordflow">return</span> p[K]; }
133<a name="l00130"></a>00130 
134<a name="l00136"></a>00136 
135<a name="l00137"></a>00137 <span class="keyword">inline</span> std::ptrdiff_t iround(<span class="keywordtype">float</span> x ) { <span class="keywordflow">return</span> <span class="keyword">static_cast&lt;</span>std::ptrdiff_t<span class="keyword">&gt;</span>(x + (x &lt; 0.0f ? -0.5f : 0.5f)); }
136<a name="l00138"></a>00138 <span class="keyword">inline</span> std::ptrdiff_t iround(<span class="keywordtype">double</span> x) { <span class="keywordflow">return</span> <span class="keyword">static_cast&lt;</span>std::ptrdiff_t<span class="keyword">&gt;</span>(x + (x &lt; 0.0 ? -0.5 : 0.5)); }
137<a name="l00139"></a>00139 <span class="keyword">inline</span> std::ptrdiff_t ifloor(<span class="keywordtype">float</span> x ) { <span class="keywordflow">return</span> <span class="keyword">static_cast&lt;</span>std::ptrdiff_t<span class="keyword">&gt;</span>(std::floor(x)); }
138<a name="l00140"></a>00140 <span class="keyword">inline</span> std::ptrdiff_t ifloor(<span class="keywordtype">double</span> x) { <span class="keywordflow">return</span> <span class="keyword">static_cast&lt;</span>std::ptrdiff_t<span class="keyword">&gt;</span>(std::floor(x)); }
139<a name="l00141"></a>00141 <span class="keyword">inline</span> std::ptrdiff_t iceil(<span class="keywordtype">float</span> x )  { <span class="keywordflow">return</span> <span class="keyword">static_cast&lt;</span>std::ptrdiff_t<span class="keyword">&gt;</span>(std::ceil(x)); }
140<a name="l00142"></a>00142 <span class="keyword">inline</span> std::ptrdiff_t iceil(<span class="keywordtype">double</span> x)  { <span class="keywordflow">return</span> <span class="keyword">static_cast&lt;</span>std::ptrdiff_t<span class="keyword">&gt;</span>(std::ceil(x)); }
141<a name="l00143"></a>00143 
142<a name="l00153"></a>00153 
143<a name="l00154"></a>00154 <span class="keyword">inline</span> point2&lt;std::ptrdiff_t&gt; iround(<span class="keyword">const</span> point2&lt;float &gt;&amp; p)  { <span class="keywordflow">return</span> point2&lt;std::ptrdiff_t&gt;(iround(p.x),iround(p.y)); }
144<a name="l00156"></a>00156 <span class="keyword">inline</span> point2&lt;std::ptrdiff_t&gt; iround(<span class="keyword">const</span> point2&lt;double&gt;&amp; p)  { <span class="keywordflow">return</span> point2&lt;std::ptrdiff_t&gt;(iround(p.x),iround(p.y)); }
145<a name="l00158"></a>00158 <span class="keyword">inline</span> point2&lt;std::ptrdiff_t&gt; ifloor(<span class="keyword">const</span> point2&lt;float &gt;&amp; p)  { <span class="keywordflow">return</span> point2&lt;std::ptrdiff_t&gt;(ifloor(p.x),ifloor(p.y)); }
146<a name="l00160"></a>00160 <span class="keyword">inline</span> point2&lt;std::ptrdiff_t&gt; ifloor(<span class="keyword">const</span> point2&lt;double&gt;&amp; p)  { <span class="keywordflow">return</span> point2&lt;std::ptrdiff_t&gt;(ifloor(p.x),ifloor(p.y)); }
147<a name="l00162"></a>00162 <span class="keyword">inline</span> point2&lt;std::ptrdiff_t&gt; iceil (<span class="keyword">const</span> point2&lt;float &gt;&amp; p)  { <span class="keywordflow">return</span> point2&lt;std::ptrdiff_t&gt;(iceil(p.x), iceil(p.y)); }
148<a name="l00164"></a>00164 <span class="keyword">inline</span> point2&lt;std::ptrdiff_t&gt; iceil (<span class="keyword">const</span> point2&lt;double&gt;&amp; p)  { <span class="keywordflow">return</span> point2&lt;std::ptrdiff_t&gt;(iceil(p.x), iceil(p.y)); }
149<a name="l00165"></a>00165 
150<a name="l00171"></a>00171 
151<a name="l00172"></a>00172 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt; 
152<a name="l00173"></a>00173 <span class="keyword">inline</span> T align(T val, std::size_t alignment) { 
153<a name="l00174"></a>00174     <span class="keywordflow">return</span> val+(alignment - val%alignment)%alignment; 
154<a name="l00175"></a>00175 }
155<a name="l00176"></a>00176 
156<a name="l00180"></a>00180 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ConstT, <span class="keyword">typename</span> Value, <span class="keyword">typename</span> Reference, <span class="keyword">typename</span> ConstReference,
157<a name="l00181"></a>00181           <span class="keyword">typename</span> ArgType, <span class="keyword">typename</span> ResultType, <span class="keywordtype">bool</span> IsMutable&gt;
158<a name="l00182"></a><a class="code" href="g_i_l_0475.html">00182</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0475.html" title="Helper base class for pixel dereference adaptors.">deref_base</a> : <span class="keyword">public</span> std::unary_function&lt;ArgType, ResultType&gt; {
159<a name="l00183"></a>00183     <span class="keyword">typedef</span> ConstT         const_t;
160<a name="l00184"></a>00184     <span class="keyword">typedef</span> Value          value_type;
161<a name="l00185"></a>00185     <span class="keyword">typedef</span> Reference      reference;
162<a name="l00186"></a>00186     <span class="keyword">typedef</span> ConstReference const_reference;
163<a name="l00187"></a>00187     BOOST_STATIC_CONSTANT(<span class="keywordtype">bool</span>, is_mutable = IsMutable);
164<a name="l00188"></a>00188 };
165<a name="l00189"></a>00189 
166<a name="l00193"></a>00193 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> D1, <span class="keyword">typename</span> D2&gt;
167<a name="l00194"></a><a class="code" href="g_i_l_0024.html">00194</a> <span class="keyword">class </span><a class="code" href="g_i_l_0024.html" title="Composes two dereference function objects. Similar to std::unary_compose but needs...">deref_compose</a> : <span class="keyword">public</span> <a class="code" href="g_i_l_0475.html" title="Helper base class for pixel dereference adaptors.">deref_base</a>&lt;
168<a name="l00195"></a>00195       deref_compose&lt;typename D1::const_t, typename D2::const_t&gt;,
169<a name="l00196"></a>00196       typename D1::value_type, typename D1::reference, typename D1::const_reference, 
170<a name="l00197"></a>00197       typename D2::argument_type, typename D1::result_type, D1::is_mutable &amp;&amp; D2::is_mutable&gt;
171<a name="l00198"></a>00198 {
172<a name="l00199"></a>00199 <span class="keyword">public</span>:
173<a name="l00200"></a>00200     D1 _fn1;
174<a name="l00201"></a>00201     D2 _fn2;
175<a name="l00202"></a>00202 
176<a name="l00203"></a>00203     <span class="keyword">typedef</span> <span class="keyword">typename</span> D2::argument_type   argument_type;
177<a name="l00204"></a>00204     <span class="keyword">typedef</span> <span class="keyword">typename</span> D1::result_type     result_type;
178<a name="l00205"></a>00205 
179<a name="l00206"></a>00206     <a class="code" href="g_i_l_0024.html" title="Composes two dereference function objects. Similar to std::unary_compose but needs...">deref_compose</a>() {}
180<a name="l00207"></a>00207     <a class="code" href="g_i_l_0024.html" title="Composes two dereference function objects. Similar to std::unary_compose but needs...">deref_compose</a>(<span class="keyword">const</span> D1&amp; x, <span class="keyword">const</span> D2&amp; y) : _fn1(x), _fn2(y) {}
181<a name="l00208"></a>00208     <a class="code" href="g_i_l_0024.html" title="Composes two dereference function objects. Similar to std::unary_compose but needs...">deref_compose</a>(<span class="keyword">const</span> <a class="code" href="g_i_l_0024.html" title="Composes two dereference function objects. Similar to std::unary_compose but needs...">deref_compose</a>&amp; dc)  : _fn1(dc.<a class="code" href="g_i_l_0024.html#fbe38941175e93403e20454f43a45371">_fn1</a>), _fn2(dc.<a class="code" href="g_i_l_0024.html#3b5402cbecf2cb062d68afeb8fca26eb">_fn2</a>) {}
182<a name="l00209"></a>00209     <span class="keyword">template</span> &lt;<span class="keyword">typename</span> _D1, <span class="keyword">typename</span> _D2&gt; <a class="code" href="g_i_l_0024.html" title="Composes two dereference function objects. Similar to std::unary_compose but needs...">deref_compose</a>(<span class="keyword">const</span> <a class="code" href="g_i_l_0024.html" title="Composes two dereference function objects. Similar to std::unary_compose but needs...">deref_compose&lt;_D1,_D2&gt;</a>&amp; dc) : _fn1(dc.<a class="code" href="g_i_l_0024.html#fbe38941175e93403e20454f43a45371">_fn1</a>), _fn2(dc.<a class="code" href="g_i_l_0024.html#3b5402cbecf2cb062d68afeb8fca26eb">_fn2</a>) {}
183<a name="l00210"></a>00210 
184<a name="l00211"></a>00211     result_type operator()(argument_type x)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _fn1(_fn2(x)); }
185<a name="l00212"></a>00212     result_type operator()(argument_type x)       { <span class="keywordflow">return</span> _fn1(_fn2(x)); }
186<a name="l00213"></a>00213 };
187<a name="l00214"></a>00214 
188<a name="l00215"></a>00215 <span class="comment">// reinterpret_cast is implementation-defined. Static cast is not.</span>
189<a name="l00216"></a>00216 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> OutPtr, <span class="keyword">typename</span> In&gt; GIL_FORCEINLINE
190<a name="l00217"></a>00217       OutPtr gil_reinterpret_cast(      In* p) { <span class="keywordflow">return</span> <span class="keyword">static_cast&lt;</span>OutPtr<span class="keyword">&gt;</span>(<span class="keyword">static_cast&lt;</span><span class="keywordtype">void</span>*<span class="keyword">&gt;</span>(p)); }
191<a name="l00218"></a>00218 
192<a name="l00219"></a>00219 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> OutPtr, <span class="keyword">typename</span> In&gt; GIL_FORCEINLINE
193<a name="l00220"></a>00220 <span class="keyword">const</span> OutPtr gil_reinterpret_cast_c(<span class="keyword">const</span> In* p) { <span class="keywordflow">return</span> <span class="keyword">static_cast&lt;</span><span class="keyword">const </span>OutPtr<span class="keyword">&gt;</span>(<span class="keyword">static_cast&lt;</span><span class="keyword">const </span><span class="keywordtype">void</span>*<span class="keyword">&gt;</span>(p)); }
194<a name="l00221"></a>00221 
195<a name="l00222"></a>00222 <span class="keyword">namespace </span>detail {
196<a name="l00223"></a>00223 
197<a name="l00229"></a>00229 
198<a name="l00230"></a>00230 <span class="keyword">template</span> &lt;<span class="keyword">class</span> InputIter, <span class="keyword">class</span> Size, <span class="keyword">class</span> OutputIter&gt;
199<a name="l00231"></a>00231 std::pair&lt;InputIter, OutputIter&gt; _copy_n(InputIter first, Size count,
200<a name="l00232"></a>00232                                          OutputIter result,
201<a name="l00233"></a>00233                                          std::input_iterator_tag) {
202<a name="l00234"></a>00234    <span class="keywordflow">for</span> ( ; count &gt; 0; --count) {
203<a name="l00235"></a>00235       *result = *first;
204<a name="l00236"></a>00236       ++first;
205<a name="l00237"></a>00237       ++result;
206<a name="l00238"></a>00238    }
207<a name="l00239"></a>00239    <span class="keywordflow">return</span> std::pair&lt;InputIter, OutputIter&gt;(first, result);
208<a name="l00240"></a>00240 }
209<a name="l00241"></a>00241 
210<a name="l00242"></a>00242 <span class="keyword">template</span> &lt;<span class="keyword">class</span> RAIter, <span class="keyword">class</span> Size, <span class="keyword">class</span> OutputIter&gt;
211<a name="l00243"></a>00243 <span class="keyword">inline</span> std::pair&lt;RAIter, OutputIter&gt;
212<a name="l00244"></a>00244 _copy_n(RAIter first, Size count, OutputIter result, std::random_access_iterator_tag) {
213<a name="l00245"></a>00245    RAIter last = first + count;
214<a name="l00246"></a>00246    <span class="keywordflow">return</span> std::pair&lt;RAIter, OutputIter&gt;(last, <a class="code" href="g_i_l_0214.html#g4e8a9e1bb08e76c93dc56a4626231ee1" title="Copy when both src and dst are planar pointers is copy for each channel.">std::copy</a>(first, last, result));
215<a name="l00247"></a>00247 }
216<a name="l00248"></a>00248 
217<a name="l00249"></a>00249 <span class="keyword">template</span> &lt;<span class="keyword">class</span> InputIter, <span class="keyword">class</span> Size, <span class="keyword">class</span> OutputIter&gt;
218<a name="l00250"></a>00250 <span class="keyword">inline</span> std::pair&lt;InputIter, OutputIter&gt;
219<a name="l00251"></a>00251 _copy_n(InputIter first, Size count, OutputIter result) {
220<a name="l00252"></a>00252    <span class="keywordflow">return</span> _copy_n(first, count, result, <span class="keyword">typename</span> std::iterator_traits&lt;InputIter&gt;::iterator_category());
221<a name="l00253"></a>00253 }
222<a name="l00254"></a>00254 
223<a name="l00255"></a>00255 <span class="keyword">template</span> &lt;<span class="keyword">class</span> InputIter, <span class="keyword">class</span> Size, <span class="keyword">class</span> OutputIter&gt;
224<a name="l00256"></a>00256 <span class="keyword">inline</span> std::pair&lt;InputIter, OutputIter&gt;
225<a name="l00257"></a>00257 copy_n(InputIter first, Size count, OutputIter result) {
226<a name="l00258"></a>00258     <span class="keywordflow">return</span> detail::_copy_n(first, count, result);
227<a name="l00259"></a>00259 }
228<a name="l00260"></a>00260 
229<a name="l00262"></a>00262 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt; 
230<a name="l00263"></a><a class="code" href="g_i_l_0509.html">00263</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0509.html" title="identity taken from SGI STL.">identity</a> : <span class="keyword">public</span> std::unary_function&lt;T,T&gt; {
231<a name="l00264"></a>00264     <span class="keyword">const</span> T&amp; operator()(<span class="keyword">const</span> T&amp; val)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> val; }
232<a name="l00265"></a>00265 };
233<a name="l00266"></a>00266 
234<a name="l00267"></a>00267 <span class="comment">/*************************************************************************************************/</span>
235<a name="l00268"></a>00268 
236<a name="l00270"></a>00270 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T1, <span class="keyword">typename</span> T2&gt;
237<a name="l00271"></a><a class="code" href="g_i_l_0517.html">00271</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0517.html" title="plus function object whose arguments may be of different type.">plus_asymmetric</a> : <span class="keyword">public</span> std::binary_function&lt;T1,T2,T1&gt; {
238<a name="l00272"></a>00272     T1 operator()(T1 f1, T2 f2)<span class="keyword"> const </span>{
239<a name="l00273"></a>00273         <span class="keywordflow">return</span> f1+f2;
240<a name="l00274"></a>00274     }
241<a name="l00275"></a>00275 };
242<a name="l00276"></a>00276 
243<a name="l00277"></a>00277 <span class="comment">/*************************************************************************************************/</span>
244<a name="l00278"></a>00278 
245<a name="l00280"></a>00280 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
246<a name="l00281"></a><a class="code" href="g_i_l_0511.html">00281</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0511.html" title="operator++ wrapped in a function object">inc</a> : <span class="keyword">public</span> std::unary_function&lt;T,T&gt; {
247<a name="l00282"></a>00282     T operator()(T x)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> ++x; }
248<a name="l00283"></a>00283 };
249<a name="l00284"></a>00284 
250<a name="l00285"></a>00285 <span class="comment">/*************************************************************************************************/</span>
251<a name="l00286"></a>00286 
252<a name="l00288"></a>00288 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
253<a name="l00289"></a><a class="code" href="g_i_l_0487.html">00289</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0487.html" title="operator-- wrapped in a function object">dec</a> : <span class="keyword">public</span> std::unary_function&lt;T,T&gt; {
254<a name="l00290"></a>00290     T operator()(T x)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> --x; }
255<a name="l00291"></a>00291 };
256<a name="l00292"></a>00292 
257<a name="l00294"></a>00294 <span class="comment">//         a given MPL RandomAccessSequence (or size if the type is not present)</span>
258<a name="l00295"></a>00295 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Types, <span class="keyword">typename</span> T&gt;
259<a name="l00296"></a><a class="code" href="g_i_l_0522.html">00296</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0522.html" title="Returns the index corresponding to the first occurrance of a given given type in...">type_to_index</a> 
260<a name="l00297"></a>00297     : <span class="keyword">public</span> mpl::distance&lt;typename mpl::begin&lt;Types&gt;::type, 
261<a name="l00298"></a>00298                                   typename mpl::find&lt;Types,T&gt;::type&gt;::type {};
262<a name="l00299"></a>00299 } <span class="comment">// namespace detail</span>
263<a name="l00300"></a>00300 
264<a name="l00301"></a>00301 
265<a name="l00302"></a>00302 
266<a name="l00305"></a>00305 template &lt;typename ColorSpace, typename ChannelMapping = mpl::range_c&lt;int,0,mpl::size&lt;ColorSpace&gt;::value&gt; &gt;
267<a name="l00306"></a><a class="code" href="g_i_l_0567.html">00306</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0567.html" title="Represents a color space and ordering of channels in memory.">layout</a> {
268<a name="l00307"></a>00307     <span class="keyword">typedef</span> ColorSpace      color_space_t;
269<a name="l00308"></a>00308     <span class="keyword">typedef</span> ChannelMapping  channel_mapping_t;
270<a name="l00309"></a>00309 };
271<a name="l00310"></a>00310 
272<a name="l00312"></a>00312 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Value, <span class="keyword">typename</span> T1, <span class="keyword">typename</span> T2&gt; <span class="comment">// where value_type&lt;T1&gt;  == value_type&lt;T2&gt; == Value</span>
273<a name="l00313"></a>00313 <span class="keywordtype">void</span> swap_proxy(T1&amp; left, T2&amp; right) {
274<a name="l00314"></a>00314     Value tmp = left;
275<a name="l00315"></a>00315     left = right;
276<a name="l00316"></a>00316     right = tmp;
277<a name="l00317"></a>00317 }
278<a name="l00318"></a>00318 
279<a name="l00320"></a>00320 <span class="keyword">inline</span> <span class="keywordtype">bool</span> little_endian() {
280<a name="l00321"></a>00321     <span class="keywordtype">short</span> tester = 0x0001;
281<a name="l00322"></a>00322     <span class="keywordflow">return</span>  *(<span class="keywordtype">char</span>*)&amp;tester!=0;
282<a name="l00323"></a>00323 }
283<a name="l00325"></a>00325 <span class="keyword">inline</span> <span class="keywordtype">bool</span> big_endian() {
284<a name="l00326"></a>00326     <span class="keywordflow">return</span> !little_endian();
285<a name="l00327"></a>00327 }
286<a name="l00328"></a>00328 
287<a name="l00329"></a>00329 } }  <span class="comment">// namespace boost::gil</span>
288<a name="l00330"></a>00330 
289<a name="l00331"></a>00331 <span class="preprocessor">#endif</span>
290</pre></div></div>
291<hr size="1"><address style="text-align: right;"><small>Generated on Sat May 2 13:50:15 2009 for Generic Image Library by&nbsp;
292<a href="http://www.doxygen.org/index.html">
293<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
294</body>
295</html>