1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>dimension</title> 5<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css"> 6<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 7<link rel="home" href="../../../index.html" title="Chapter 1. Geometry"> 8<link rel="up" href="../core.html" title="Core Metafunctions"> 9<link rel="prev" href="degree.html" title="degree"> 10<link rel="next" href="interior_type.html" title="interior_type"> 11</head> 12<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 13<table cellpadding="2" width="100%"><tr> 14<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td> 15<td align="center"><a href="../../../../../../../index.html">Home</a></td> 16<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td> 17<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 18<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 19<td align="center"><a href="../../../../../../../more/index.htm">More</a></td> 20</tr></table> 21<hr> 22<div class="spirit-nav"> 23<a accesskey="p" href="degree.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../core.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="interior_type.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 24</div> 25<div class="section"> 26<div class="titlepage"><div><div><h4 class="title"> 27<a name="geometry.reference.core.dimension"></a><a class="link" href="dimension.html" title="dimension">dimension</a> 28</h4></div></div></div> 29<p> 30 <a class="indexterm" name="idm45635683969120"></a> 31Metafunction defining <span class="bold"><strong>value</strong></span> as the number 32 of coordinates (the number of axes of any geometry) of the point type making 33 up the specified geometry type. 34 </p> 35<h6> 36<a name="geometry.reference.core.dimension.h0"></a> 37 <span class="phrase"><a name="geometry.reference.core.dimension.synopsis"></a></span><a class="link" href="dimension.html#geometry.reference.core.dimension.synopsis">Synopsis</a> 38 </h6> 39<p> 40</p> 41<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">Geometry</span><span class="special">></span> 42<span class="keyword">struct</span> <span class="identifier">dimension</span> 43 <span class="special">:</span> <span class="keyword">public</span> <span class="identifier">core_dispatch</span><span class="special">::</span><span class="identifier">dimension</span><span class="special"><</span> <span class="identifier">tag</span><span class="special"><</span> <span class="identifier">Geometry</span> <span class="special">>::</span><span class="identifier">type</span><span class="special">,</span> <span class="identifier">geometry</span><span class="special">::</span><span class="identifier">util</span><span class="special">::</span><span class="identifier">bare_type</span><span class="special"><</span> <span class="identifier">Geometry</span> <span class="special">>::</span><span class="identifier">type</span> <span class="special">></span> 44<span class="special">{</span> 45 <span class="comment">// ...</span> 46<span class="special">};</span> 47</pre> 48<p> 49 </p> 50<h6> 51<a name="geometry.reference.core.dimension.h1"></a> 52 <span class="phrase"><a name="geometry.reference.core.dimension.template_parameter_s_"></a></span><a class="link" href="dimension.html#geometry.reference.core.dimension.template_parameter_s_">Template 53 parameter(s)</a> 54 </h6> 55<div class="informaltable"><table class="table"> 56<colgroup> 57<col> 58<col> 59</colgroup> 60<thead><tr> 61<th> 62 <p> 63 Parameter 64 </p> 65 </th> 66<th> 67 <p> 68 Description 69 </p> 70 </th> 71</tr></thead> 72<tbody><tr> 73<td> 74 <p> 75 typename Geometry 76 </p> 77 </td> 78<td> 79 <p> 80 Any type fulfilling a Geometry Concept 81 </p> 82 </td> 83</tr></tbody> 84</table></div> 85<h6> 86<a name="geometry.reference.core.dimension.h2"></a> 87 <span class="phrase"><a name="geometry.reference.core.dimension.header"></a></span><a class="link" href="dimension.html#geometry.reference.core.dimension.header">Header</a> 88 </h6> 89<p> 90 Either 91 </p> 92<p> 93 <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> 94 </p> 95<p> 96 Or 97 </p> 98<p> 99 <code class="computeroutput"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">core</span><span class="special">/</span><span class="identifier">coordinate_dimension</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> 100 </p> 101<h6> 102<a name="geometry.reference.core.dimension.h3"></a> 103 <span class="phrase"><a name="geometry.reference.core.dimension.complexity"></a></span><a class="link" href="dimension.html#geometry.reference.core.dimension.complexity">Complexity</a> 104 </h6> 105<p> 106 Compile time 107 </p> 108<h6> 109<a name="geometry.reference.core.dimension.h4"></a> 110 <span class="phrase"><a name="geometry.reference.core.dimension.example"></a></span><a class="link" href="dimension.html#geometry.reference.core.dimension.example">Example</a> 111 </h6> 112<p> 113 Examine the number of coordinates making up the points in a linestring 114 type 115 </p> 116<p> 117</p> 118<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> 119 120<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 121<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">linestring</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 122<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">/</span><span class="identifier">geometries</span><span class="special">/</span><span class="identifier">adapted</span><span class="special">/</span><span class="identifier">boost_tuple</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 123 124<span class="identifier">BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS</span><span class="special">(</span><span class="identifier">cs</span><span class="special">::</span><span class="identifier">cartesian</span><span class="special">);</span> 125 126<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> 127<span class="special">{</span> 128 <span class="keyword">int</span> <span class="identifier">dim</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">dimension</span> 129 <span class="special"><</span> 130 <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">model</span><span class="special">::</span><span class="identifier">linestring</span> 131 <span class="special"><</span> 132 <span class="identifier">boost</span><span class="special">::</span><span class="identifier">tuple</span><span class="special"><</span><span class="keyword">float</span><span class="special">,</span> <span class="keyword">float</span><span class="special">,</span> <span class="keyword">float</span><span class="special">></span> 133 <span class="special">></span> 134 <span class="special">>::</span><span class="identifier">value</span><span class="special">;</span> 135 136 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"dimensions: "</span> <span class="special"><<</span> <span class="identifier">dim</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> 137 138 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 139<span class="special">}</span> 140</pre> 141<p> 142 </p> 143<p> 144 Output: 145 </p> 146<pre class="programlisting">dimensions: 3 147</pre> 148</div> 149<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 150<td align="left"></td> 151<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam 152 Wulkiewicz, Oracle and/or its affiliates<p> 153 Distributed under the Boost Software License, Version 1.0. (See accompanying 154 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 155 </p> 156</div></td> 157</tr></table> 158<hr> 159<div class="spirit-nav"> 160<a accesskey="p" href="degree.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../core.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="interior_type.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 161</div> 162</body> 163</html> 164