1 /* -*- C++ -*- ------------------------------------------------------------
3 Copyright (c) 2007 Jesse Anders and Demian Nave http://cmldev.net/
5 The Configurable Math Library (CML) is distributed under the terms of the
6 Boost Software License, v1.0 (see cml/LICENSE for details).
8 *-----------------------------------------------------------------------*/
12 * Defines promotions for vectors used in vector/vector or vector/scalar
18 #ifndef vector_promotions_h
19 #define vector_promotions_h
21 #include <cml/et/scalar_promotions.h>
22 #include <cml/et/array_promotions.h>
27 /* Default vector type promotion template. */
28 template<class LeftT
, class RightT
> struct VectorPromote
;
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
> >
34 typedef typename ArrayPromote
<
35 typename
cml::vector
<E1
,AT1
>::array_type
,
36 typename
cml::vector
<E2
,AT2
>::array_type
37 >::type promoted_array
;
39 /* The deduced vector result type: */
41 typename
promoted_array::value_type
,
42 typename
promoted_array::generator_type
45 /* The deduced temporary type: */
46 typedef typename
type::temporary_type temporary_type
;
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
>
53 /* The deduced vector result type (the array type is the same): */
54 typedef cml::vector
<typename ScalarPromote
<E
,S
>::type
, AT
> type
;
56 /* The deduced temporary type: */
57 typedef typename
type::temporary_type temporary_type
;
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
> >
64 /* The deduced vector result type (the array type is the same): */
65 typedef cml::vector
<typename ScalarPromote
<S
,E
>::type
, AT
> type
;
67 /* The deduced temporary type: */
68 typedef typename
type::temporary_type temporary_type
;
76 // -------------------------------------------------------------------------