Teuchos::Array< T > Class Template Reference
[Teuchos Memory Management Utilities]

Memory-safe tempalted array class that encapsulates std::vector. More...

#include <Teuchos_Array.hpp>

List of all members.

General non-standard functions.

Array< T > & append (const T &x)
 Add a new entry at the end of the array.
void remove (int i)
 Remove the i-th element from the array, with optional boundschecking.
int length () const
 Return number of elements in the array.
std::string toString () const
 Convert an Array to an std::string.
T * getRawPtr ()
 Return a raw pointer to beginning of array or NULL if unsized.
const T * getRawPtr () const
 Return a raw pointer to beginning of array or NULL if unsized.
static bool hasBoundsChecking ()
 Return true if Array has been compiled with boundschecking on.

Public Types

std::vector typedefs
typedef std::vector< T
>::value_type 
value_type
 
typedef std::vector< T
>::pointer 
pointer
 
typedef std::vector< T
>::const_pointer 
const_pointer
 
typedef std::vector< T
>::reference 
reference
 
typedef std::vector< T
>::const_reference 
const_reference
 
typedef Teuchos_Index Ordinal
 
typedef std::vector< T
>::iterator 
iterator
 
typedef std::vector< T
>::const_iterator 
const_iterator
 
typedef std::vector< T
>::reverse_iterator 
reverse_iterator
 
typedef std::vector< T
>::const_reverse_iterator 
const_reverse_iterator
 
typedef std::vector< T
>::size_type 
size_type
 
typedef std::vector< T
>::difference_type 
difference_type
 
typedef std::vector< T
>::allocator_type 
allocator_type
 

Public Member Functions

All constructors
 Array ()
 
 Array (Ordinal n, const value_type &value=value_type())
 
 Array (const Array< T > &x)
 
template<typename InputIterator>
 Array (InputIterator first, InputIterator last)
 
 Array (const ArrayView< const T > &a)
 
template<int N>
 Array (const Tuple< T, N > &t)
 
 ~Array ()
 
Arrayoperator= (const Array< T > &a)
 
Other std::vector functions
void assign (Ordinal n, const value_type &val)
 
template<typename InputIterator>
void assign (InputIterator first, InputIterator last)
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
reverse_iterator rbegin ()
 
reverse_iterator rend ()
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
size_type size () const
 
size_type max_size () const
 
void resize (Ordinal new_size, const value_type &x=value_type())
 
size_type capacity () const
 
bool empty () const
 
void reserve (Ordinal n)
 
reference operator[] (Ordinal i)
 
const_reference operator[] (Ordinal i) const
 
reference at (Ordinal i)
 
const_reference at (Ordinal i) const
 
reference front ()
 
const_reference front () const
 
reference back ()
 
const_reference back () const
 
void push_back (const value_type &x)
 
void pop_back ()
 
iterator insert (iterator position, const value_type &x)
 
void insert (iterator position, Ordinal n, const value_type &x)
 
template<typename InputIterator>
void insert (iterator position, InputIterator first, InputIterator last)
 
iterator erase (iterator position)
 
iterator erase (iterator first, iterator last)
 
void swap (Array &x)
 
void clear ()
 
Conversions to and from std::vector.
 Array (const std::vector< T > &v)
 Copy constructor from an std::vector.
std::vector< T > toVector () const
 Explicit copy conversion to an std::vector.
Arrayoperator= (const std::vector< T > &v)
 Assignment operator for std::vector.
Views
ArrayView< T > view (Ordinal offset, Ordinal size)
 Return non-const view of a contiguous range of elements.
ArrayView< const T > view (Ordinal offset, Ordinal size) const
 Return const view of a contiguous range of elements.
ArrayView< T > operator() (Ordinal offset, Ordinal size)
 Return a non-const view of a contiguous range of elements (calls view(offset,size)).
ArrayView< const T > operator() (Ordinal offset, Ordinal size) const
 Return a non-const view of a contiguous range of elements (calls view(offset,size)).
ArrayView< T > operator() ()
 Return an non-const ArrayView of *this.
ArrayView< const T > operator() () const
 Return an const ArrayView of *this.
 operator ArrayView ()
 Perform an implicit conversion to a non-const ArrayView (calls operator()()).
 operator ArrayView () const
 Perform an implicit conversion to a non-const ArrayView (calls operator()()).

