1<html> 2<head> 3<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 4<title>C++11 Array Container</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="../adapted.html" title="Adapted models"> 9<link rel="prev" href="c_array.html" title="C array"> 10<link rel="next" href="boost_array.html" title="Boost.Array"> 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="c_array.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../adapted.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="boost_array.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.adapted.std_array"></a><a class="link" href="std_array.html" title="C++11 Array Container">C++11 Array Container</a> 28</h4></div></div></div> 29<p> 30 C++11 array containers are adapted to the Boost.Geometry point concept 31 </p> 32<h6> 33<a name="geometry.reference.adapted.std_array.h0"></a> 34 <span class="phrase"><a name="geometry.reference.adapted.std_array.description"></a></span><a class="link" href="std_array.html#geometry.reference.adapted.std_array.description">Description</a> 35 </h6> 36<p> 37 A C++11 std::array is (optionally) adapted to the Boost.Geometry point 38 concept. It can therefore be used in all Boost.Geometry algorithms. 39 </p> 40<p> 41 A std::array can be the point type used by the models linestring, polygon, 42 segment, box, and ring. 43 </p> 44<h6> 45<a name="geometry.reference.adapted.std_array.h1"></a> 46 <span class="phrase"><a name="geometry.reference.adapted.std_array.model_of"></a></span><a class="link" href="std_array.html#geometry.reference.adapted.std_array.model_of">Model 47 of</a> 48 </h6> 49<p> 50 <a class="link" href="../concepts/concept_point.html" title="Point Concept">Point Concept</a> 51 </p> 52<h6> 53<a name="geometry.reference.adapted.std_array.h2"></a> 54 <span class="phrase"><a name="geometry.reference.adapted.std_array.header"></a></span><a class="link" href="std_array.html#geometry.reference.adapted.std_array.header">Header</a> 55 </h6> 56<p> 57 <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">geometries</span><span class="special">/</span><span class="identifier">adapted</span><span class="special">/</span><span class="identifier">std_array</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> 58 </p> 59<p> 60 The standard header <code class="computeroutput"><span class="identifier">boost</span><span class="special">/</span><span class="identifier">geometry</span><span class="special">.</span><span class="identifier">hpp</span></code> 61 does not include this header. 62 </p> 63<h6> 64<a name="geometry.reference.adapted.std_array.h3"></a> 65 <span class="phrase"><a name="geometry.reference.adapted.std_array.example"></a></span><a class="link" href="std_array.html#geometry.reference.adapted.std_array.example">Example</a> 66 </h6> 67<p> 68 Shows how to use a C++11 std::array using Boost.Geometry's distance, set 69 and assign_values algorithms 70 </p> 71<p> 72</p> 73<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span> 74 75<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> 76<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> 77<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">std_array</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span> 78 79<span class="identifier">BOOST_GEOMETRY_REGISTER_STD_ARRAY_CS</span><span class="special">(</span><span class="identifier">cs</span><span class="special">::</span><span class="identifier">cartesian</span><span class="special">)</span> 80 81<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span> 82<span class="special">{</span> 83 <span class="identifier">std</span><span class="special">::</span><span class="identifier">array</span><span class="special"><</span><span class="keyword">float</span><span class="special">,</span> <span class="number">2</span><span class="special">></span> <span class="identifier">a</span> <span class="special">=</span> <span class="special">{</span> <span class="special">{</span><span class="number">1</span><span class="special">,</span> <span class="number">2</span><span class="special">}</span> <span class="special">};</span> 84 <span class="identifier">std</span><span class="special">::</span><span class="identifier">array</span><span class="special"><</span><span class="keyword">double</span><span class="special">,</span> <span class="number">2</span><span class="special">></span> <span class="identifier">b</span> <span class="special">=</span> <span class="special">{</span> <span class="special">{</span><span class="number">2</span><span class="special">,</span> <span class="number">3</span><span class="special">}</span> <span class="special">};</span> 85 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</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">distance</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> 86 87 <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">set</span><span class="special"><</span><span class="number">0</span><span class="special">>(</span><span class="identifier">a</span><span class="special">,</span> <span class="number">1.1f</span><span class="special">);</span> 88 <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">set</span><span class="special"><</span><span class="number">1</span><span class="special">>(</span><span class="identifier">a</span><span class="special">,</span> <span class="number">2.2f</span><span class="special">);</span> 89 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</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">distance</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> 90 91 <span class="identifier">boost</span><span class="special">::</span><span class="identifier">geometry</span><span class="special">::</span><span class="identifier">assign_values</span><span class="special">(</span><span class="identifier">b</span><span class="special">,</span> <span class="number">2.2</span><span class="special">,</span> <span class="number">3.3</span><span class="special">);</span> 92 <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</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">distance</span><span class="special">(</span><span class="identifier">a</span><span class="special">,</span> <span class="identifier">b</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> 93 94 <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><span class="special"><</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">array</span><span class="special"><</span><span class="keyword">double</span><span class="special">,</span> <span class="number">2</span><span class="special">></span> <span class="special">></span> <span class="identifier">line</span><span class="special">;</span> 95 <span class="identifier">line</span><span class="special">.</span><span class="identifier">push_back</span><span class="special">(</span><span class="identifier">b</span><span class="special">);</span> 96 97 <span class="keyword">return</span> <span class="number">0</span><span class="special">;</span> 98<span class="special">}</span> 99</pre> 100<p> 101 </p> 102<p> 103 Output: 104 </p> 105<pre class="programlisting">1.41421 1061.20416 1071.55563 108</pre> 109</div> 110<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 111<td align="left"></td> 112<td align="right"><div class="copyright-footer">Copyright © 2009-2019 Barend Gehrels, Bruno Lalande, Mateusz Loskot, Adam 113 Wulkiewicz, Oracle and/or its affiliates<p> 114 Distributed under the Boost Software License, Version 1.0. (See accompanying 115 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>) 116 </p> 117</div></td> 118</tr></table> 119<hr> 120<div class="spirit-nav"> 121<a accesskey="p" href="c_array.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../adapted.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="boost_array.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a> 122</div> 123</body> 124</html> 125