]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/qvm/vec_traits_defaults.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / qvm / vec_traits_defaults.hpp
1 //Copyright (c) 2008-2016 Emil Dotchevski and Reverge Studios, Inc.
2
3 //Distributed under the Boost Software License, Version 1.0. (See accompanying
4 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #ifndef UUID_DFFD61ACC72311E6955FFF1F07624D53
7 #define UUID_DFFD61ACC72311E6955FFF1F07624D53
8
9 #include <boost/qvm/inline.hpp>
10 #include <boost/qvm/assert.hpp>
11
12 namespace
13 boost
14 {
15 namespace
16 qvm
17 {
18 template <class>
19 struct vec_traits;
20
21 namespace
22 qvm_detail
23 {
24 template <int I,int N>
25 struct
26 vector_w
27 {
28 template <class A>
29 static
30 BOOST_QVM_INLINE_CRITICAL
31 typename vec_traits<A>::scalar_type &
32 write_element_idx( int i, A & a )
33 {
34 return I==i?
35 vec_traits<A>::template write_element<I>(a) :
36 vector_w<I+1,N>::write_element_idx(i,a);
37 }
38 };
39
40 template <int N>
41 struct
42 vector_w<N,N>
43 {
44 template <class A>
45 static
46 BOOST_QVM_INLINE_TRIVIAL
47 typename vec_traits<A>::scalar_type &
48 write_element_idx( int, A & a )
49 {
50 BOOST_QVM_ASSERT(0);
51 return vec_traits<A>::template write_element<0>(a);
52 }
53 };
54 }
55
56 template <class VecType,class ScalarType,int Dim>
57 struct
58 vec_traits_defaults
59 {
60 typedef VecType vec_type;
61 typedef ScalarType scalar_type;
62 static int const dim=Dim;
63
64 template <int I>
65 static
66 BOOST_QVM_INLINE_CRITICAL
67 scalar_type
68 read_element( vec_type const & x )
69 {
70 return vec_traits<vec_type>::template write_element<I>(const_cast<vec_type &>(x));
71 }
72
73 static
74 BOOST_QVM_INLINE_CRITICAL
75 scalar_type
76 read_element_idx( int i, vec_type const & x )
77 {
78 return vec_traits<vec_type>::write_element_idx(i,const_cast<vec_type &>(x));
79 }
80
81 protected:
82
83 static
84 BOOST_QVM_INLINE_TRIVIAL
85 scalar_type &
86 write_element_idx( int i, vec_type & m )
87 {
88 return qvm_detail::vector_w<0,vec_traits<vec_type>::dim>::write_element_idx(i,m);
89 }
90 };
91 }
92 }
93
94 #endif