arrow_back_ios Back to List


Offload KB - features

Old Content Alert

Please note that this is a old document archive and the will most likely be out-dated or superseded by various other products and is purely here for historical purposes.

As of release 2.5 (19th Dec 2011) the Offload C++ compiler provides the intrinsic __cp_typestringliteral(type) which returns the string literal of a type. This can be useful for example when debugging templated code, but also to determine the type of variables or typedefs whose declarations do not make it obvious what the actual type is (for example could be declared using another typedef or template).

#include <iostream>

template <class T> void f(T)
   printf("The type is %s \n",__cp_typestringliteral(T));

template <class T> struct str {};

int main()
    f([](){return str<double>();});
    printf("std::cout is of type %s
", __cp_typestringliteral(decltype(std::cout)) );

The above code prints:

The type is struct str<int >The type is lambda<mainlambdatest2.cpp(13)>std::cout is of type class std::basic_ostream<char ,std::char_traits<char > >