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