Friends

template<typename T2>
bool operator== (const Array< T2 > &a1, const Array< T2 > &a2)
 
template<typename T2>
bool operator!= (const Array< T2 > &a1, const Array< T2 > &a2)
 
template<typename T2>
void swap (Array< T2 > &a1, Array< T2 > &a2)
 
template<typename T2>
bool operator< (const Array< T2 > &a1, const Array< T2 > &a2)
 
template<typename T2>
bool operator<= (const Array< T2 > &a1, const Array< T2 > &a2)
 
template<typename T2>
bool operator> (const Array< T2 > &a1, const Array< T2 > &a2)
 
template<typename T2>
bool operator>= (const Array< T2 > &a1, const Array< T2 > &a2)
 

Related Functions

(Note that these are not member functions.)

bool operator== (const Array< T > &a1, const Array< T > &a2)
 Equality operator.
bool operator!= (const Array< T > &a1, const Array< T > &a2)
 Non-equality operator.
void swap (Array< T > &a1, Array< T > &a2)
 Non-member swap (specializes default std version).
bool operator< (const Array< T > &a1, const Array< T > &a2)
 Less-than operator.
bool operator<= (const Array< T > &a1, const Array< T > &a2)
 Less-than-or-equal operator.
bool operator> (const Array< T > &a1, const Array< T > &a2)
 Greater-than operator.
bool operator>= (const Array< T > &a1, const Array< T > &a2)
 Greater-than-or-equal operator.
std::ostream & operator<< (std::ostream &os, const Array< T > &array)
 Write an Array to an ostream.
int hashCode (const Array< T > &array)
 Return the hash code.
std::vector< T > createVector (const Array< T > &a)
 Copy conversion to an std::vector.
std::string toString (const Array< T > &array)
 Convert an array to a string representation.
Array< T > fromStringToArray (const std::string &arrayStr)
 Converts from std::string representation (as created by toString()) back into the array object.
void extractDataFromISS (std::istringstream &iss, T &data)
 Extracts data from an istringstream object.
void extractDataFromISS (std::istringstream &iss, std::string &data)
 Extracts std::string data from an istringstream object.


Detailed Description

template<typename T>
class Teuchos::Array< T >

Memory-safe tempalted array class that encapsulates std::vector.

ToDo: Finish documentation!

Tuple Construction

A user can create a Teuchos::Tuple object to initialize an Array object by using one of the the convenient overloaded Teuchos::tuple() non-member constructor functions. For example, see Array_test.cpp for how this is done.

Design Discussion

Currently, this class defines implicit conversions to ArrayView. An alternative design would be to have Array derive from ArrayView. This is a workable design but it would impart some extra storage and runtime overhead. Perhaps the most significant overhead would be having the reset the base ArrayView pointer and size on each and every change in the structure of the container. This would import extra overhead beyond a straight std::vector.

The big advantage of deriving Array from ArrayView is that this would allow Array to be used to call some functions taking ArrayView without requiring an implicit conversion. While the implicit shallow conversion from Array to ArrayView is very cheap (just a pointer and int copy), it does cause problems where the compiler will refuse to perform an implicit conversion to call a templated function. However, note that an implicit conversion to an ArrayView<const T> would always have to be performed no matter what.

In summary, having Array implicitly convert to ArrayView instead of having Array derive from ArrayView results in faster and simpler code at the expense of the compiler refusing the make implicit conversions in some cases when calling template functions. Such conversion problems can always be dealt with by using explicit templat arguments.

Examples:

ParameterList/cxx_main.cpp.

Definition at line 162 of file Teuchos_Array.hpp.


Member Typedef Documentation

template<typename T>
typedef std::vector<T>::value_type Teuchos::Array< T >::value_type

Definition at line 203 of file Teuchos_Array.hpp.

template<typename T>
typedef std::vector<T>::pointer Teuchos::Array< T >::pointer

Definition at line 205 of file Teuchos_Array.hpp.

template<typename T>
typedef std::vector<T>::const_pointer Teuchos::Array< T >::const_pointer

Definition at line 207 of file Teuchos_Array.hpp.

template<typename T>
typedef std::vector<T>::reference Teuchos::Array< T >::reference

Definition at line 209 of file Teuchos_Array.hpp.

