1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| #include <iostream>
#include <boost/any.hpp>
#include <vector>
#include <string>
#include <boost/enum.hpp>
BOOST_ENUM_VALUES( boolean1, std::string,
(True1)("true1")
(False1)("false1")
)
BOOST_ENUM_VALUES( boolean2, std::string,
(True2)("true2")
(False2)("false2")
)
void displayValues( const boost::any& val )
{
//...
}
int main( int argc, char* argv[] )
{
std::vector< boost::any > vect;
boolean1 b1;
boolean2 b2;
vect.push_back( b1 );
vect.push_back( b2 );
for( int idx = 0; idx < vect.size(); idx++ )
{
std::cout << idx << "-->" << std::endl;
displayValues( vect[idx] );
}
return 0;
} |
Partager