MRPT  2.0.1
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.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020