rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWConvertMathVec< From, To > Struct Template Reference
[Math Collections]

Converts between RWMathVec types with different datatypes. More...

#include <rw/math/mathvec.h>

List of all members.

Public Member Functions

 RWConvertMathVec (const RWMathVec< From > &v)
 operator RWMathVec< To > ()

Detailed Description

template<class From, class To>
struct RWConvertMathVec< From, To >

Class RWConvertMathVec<From,To> converts between RWMathVec types with different datatypes.

Synopsis

 template <class From, class To>
 class RWConvertMathVec;

Examples

 #include <rw/math/mathvec.h>
 
 int main()
 {
        // create a length 5 vector of 1's
   RWMathVec<int> d(5,1);
 
        // convert int vector d to a DComplex
        // vector c with all real parts 1
   RWMathVec<DComplex> c = RWConvertMathVec<int,DComplex>(d);
 
        // convert int vector d to a double vector
        //and then call sin
   RWMathVec<double> s = RWConvertMathVec<int,double>(d);
   s = sin(s);
 }

Constructor & Destructor Documentation

template<class From, class To>
RWConvertMathVec< From, To >::RWConvertMathVec ( const RWMathVec< From > &  v  )  [inline]

Constructs a new vector of type RWMathVec<To> that can be used anywhere as a type RWMathVec<To> . Note that a temporary array is created every time this constructor is invoked, but the conversion operator below can be used repeatedly without creating additional temporaries.


Member Function Documentation

template<class From, class To>
RWConvertMathVec< From, To >::operator RWMathVec< To > (  )  [inline]

Automatic conversion operator that enables class RWConvertMathVec<From,To> to be used as an RWMathVec<To> . While the actual conversion takes place in the constructor, this operator provides a reference to that converted vector.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.