template<typename T>
typedef std::vector<T>::const_reference Teuchos::Array< T >::const_reference

Definition at line 211 of file Teuchos_Array.hpp.

template<typename T>
typedef Teuchos_Index Teuchos::Array< T >::Ordinal

Definition at line 214 of file Teuchos_Array.hpp.

template<typename T>
typedef std::vector<T>::iterator Teuchos::Array< T >::iterator

Definition at line 227 of file Teuchos_Array.hpp.

template<typename T>
typedef std::vector<T>::const_iterator Teuchos::Array< T >::const_iterator

Definition at line 229 of file Teuchos_Array.hpp.

template<typename T>
typedef std::vector<T>::reverse_iterator Teuchos::Array< T >::reverse_iterator

Definition at line 231 of file Teuchos_Array.hpp.

template<typename T>
typedef std::vector<T>::const_reverse_iterator Teuchos::Array< T >::const_reverse_iterator

Definition at line 233 of file Teuchos_Array.hpp.

template<typename T>
typedef std::vector<T>::size_type Teuchos::Array< T >::size_type

Definition at line 237 of file Teuchos_Array.hpp.

template<typename T>
typedef std::vector<T>::difference_type Teuchos::Array< T >::difference_type

Definition at line 239 of file Teuchos_Array.hpp.

template<typename T>
typedef std::vector<T>::allocator_type Teuchos::Array< T >::allocator_type

Definition at line 241 of file Teuchos_Array.hpp.


Constructor & Destructor Documentation

template<typename T>
Teuchos::Array< T >::Array (  )  [inline]

Definition at line 653 of file Teuchos_Array.hpp.

template<typename T>
Teuchos::Array< T >::Array ( Ordinal  n,
const value_type value = value_type() 
) [inline, explicit]

Definition at line 661 of file Teuchos_Array.hpp.

template<typename T>
Teuchos::Array< T >::Array ( const Array< T > &  x  )  [inline]

Definition at line 671 of file Teuchos_Array.hpp.

template<typename T>
template<typename InputIterator>
Teuchos::Array< T >::Array ( InputIterator  first,
InputIterator  last 
) [inline]

Definition at line 681 of file Teuchos_Array.hpp.

template<typename T>
Teuchos::Array< T >::Array ( const ArrayView< const T > &  a  )  [inline]

Definition at line 708 of file Teuchos_Array.hpp.

template<typename T>
template<int N>
Teuchos::Array< T >::Array ( const Tuple< T, N > &  t  )  [inline]

Definition at line 720 of file Teuchos_Array.hpp.

template<typename T>
Teuchos::Array< T >::~Array (  )  [inline]

Definition at line 691 of file Teuchos_Array.hpp.

template<typename T>
Teuchos::Array< T >::Array ( const std::vector< T > &  v  )  [inline]

Copy constructor from an std::vector.

Definition at line 1167 of file Teuchos_Array.hpp.


Member Function Documentation

template<typename T>
Array& Teuchos::Array< T >::operator= ( const Array< T > &  a  ) 

template<typename T>
void Teuchos::Array< T >::assign ( Ordinal  n,
const value_type val 
) [inline]

Definition at line 741 of file Teuchos_Array.hpp.

template<typename T>
template<typename InputIterator>
void Teuchos::Array< T >::assign ( InputIterator  first,
InputIterator  last 
) [inline]

Definition at line 748 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::iterator Teuchos::Array< T >::begin (  )  [inline]

Definition at line 756 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::iterator Teuchos::Array< T >::end (  )  [inline]

Definition at line 770 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::const_iterator Teuchos::Array< T >::begin (  )  const [inline]

Definition at line 782 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::const_iterator Teuchos::Array< T >::end (  )  const [inline]

Definition at line 796 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::reverse_iterator Teuchos::Array< T >::rbegin (  )  [inline]

Definition at line 808 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::reverse_iterator Teuchos::Array< T >::rend (  )  [inline]

Definition at line 820 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::const_reverse_iterator Teuchos::Array< T >::rbegin (  )  const [inline]

Definition at line 832 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::const_reverse_iterator Teuchos::Array< T >::rend (  )  const [inline]

Definition at line 844 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::size_type Teuchos::Array< T >::size (  )  const [inline]

