]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/qvm/vec.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / qvm / vec.hpp
1 #ifndef BOOST_QVM_VEC_HPP_INCLUDED
2 #define BOOST_QVM_VEC_HPP_INCLUDED
3
4 // Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc.
5
6 // Distributed under the Boost Software License, Version 1.0. (See accompanying
7 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8
9 #include <boost/qvm/detail/vec_assign.hpp>
10 #include <boost/qvm/assert.hpp>
11 #include <boost/qvm/static_assert.hpp>
12
13 namespace boost { namespace qvm {
14
15 template <class T,int D>
16 struct
17 vec
18 {
19 T a[D];
20 template <class R>
21 operator R() const
22 {
23 R r;
24 assign(r,*this);
25 return r;
26 }
27 };
28
29 template <class V>
30 struct vec_traits;
31
32 template <class T,int Dim>
33 struct
34 vec_traits< vec<T,Dim> >
35 {
36 typedef vec<T,Dim> this_vector;
37 typedef T scalar_type;
38 static int const dim=Dim;
39
40 template <int I>
41 static
42 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
43 scalar_type
44 read_element( this_vector const & x )
45 {
46 BOOST_QVM_STATIC_ASSERT(I>=0);
47 BOOST_QVM_STATIC_ASSERT(I<dim);
48 return x.a[I];
49 }
50
51 template <int I>
52 static
53 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
54 scalar_type &
55 write_element( this_vector & x )
56 {
57 BOOST_QVM_STATIC_ASSERT(I>=0);
58 BOOST_QVM_STATIC_ASSERT(I<dim);
59 return x.a[I];
60 }
61
62 static
63 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
64 scalar_type
65 read_element_idx( int i, this_vector const & x )
66 {
67 BOOST_QVM_ASSERT(i>=0);
68 BOOST_QVM_ASSERT(i<dim);
69 return x.a[i];
70 }
71
72 static
73 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
74 scalar_type &
75 write_element_idx( int i, this_vector & x )
76 {
77 BOOST_QVM_ASSERT(i>=0);
78 BOOST_QVM_ASSERT(i<dim);
79 return x.a[i];
80 }
81 };
82
83 } }
84
85 #endif