]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/qvm/vec_traits_array.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / qvm / vec_traits_array.hpp
CommitLineData
1e59de90
TL
1#ifndef BOOST_QVM_VEC_TRAITS_ARRAY_HPP_INCLUDED
2#define BOOST_QVM_VEC_TRAITS_ARRAY_HPP_INCLUDED
92f5a8d4 3
1e59de90 4// Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc.
92f5a8d4 5
1e59de90
TL
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)
92f5a8d4
TL
8
9#include <boost/qvm/inline.hpp>
10#include <boost/qvm/deduce_vec.hpp>
11#include <boost/qvm/detail/remove_const.hpp>
12#include <boost/qvm/assert.hpp>
13
1e59de90
TL
14namespace boost { namespace qvm {
15
16template <class T,int M,int N>
17struct
18vec_traits<T[M][N]>
19 {
20 static int const dim=0;
21 typedef void scalar_type;
22 };
23
24template <class T,int Dim>
25struct
26vec_traits<T[Dim]>
92f5a8d4 27 {
1e59de90
TL
28 typedef T this_vector[Dim];
29 typedef typename qvm_detail::remove_const<T>::type scalar_type;
30 static int const dim=Dim;
31
32 template <int I>
33 static
34 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
35 scalar_type
36 read_element( this_vector const & x )
37 {
38 BOOST_QVM_STATIC_ASSERT(I>=0);
39 BOOST_QVM_STATIC_ASSERT(I<Dim);
40 return x[I];
41 }
42
43 template <int I>
44 static
45 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
46 scalar_type &
47 write_element( this_vector & x )
48 {
49 BOOST_QVM_STATIC_ASSERT(I>=0);
50 BOOST_QVM_STATIC_ASSERT(I<Dim);
51 return x[I];
52 }
53
54 static
55 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
56 scalar_type
57 read_element_idx( int i, this_vector const & x )
58 {
59 BOOST_QVM_ASSERT(i>=0);
60 BOOST_QVM_ASSERT(i<Dim);
61 return x[i];
62 }
63
64 static
65 BOOST_QVM_CONSTEXPR BOOST_QVM_INLINE_CRITICAL
66 scalar_type &
67 write_element_idx( int i, this_vector & x )
92f5a8d4 68 {
1e59de90
TL
69 BOOST_QVM_ASSERT(i>=0);
70 BOOST_QVM_ASSERT(i<Dim);
71 return x[i];
92f5a8d4 72 }
1e59de90
TL
73 };
74
75template <class T,int Dim,int D>
76struct
77deduce_vec<T[Dim],D>
78 {
79 typedef vec<T,D> type;
80 };
81
82template <class T,int Dim,int D>
83struct
84deduce_vec<T const[Dim],D>
85 {
86 typedef vec<T,D> type;
87 };
88
89template <class T1,class T2,int Dim,int D>
90struct
91deduce_vec2<T1[Dim],T2[Dim],D>
92 {
93 typedef vec<typename deduce_scalar<T1,T2>::type,D> type;
94 };
95
96template <int Dim,class T>
97T (&ptr_vref( T * ptr ))[Dim]
98 {
99 return *reinterpret_cast<T (*)[Dim]>(ptr);
92f5a8d4
TL
100 }
101
1e59de90
TL
102} }
103
92f5a8d4 104#endif