Definition at line 856 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::size_type Teuchos::Array< T >::max_size (  )  const [inline]

Definition at line 864 of file Teuchos_Array.hpp.

template<typename T>
void Teuchos::Array< T >::resize ( Ordinal  new_size,
const value_type x = value_type() 
) [inline]

Definition at line 872 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::size_type Teuchos::Array< T >::capacity (  )  const [inline]

Definition at line 880 of file Teuchos_Array.hpp.

template<typename T>
bool Teuchos::Array< T >::empty (  )  const [inline]

Definition at line 887 of file Teuchos_Array.hpp.

template<typename T>
void Teuchos::Array< T >::reserve ( Ordinal  n  )  [inline]

Definition at line 894 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::reference Teuchos::Array< T >::operator[] ( Ordinal  i  )  [inline]

Definition at line 902 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::const_reference Teuchos::Array< T >::operator[] ( Ordinal  i  )  const [inline]

Definition at line 913 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::reference Teuchos::Array< T >::at ( Ordinal  i  )  [inline]

Definition at line 924 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::const_reference Teuchos::Array< T >::at ( Ordinal  i  )  const [inline]

Definition at line 935 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::reference Teuchos::Array< T >::front (  )  [inline]

Definition at line 946 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::const_reference Teuchos::Array< T >::front (  )  const [inline]

Definition at line 957 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::reference Teuchos::Array< T >::back (  )  [inline]

Definition at line 968 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::const_reference Teuchos::Array< T >::back (  )  const [inline]

Definition at line 979 of file Teuchos_Array.hpp.

template<typename T>
void Teuchos::Array< T >::push_back ( const value_type x  )  [inline]

Definition at line 989 of file Teuchos_Array.hpp.

template<typename T>
void Teuchos::Array< T >::pop_back (  )  [inline]

Definition at line 996 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::iterator Teuchos::Array< T >::insert ( iterator  position,
const value_type x 
) [inline]

Definition at line 1015 of file Teuchos_Array.hpp.

template<typename T>
void Teuchos::Array< T >::insert ( iterator  position,
Ordinal  n,
const value_type x 
) [inline]

Definition at line 1030 of file Teuchos_Array.hpp.

template<typename T>
template<typename InputIterator>
void Teuchos::Array< T >::insert ( iterator  position,
InputIterator  first,
InputIterator  last 
) [inline]

Definition at line 1042 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::iterator Teuchos::Array< T >::erase ( iterator  position  )  [inline]

Definition at line 1055 of file Teuchos_Array.hpp.

template<typename T>
Array< T >::iterator Teuchos::Array< T >::erase ( iterator  first,
iterator  last 
) [inline]

Definition at line 1072 of file Teuchos_Array.hpp.

template<typename T>
void Teuchos::Array< T >::swap ( Array< T > &  x  )  [inline]

Definition at line 1089 of file Teuchos_Array.hpp.

template<typename T>
void Teuchos::Array< T >::clear (  )  [inline]

Definition at line 1096 of file Teuchos_Array.hpp.

template<typename T>
Array< T > & Teuchos::Array< T >::append ( const T &  x  )  [inline]

Add a new entry at the end of the array.

Resize to allow space for the new entry.

Definition at line 1106 of file Teuchos_Array.hpp.

template<typename T>
void Teuchos::Array< T >::remove ( int  i  )  [inline]

Remove the i-th element from the array, with optional boundschecking.

Definition at line 1114 of file Teuchos_Array.hpp.

template<typename T>
int Teuchos::Array< T >::length (  )  const [inline]

Return number of elements in the array.

Equivalent to size(), but * included for backwards compatibility.

Definition at line 1125 of file Teuchos_Array.hpp.

template<typename T>
std::string Teuchos::Array< T >::toString (  )  const [inline]

Convert an Array to an std::string.

Definition at line 1132 of file Teuchos_Array.hpp.

template<typename T>
bool Teuchos::Array< T >::hasBoundsChecking (  )  [inline, static]

Return true if Array has been compiled with boundschecking on.

Definition at line 1139 of file Teuchos_Array.hpp.

template<typename T>
T * Teuchos::Array< T >::getRawPtr (  )  [inline]

Return a raw pointer to beginning of array or NULL if unsized.

Definition at line 1150 of file Teuchos_Array.hpp.

