]> Dogcows Code - chaz/yoink/blob - src/moof/cml/vector/vector_promotions.h
the massive refactoring effort
[chaz/yoink] / src / moof / cml / vector / vector_promotions.h
1 /* -*- C++ -*- ------------------------------------------------------------
2
3 Copyright (c) 2007 Jesse Anders and Demian Nave http://cmldev.net/
4
5 The Configurable Math Library (CML) is distributed under the terms of the
6 Boost Software License, v1.0 (see cml/LICENSE for details).
7
8 *-----------------------------------------------------------------------*/
9 /** @file
10 * @brief
11 *
12 * Defines promotions for vectors used in vector/vector or vector/scalar
13 * expressions.
14 *
15 * @sa BinaryVectorOp
16 */
17
18 #ifndef vector_promotions_h
19 #define vector_promotions_h
20
21 #include <cml/et/scalar_promotions.h>
22 #include <cml/et/array_promotions.h>
23
24 namespace cml {
25 namespace et {
26
27 /* Default vector type promotion template. */
28 template<class LeftT, class RightT> struct VectorPromote;
29
30 /** Type promotion for two vector types. */
31 template<typename E1, class AT1, typename E2, class AT2>
32 struct VectorPromote< cml::vector<E1,AT1>, cml::vector<E2,AT2> >
33 {
34 typedef typename ArrayPromote<
35 typename cml::vector<E1,AT1>::array_type,
36 typename cml::vector<E2,AT2>::array_type
37 >::type promoted_array;
38
39 /* The deduced vector result type: */
40 typedef cml::vector<
41 typename promoted_array::value_type,
42 typename promoted_array::generator_type
43 > type;
44
45 /* The deduced temporary type: */
46 typedef typename type::temporary_type temporary_type;
47 };
48
49 /** Type promotion for a vector and a scalar. */
50 template<typename E, class AT, typename S>
51 struct VectorPromote<cml::vector<E,AT>, S>
52 {
53 /* The deduced vector result type (the array type is the same): */
54 typedef cml::vector<typename ScalarPromote<E,S>::type, AT> type;
55
56 /* The deduced temporary type: */
57 typedef typename type::temporary_type temporary_type;
58 };
59
60 /** Type promotion for a scalar and a vector. */
61 template<typename S, typename E, class AT>
62 struct VectorPromote<S, cml::vector<E,AT> >
63 {
64 /* The deduced vector result type (the array type is the same): */
65 typedef cml::vector<typename ScalarPromote<S,E>::type, AT> type;
66
67 /* The deduced temporary type: */
68 typedef typename type::temporary_type temporary_type;
69 };
70
71 } // namespace et
72 } // namespace cml
73
74 #endif
75
76 // -------------------------------------------------------------------------
77 // vim:ft=cpp
This page took 0.045205 seconds and 5 git commands to generate.