MRPT  2.0.4
typemeta_TTypeName/test.cpp
/* +------------------------------------------------------------------------+
| Mobile Robot Programming Toolkit (MRPT) |
| https://www.mrpt.org/ |
| |
| Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
| See: https://www.mrpt.org/Authors - All rights reserved. |
| Released under BSD License. See: https://www.mrpt.org/License |
+------------------------------------------------------------------------+ */
/** \example typemeta_TTypeName/test.cpp */
//! [example typename]
#include <iostream>
#include <memory> // shared_ptr
// Declare custom user types:
struct MyFooClass
{
};
namespace MyNS
{
struct MyBarClass
{
};
struct MyBarClass2
{
};
} // namespace MyNS
{
using namespace std;
using namespace mrpt::typemeta;
// Evaluation of type names as constexpr strings:
constexpr auto s1 = TTypeName<int32_t>::get();
cout << s1 << endl;
cout << TTypeName<set<vector<double>>>::get() << endl;
// Evaluation of user-defined types:
cout << TTypeName<MyFooClass>::get() << endl;
cout << TTypeName<MyFooClass::Ptr>::get() << endl;
cout << TTypeName<MyNS::MyBarClass>::get() << endl;
cout << TTypeName<MyNS::MyBarClass2>::get() << endl;
// STL typenames as strings:
cout << TTypeName<double>::get() << endl;
cout << TTypeName<vector<double>>::get() << endl;
cout << TTypeName<array<int32_t, 5>>::get() << endl;
cout << TTypeName<set<double>>::get() << endl;
cout << TTypeName<pair<int32_t, pair<int32_t, int32_t>>>::get() << endl;
cout << TTypeName<map<double, set<int32_t>>>::get() << endl;
cout << TTypeName<set<
multimap<double, pair<MyFooClass, MyNS::MyBarClass2>>>>::get()
<< endl;
}
//! [example typename]
int main(int argc, char** argv)
{
try
{
return 0;
}
catch (const std::exception& e)
{
std::cerr << "MRPT error: " << e.what() << std::endl;
return -1;
}
}



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020