template<typename T>
const T * Teuchos::Array< T >::getRawPtr (  )  const [inline]

Return a raw pointer to beginning of array or NULL if unsized.

Definition at line 1157 of file Teuchos_Array.hpp.

template<typename T>
std::vector< T > Teuchos::Array< T >::toVector (  )  const [inline]

Explicit copy conversion to an std::vector.

Definition at line 1177 of file Teuchos_Array.hpp.

template<typename T>
Array< T > & Teuchos::Array< T >::operator= ( const std::vector< T > &  v  )  [inline]

Assignment operator for std::vector.

Definition at line 1187 of file Teuchos_Array.hpp.

template<typename T>
ArrayView< T > Teuchos::Array< T >::view ( Ordinal  offset,
Ordinal  size 
) [inline]

Return non-const view of a contiguous range of elements.

Preconditions:

Postconditions:

Definition at line 1198 of file Teuchos_Array.hpp.

template<typename T>
ArrayView< const T > Teuchos::Array< T >::view ( Ordinal  offset,
Ordinal  size 
) const [inline]

Return const view of a contiguous range of elements.

Preconditions:

Postconditions:

Definition at line 1212 of file Teuchos_Array.hpp.

template<typename T>
ArrayView< T > Teuchos::Array< T >::operator() ( Ordinal  offset,
Ordinal  size 
) [inline]

Return a non-const view of a contiguous range of elements (calls view(offset,size)).

Definition at line 1229 of file Teuchos_Array.hpp.

template<typename T>
ArrayView< const T > Teuchos::Array< T >::operator() ( Ordinal  offset,
Ordinal  size 
) const [inline]

Return a non-const view of a contiguous range of elements (calls view(offset,size)).

Definition at line 1236 of file Teuchos_Array.hpp.

template<typename T>
ArrayView< T > Teuchos::Array< T >::operator() (  )  [inline]

Return an non-const ArrayView of *this.

NOTE: This will return a null ArrayView if this->size() == 0.

Definition at line 1243 of file Teuchos_Array.hpp.

template<typename T>
ArrayView< const T > Teuchos::Array< T >::operator() (  )  const [inline]

Return an const ArrayView of *this.

NOTE: This will return a null ArrayView if this->size() == 0.

Definition at line 1252 of file Teuchos_Array.hpp.

template<typename T>
Teuchos::Array< T >::operator ArrayView< T > (  )  [inline]

Perform an implicit conversion to a non-const ArrayView (calls operator()()).

Definition at line 1261 of file Teuchos_Array.hpp.

template<typename T>
Teuchos::Array< T >::operator ArrayView< const T > (  )  const [inline]

Perform an implicit conversion to a non-const ArrayView (calls operator()()).

Definition at line 1268 of file Teuchos_Array.hpp.


Friends And Related Function Documentation

template<typename T>
template<typename T2>
bool operator== ( const Array< T2 > &  a1,
const Array< T2 > &  a2 
) [friend]

template<typename T>
template<typename T2>
bool operator!= ( const Array< T2 > &  a1,
const Array< T2 > &  a2 
) [friend]

template<typename T>
template<typename T2>
void swap ( Array< T2 > &  a1,
Array< T2 > &  a2 
) [friend]

template<typename T>
template<typename T2>
bool operator< ( const Array< T2 > &  a1,
const Array< T2 > &  a2 
) [friend]

template<typename T>
template<typename T2>
bool operator<= ( const Array< T2 > &  a1,
const Array< T2 > &  a2 
) [friend]

template<typename T>
template<typename T2>
bool operator> ( const Array< T2 > &  a1,
const Array< T2 > &  a2 
) [friend]

template<typename T>
template<typename T2>
bool operator>= ( const Array< T2 > &  a1,
const Array< T2 > &  a2 
) [friend]

template<typename T>
bool operator== ( const Array< T > &  a1,
const Array< T > &  a2 
) [related]

Equality operator.

Definition at line 1379 of file Teuchos_Array.hpp.

template<typename T>
bool operator!= ( const Array< T > &  a1,
const Array< T > &  a2 
) [related]

Non-equality operator.

Definition at line 1384 of file Teuchos_Array.hpp.

template<typename T>
void swap ( Array< T > &  a1,
Array< T > &  a2 
) [related]

Non-member swap (specializes default std version).

