]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/numeric/ublas/detail/returntype_deduction.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / numeric / ublas / detail / returntype_deduction.hpp
CommitLineData
7c673cae
FG
1/*
2 * Copyright (c) 2001-2003 Joel de Guzman
3 *
4 * Use, modification and distribution is subject to the Boost Software
5 * License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 * http://www.boost.org/LICENSE_1_0.txt)
7 */
8#ifndef _BOOST_UBLAS_NUMERICTYPE_DEDUCTION_
9#define _BOOST_UBLAS_NUMERICTYPE_DEDUCTION_
10
11// See original in boost-sandbox/boost/utility/type_deduction.hpp for comments
12
13#include <boost/mpl/vector/vector20.hpp>
14#include <boost/mpl/at.hpp>
15#include <boost/mpl/or.hpp>
16#include <boost/mpl/identity.hpp>
17#include <boost/type_traits/remove_cv.hpp>
18#include <boost/type_traits/is_same.hpp>
19#include <boost/utility/enable_if.hpp>
20
21namespace boost { namespace numeric { namespace ublas {
22
23struct error_cant_deduce_type {};
24
25 namespace type_deduction_detail
26 {
27 typedef char(&bool_value_type)[1];
28 typedef char(&float_value_type)[2];
29 typedef char(&double_value_type)[3];
30 typedef char(&long_double_value_type)[4];
31 typedef char(&char_value_type)[5];
32 typedef char(&schar_value_type)[6];
33 typedef char(&uchar_value_type)[7];
34 typedef char(&short_value_type)[8];
35 typedef char(&ushort_value_type)[9];
36 typedef char(&int_value_type)[10];
37 typedef char(&uint_value_type)[11];
38 typedef char(&long_value_type)[12];
39 typedef char(&ulong_value_type)[13];
40
41 typedef char(&x_value_type)[14];
42 typedef char(&y_value_type)[15];
43
44 typedef char(&cant_deduce_type)[16];
45
46 template <typename T, typename PlainT = typename remove_cv<T>::type>
47 struct is_basic
48 : mpl::or_<
49 typename mpl::or_<
50 is_same<PlainT, bool>
51 , is_same<PlainT, float>
52 , is_same<PlainT, double>
53 , is_same<PlainT, long double>
54 > ::type,
55 typename mpl::or_<
56 is_same<PlainT, char>
57 , is_same<PlainT, signed char>
58 , is_same<PlainT, unsigned char>
59 , is_same<PlainT, short>
60 , is_same<PlainT, unsigned short>
61 > ::type,
62 typename mpl::or_<
63 is_same<PlainT, int>
64 , is_same<PlainT, unsigned int>
65 , is_same<PlainT, long>
66 , is_same<PlainT, unsigned long>
67 > ::type
68 > {};
69
70 struct asymmetric;
71
72 template <typename X, typename Y>
73 cant_deduce_type
74 test(...); // The black hole !!!
75
76 template <typename X, typename Y>
77 bool_value_type
78 test(bool const&);
79
80 template <typename X, typename Y>
81 float_value_type
82 test(float const&);
83
84 template <typename X, typename Y>
85 double_value_type
86 test(double const&);
87
88 template <typename X, typename Y>
89 long_double_value_type
90 test(long double const&);
91
92 template <typename X, typename Y>
93 char_value_type
94 test(char const&);
95
96 template <typename X, typename Y>
97 schar_value_type
98 test(signed char const&);
99
100 template <typename X, typename Y>
101 uchar_value_type
102 test(unsigned char const&);
103
104 template <typename X, typename Y>
105 short_value_type
106 test(short const&);
107
108 template <typename X, typename Y>
109 ushort_value_type
110 test(unsigned short const&);
111
112 template <typename X, typename Y>
113 int_value_type
114 test(int const&);
115
116 template <typename X, typename Y>
117 uint_value_type
118 test(unsigned int const&);
119
120 template <typename X, typename Y>
121 long_value_type
122 test(long const&);
123
124 template <typename X, typename Y>
125 ulong_value_type
126 test(unsigned long const&);
127
128 template <typename X, typename Y>
92f5a8d4 129 typename boost::disable_if<
7c673cae
FG
130 is_basic<X>, x_value_type
131 >::type
132 test(X const&);
133
134 template <typename X, typename Y>
92f5a8d4 135 typename boost::disable_if<
7c673cae
FG
136 mpl::or_<
137 is_basic<Y>
138 , is_same<Y, asymmetric>
139 , is_same<const X, const Y>
140 >
141 , y_value_type
142 >::type
143 test(Y const&);
144
145 template <typename X, typename Y>
146 struct base_result_of
147 {
148 typedef typename remove_cv<X>::type x_type;
149 typedef typename remove_cv<Y>::type y_type;
150
151 typedef mpl::vector16<
152 mpl::identity<bool>
153 , mpl::identity<float>
154 , mpl::identity<double>
155 , mpl::identity<long double>
156 , mpl::identity<char>
157 , mpl::identity<signed char>
158 , mpl::identity<unsigned char>
159 , mpl::identity<short>
160 , mpl::identity<unsigned short>
161 , mpl::identity<int>
162 , mpl::identity<unsigned int>
163 , mpl::identity<long>
164 , mpl::identity<unsigned long>
165 , mpl::identity<x_type>
166 , mpl::identity<y_type>
167 , mpl::identity<error_cant_deduce_type>
168 >
169 types;
170 };
171
172}}} } // namespace boost::numeric::ublas ::type_deduction_detail
173
174#endif