Teamcenter C++ API Reference  2312
Functions
Teamcenter::Util Namespace Reference

Functions

template<typename T >
array_length (size_t s)
 
template<typename Container , typename Vector >
void copyBack (const Container &container, Vector &vector)
 

Function Documentation

template<typename T >
T Teamcenter::Util::array_length ( size_t  s)

Converts from one type to another using a static_cast call.
This template function is of special interest to correct conversion issues from "unsigned_int64" to "int", which arise with Visual Studio 2013 (error C4244 - "'=' : conversion from 'unsigned __int64' to 'int'").


The following code would generate a compilation error C4244 with Visual Studio 2013, because std::vector - size() returns the size of an array using the "unsigned __int64" type.

//Compilation error:
//*n_values = pvmValues.size();
*n_values = Util::array_length<int>( pvmValues.size() );

Definition at line 62 of file TcBaseUtils.hxx.

template<typename Container , typename Vector >
void Teamcenter::Util::copyBack ( const Container &  container,
Vector &  vector 
)

Copies all elements in the Container into the back of the Vector.
The container can be any of Standard Template Library (STL)-derived container that stores a collection of other objects and provides access either directly or through iterators.

//tags1, tags2, tags3 are TagVector
TagVector allTags;
Util::copyBack( tags1, allTags );
Util::copyBack( tags2, allTags );
Util::copyBack( tags3, allTags );
//allTags now contains tags1 + tags2 + tags3
Parameters
container(I) The container to copy from
vector(O) The vector to copy to

Definition at line 40 of file TcBaseUtils.hxx.