Definition at line 1389 of file Teuchos_Array.hpp.

template<typename T>
bool operator< ( const Array< T > &  a1,
const Array< T > &  a2 
) [related]

Less-than operator.

Definition at line 1394 of file Teuchos_Array.hpp.

template<typename T>
bool operator<= ( const Array< T > &  a1,
const Array< T > &  a2 
) [related]

Less-than-or-equal operator.

Definition at line 1399 of file Teuchos_Array.hpp.

template<typename T>
bool operator> ( const Array< T > &  a1,
const Array< T > &  a2 
) [related]

Greater-than operator.

Definition at line 1404 of file Teuchos_Array.hpp.

template<typename T>
bool operator>= ( const Array< T > &  a1,
const Array< T > &  a2 
) [related]

Greater-than-or-equal operator.

Definition at line 1409 of file Teuchos_Array.hpp.

template<typename T>
std::ostream & operator<< ( std::ostream &  os,
const Array< T > &  array 
) [related]

Write an Array to an ostream.

This prints arrays in the form:

 { 1.0, 2.0, 3.0 }

 

Definition at line 1414 of file Teuchos_Array.hpp.

template<typename T>
int hashCode ( const Array< T > &  array  )  [related]

Return the hash code.

Definition at line 1423 of file Teuchos_Array.hpp.

template<typename T>
std::vector< T > createVector ( const Array< T > &  a  )  [related]

Copy conversion to an std::vector.

This function is included for consistency with ArrayView.

Definition at line 1435 of file Teuchos_Array.hpp.

template<typename T>
std::string toString ( const Array< T > &  array  )  [related]

Convert an array to a string representation.

Definition at line 1442 of file Teuchos_Array.hpp.

template<typename T>
Array< T > fromStringToArray ( const std::string &  arrayStr  )  [related]

Converts from std::string representation (as created by toString()) back into the array object.

Parameters:
arrayStr [in] The std::string representation of the array (see below).
Exceptions: If the std::string representation is not valid, then an std::exception of type InvalidArrayStringRepresentation with be thrown with a decent error message attached.

The formating of the std::string arrayStr must look like:

 {  val[0], val[1], val[2], val[3], ..., val[n-1] }

 

Currently operator>>() is used to convert the entries from their std::string representation to objects of type T. White space is unimportant and the parser keys off of ',', '{' and '}' so even newlines are allowed. In the future, a traits class might be defined that will allow for finer-grained control of how the conversion from strings to values is performed in cases where operator>>() does not exist for certain types.

Warning! Currently this function only supports reading in flat array objects for basic types like bool, int, and double and does not yet support nested arrays (i.e. no Array<Array<int> >) or other such fancy nested types. Support for nested arrays and other user defined types T can be added in the future with no impact on user code. Only the parser for the array needs to be improved. More specifically, the current implementation will not work for any types T who's std::string representation contains the characters ',' or '}'. This implementation can be modified to allow any such types by watching for the nesting of common enclosing structures like [...], {...} or (...) within each entry of the std::string representation. However, this should all just work fine on most machines for the types int, bool, float, double etc.

Warning! Trying to read in an array in std::string format of doubles in scientific notation such as {1e+2,3.53+6,...} into an array object such as Array<int> will not yield the correct results. If one wants to allow a neutral std::string representation to be read in as an Array<double> object or an Array<int> object, then general formating such as {100,3530000,...} should be used. This templated function is unable to deal std::complex type conversion issues.

Definition at line 1450 of file Teuchos_Array.hpp.

template<typename T>
void extractDataFromISS ( std::istringstream &  iss,
T &  data 
) [related]

Extracts data from an istringstream object.

Note:
This templated function is necessary for the proper extraction of data by the fromStringToArray function.

Definition at line 618 of file Teuchos_Array.hpp.

template<typename T>
void extractDataFromISS ( std::istringstream &  iss,
std::string &  data 
) [related]

Extracts std::string data from an istringstream object.

Note:
This function overloads the templated extractDataFromISS function and is necessary for the proper extraction of std::string objects by the fromStringToArray function.

Definition at line 630 of file Teuchos_Array.hpp.


The documentation for this class was generated from the following file:
Generated on Wed May 12 21:24:42 2010 for Teuchos - Trilinos Tools Package by  doxygen 1.4.7