]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/qvm/doc/vec_traits.html
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / qvm / doc / vec_traits.html
1 <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
2 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
3 <html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
4 <head>
5 <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
6 <title>vec_traits</title>
7 <link href='reno.css' type='text/css' rel='stylesheet'/>
8 </head>
9 <body>
10 <div class="body-0">
11 <div class="body-1">
12 <div class="body-2">
13 <div>
14 <h1>QVM: Quaternions, Vectors, Matrices</h1>
15 </div>
16 <!-- Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc. -->
17 <!-- Distributed under the Boost Software License, Version 1.0. (See accompanying -->
18 <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
19 <div class="RenoIncludeDIV"><div class="RenoAutoDIV"><h3>vec_traits</h3>
20 </div>
21 <div class="RenoIncludeDIV"><p><span class="RenoEscape">&#35;<!--<wiki>`&#35;</wiki>--></span>include &lt;<span class="RenoLink"><a href="boost_qvm_vec_traits_hpp.html">boost/qvm/vec_traits.hpp</a></span>&gt;</p>
22 <pre>namespace
23 boost
24 {
25 namespace
26 <span class="RenoLink"><a href="qvm.html">qvm</a></span>
27 {
28 <span class="RenoIncludeSPAN"> template &lt;class V&gt;
29 struct <span class="RenoLink">vec_traits</span>
30 {
31 /*main template members unspecified*/
32 };
33
34 /*
35 User-defined (possibly partial) specializations:
36
37 template &lt;&gt;
38 struct <span class="RenoLink">vec_traits</span>&lt;V&gt;
39 {
40 <span class="RenoIncludeSPAN"> static int const <span class="RenoLink"><a href="vec_traits_Vector_dim.html">dim</a></span> = /*user-defined*/;</span>
41 <span class="RenoIncludeSPAN"> typedef /*user-defined*/ <span class="RenoLink"><a href="vec_traits_V_scalar_type.html">scalar_type</a></span>;</span>
42
43 <span class="RenoIncludeSPAN"> template &lt;int I&gt; static inline <span class="RenoLink"><a href="vec_traits_V_scalar_type.html">scalar_type</a></span> <span class="RenoLink"><a href="vec_traits_V_read_element.html">read_element</a></span>( Vector const &amp; v );</span>
44 <span class="RenoIncludeSPAN"> template &lt;int I&gt; static inline <span class="RenoLink"><a href="vec_traits_V_scalar_type.html">scalar_type</a></span> &amp; <span class="RenoLink"><a href="vec_traits_V_write_element.html">write_element</a></span>( Vector &amp; v );</span>
45
46 <span class="RenoIncludeSPAN"> static inline <span class="RenoLink"><a href="vec_traits_V_scalar_type.html">scalar_type</a></span> <span class="RenoLink"><a href="vec_traits_V_read_element_idx.html">read_element_idx</a></span>( int i, Vector const &amp; v );</span>
47 <span class="RenoIncludeSPAN"> static inline <span class="RenoLink"><a href="vec_traits_V_scalar_type.html">scalar_type</a></span> &amp; <span class="RenoLink"><a href="vec_traits_V_write_element_idx.html">write_element_idx</a></span>( int i, Vector &amp; v );</span>
48 };
49 */</span>
50 }
51 }</pre>
52 </div><p>The <i><span class="RenoLink">vec_traits</span></i> template must be specialized for (user-defined) vector types in order to enable vector and matrix operations defined in Boost QVM headers for objects of those types.</p>
53 <p><i>Note: vector types are not required to be copyable.</i></p>
54 <p>The main <i><span class="RenoLink">vec_traits</span></i> template members are not specified. Valid specializations are required to define the following members:</p>
55 <div><ul><li> <i><span class="RenoLink"><a href="vec_traits_Vector_dim.html">dim</a></span></i>: the expression <i><span class="RenoLink">vec_traits</span>&lt;Vector&gt;::<span class="RenoLink"><a href="vec_traits_Vector_dim.html">dim</a></span></i> must evaluate to a compile-time integer constant greater than 0 that specifies the vector size.</li>
56 <li> <i><span class="RenoLink"><a href="vec_traits_V_scalar_type.html">scalar_type</a></span></i>: the expression <i><span class="RenoLink">vec_traits</span>&lt;Vector&gt;::<span class="RenoLink"><a href="vec_traits_V_scalar_type.html">scalar_type</a></span></i> must be a value type which satisfies the <span class="RenoLink"><a href="scalar_requirements.html">scalar requirements</a></span>.</li>
57 </ul></div>
58 <p>In addition, valid specializations of the <i><span class="RenoLink">vec_traits</span></i> template may define the following access functions as static members, where <i>v</i> is an object of type <i>Vector</i>, <i>I</i> is a compile-time integer constant, and <i>i</i> is a variable of type <i>int</i>:</p>
59 <div><ul><li> <i><span class="RenoLink"><a href="vec_traits_V_read_element.html">read_element</a></span></i>: the expression <i><span class="RenoLink">vec_traits</span>&lt;Vector&gt;::<span class="RenoLink"><a href="vec_traits_V_read_element.html">read_element</a></span>&lt;I&gt;(v)</i> returns either a copy of or a const reference to the <i>I</i>-th element of <i>v</i>.</li>
60 <li> <i><span class="RenoLink"><a href="vec_traits_V_write_element.html">write_element</a></span></i>: the expression <i><span class="RenoLink">vec_traits</span>&lt;Vector&gt;::<span class="RenoLink"><a href="vec_traits_V_write_element.html">write_element</a></span>&lt;I&gt;(v)</i> returns mutable reference to the <i>I</i>-th element of <i>v</i>.</li>
61 <li> <i><span class="RenoLink"><a href="vec_traits_V_read_element_idx.html">read_element_idx</a></span></i>: the expression <i><span class="RenoLink">vec_traits</span>&lt;Vector&gt;::<span class="RenoLink"><a href="vec_traits_V_read_element_idx.html">read_element_idx</a></span>(i,v)</i> returns either a copy of or a const reference to the <i>i</i>-th element of <i>v</i>.</li>
62 <li> <i><span class="RenoLink"><a href="vec_traits_V_write_element_idx.html">write_element_idx</a></span></i>: the expression <i><span class="RenoLink">vec_traits</span>&lt;Vector&gt;::<span class="RenoLink"><a href="vec_traits_V_write_element_idx.html">write_element_idx</a></span>(i,v)</i> returns mutable reference to the <i>i</i>-th element of <i>v</i>.</li>
63 </ul></div>
64 <p>It is illegal to call any of the above functions unless <i><span class="RenoLink"><a href="is_vec.html">is_vec</a></span>&lt;Vector&gt;::value</i> is <i>true</i>. Even then, vector types are allowed to define only a subset of the access functions. The general requirements are:</p>
65 <div><ul><li> At least one of <i><span class="RenoLink"><a href="vec_traits_V_read_element.html">read_element</a></span></i> or <i><span class="RenoLink"><a href="vec_traits_V_write_element.html">write_element</a></span></i> must be defined;</li>
66 <li> If <i><span class="RenoLink"><a href="vec_traits_V_read_element_idx.html">read_element_idx</a></span></i> is defined, <i><span class="RenoLink"><a href="vec_traits_V_read_element.html">read_element</a></span></i> must also be defined;</li>
67 <li> If <i><span class="RenoLink"><a href="vec_traits_V_write_element_idx.html">write_element_idx</a></span></i> is defined, <i><span class="RenoLink"><a href="vec_traits_V_write_element.html">write_element</a></span></i> must also be defined.</li>
68 </ul></div>
69 <p>Below is an example of a user-defined 3D vector type, and its corresponding specialization of the <i><span class="RenoLink">vec_traits</span></i> template:</p>
70 <div class="RenoIncludeDIV"><pre>#include &lt;<span class="RenoLink"><a href="boost_qvm_vec_traits_hpp.html">boost/qvm/vec_traits.hpp</a></span>&gt;
71
72 struct float3 { float a[3]; };
73
74 namespace boost
75 {
76 namespace <span class="RenoLink"><a href="qvm.html">qvm</a></span>
77 {
78 template &lt;&gt;
79 struct <span class="RenoLink">vec_traits</span>&lt;float3&gt;
80 {
81 static int const <span class="RenoLink"><a href="vec_traits_Vector_dim.html">dim</a></span>=3;
82 typedef float <span class="RenoLink"><a href="vec_traits_V_scalar_type.html">scalar_type</a></span>;
83
84 template &lt;int I&gt; static inline <span class="RenoLink"><a href="vec_traits_V_scalar_type.html">scalar_type</a></span> &amp; <span class="RenoLink"><a href="vec_traits_V_write_element.html">write_element</a></span>( float3 &amp; v ) { return v.a[I]; }
85 template &lt;int I&gt; static inline <span class="RenoLink"><a href="vec_traits_V_scalar_type.html">scalar_type</a></span> <span class="RenoLink"><a href="vec_traits_V_read_element.html">read_element</a></span>( float3 const &amp; v ) { return v.a[I]; }
86
87 static inline <span class="RenoLink"><a href="vec_traits_V_scalar_type.html">scalar_type</a></span> &amp; <span class="RenoLink"><a href="vec_traits_V_write_element_idx.html">write_element_idx</a></span>( int i, float3 &amp; v ) { return v.a[i]; } //optional
88 static inline <span class="RenoLink"><a href="vec_traits_V_scalar_type.html">scalar_type</a></span> <span class="RenoLink"><a href="vec_traits_V_read_element_idx.html">read_element_idx</a></span>( int i, float3 const &amp; v ) { return v.a[i]; } //optional
89 };
90 }
91 }</pre>
92 </div></div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
93 See also: <span class="RenoPageList"><a href="assign_vec_vec_.html">assign(vec,vec)</a>&nbsp;| <a href="boost_qvm_vec_traits_hpp.html">boost/qvm/vec_traits.hpp</a>&nbsp;| <a href="boost_qvm_vec_traits_array_hpp.html">boost/qvm/vec_traits_array.hpp</a>&nbsp;| <a href="cmp_vec_vec_.html">cmp(vec,vec)</a>&nbsp;| <a href="convert_to_vec_.html">convert_to(vec)</a>&nbsp;| <a href="cross.html">cross</a>&nbsp;| <a href="deduce_vec.html">deduce_vec</a>&nbsp;| <a href="deduce_vec2.html">deduce_vec2</a>&nbsp;| <a href="dot_vec_vec_.html">dot(vec,vec)</a>&nbsp;| <a href="is_vec.html">is_vec</a>&nbsp;| <a href="mag_vec_.html">mag(vec)</a>&nbsp;| <a href="mag_sqr_vec_.html">mag_sqr(vec)</a>&nbsp;| <a href="normalize_vec_.html">normalize(vec)</a>&nbsp;| <a href="operator_not_eq_vec_vec_.html">operator!=(vec,vec)</a>&nbsp;| <a href="operator_times_mat_vec_.html">operator*(mat,vec)</a>&nbsp;| <a href="operator_times_quat_vec_.html">operator*(quat,vec)</a>&nbsp;| <a href="operator_times_vec_mat_.html">operator*(vec,mat)</a>&nbsp;| <a href="operator_plus_vec_vec_.html">operator+(vec,vec)</a>&nbsp;| <a href="operator_add_vec_vec_.html">operator+=(vec,vec)</a>&nbsp;| <a href="operator_minus_vec_vec_.html">operator-(vec,vec)</a>&nbsp;| <a href="operator_sub_eq_vec_vec_.html">operator-=(vec,vec)</a>&nbsp;| <a href="operator_eq_vec_vec_.html">operator==(vec,vec)</a>&nbsp;| <a href="rot_mat.html">rot_mat</a>&nbsp;| <a href="rot_quat.html">rot_quat</a>&nbsp;| <a href="rotate_mat_vec_scalar_.html">rotate(mat,vec,scalar)</a>&nbsp;| <a href="rotate_quat_vec_scalar_.html">rotate(quat,vec,scalar)</a>&nbsp;| <a href="SFINAE_enable_if.html">SFINAE/enable_if</a>&nbsp;| <a href="scalar.html">scalar</a>&nbsp;| <a href="set_rot_mat_vec_scalar_.html">set_rot(mat,vec,scalar)</a>&nbsp;| <a href="set_rot_quat_vec_scalar_.html">set_rot(quat,vec,scalar)</a>&nbsp;| <a href="set_zero_vec_.html">set_zero(vec)</a>&nbsp;| <a href="transform_point.html">transform_point</a>&nbsp;| <a href="transform_vector.html">transform_vector</a>&nbsp;| <a href="view_proxy.html">View Proxy</a>&nbsp;| <a href="vec.html">vec</a>&nbsp;| <a href="vec_index_read.html">vec_index_read</a>&nbsp;| <a href="vec_index_write.html">vec_index_write</a>&nbsp;| <a href="vec_traits_V_read_element.html">vec_traits&lt;V&gt;::read_element</a>&nbsp;| <a href="vec_traits_V_read_element_idx.html">vec_traits&lt;V&gt;::read_element_idx</a>&nbsp;| <a href="vec_traits_V_scalar_type.html">vec_traits&lt;V&gt;::scalar_type</a>&nbsp;| <a href="vec_traits_V_write_element.html">vec_traits&lt;V&gt;::write_element</a>&nbsp;| <a href="vec_traits_V_write_element_idx.html">vec_traits&lt;V&gt;::write_element_idx</a>&nbsp;| <a href="vec_traits_Vector_dim.html">vec_traits&lt;Vector&gt;::dim</a></span>
94 </div>
95 <!-- Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc. -->
96 <!-- Distributed under the Boost Software License, Version 1.0. (See accompanying -->
97 <!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
98 <div id="footer">
99 <p>
100 <a class="logo" href="http://jigsaw.w3.org/css-validator/check/referer"><img class="logo_pic" src="valid-css.png" alt="Valid CSS" height="31" width="88"/></a>
101 <a class="logo" href="http://validator.w3.org/check?uri=referer"><img class="logo_pic" src="valid-xhtml.png" alt="Valid XHTML 1.0" height="31" width="88"/></a>
102 <small>Copyright (c) 2008-2016 by Emil Dotchevski and Reverge Studios, Inc.<br/>
103 Distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License, Version 1.0</a>.</small>
104 </p>
105 </div>
106 </div>
107 </div>
108 </div>
109 </body>
110 </html>