MRPT  2.0.4
typemeta_TEnumType/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_TEnumType/test.cpp */
//! [example]
#include <iostream>
#include <string>
// Example declaration of "enum class"
enum class TestColors
{
Black = 0,
Gray = 7,
White = 15
};
// Example declaration of plain enum
{
};
// Example declaration of "enum class"
{
using namespace std;
using namespace mrpt::typemeta;
cout << "White => " << (int)TEnumType<TestColors>::name2value("White")
<< endl;
cout << "Black => " << (int)TEnumType<TestColors>::name2value("Black")
<< endl;
cout << "Gray => " << (int)TEnumType<TestColors>::name2value("Gray")
<< endl;
<< endl;
}
//! [example]
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