rendered paste body#include <boost/variant.hpp>#include <string>#include <iostream>class boolean_visitor : boost::static_visitor<bool> {public: bool operator()( int& i ) { if( i == 0 ) { return false; } return true; } bool operator()( std::string& str ) { if( str.empty() ) { return false; } return true; } bool operator()( float& f ) { if( f == 0.0 ) { return false; } return true; }};int main( int argc, char** argv ) { boost::variant< int, std::string, float > cvar; cvar = "Hello, World!"; std::cout << cvar << std::endl; if( boost::apply_visitor( boolean_visitor(), cvar ) ) { std::cout << "true" << std::endl; } cvar = 0; std::cout << cvar << std::endl; if( boost::apply_visitor( boolean_visitor(), cvar ) ) { std::cout << "true" << std::endl; } cvar = 3.14f; std::cout << cvar << std::endl; if( boost::apply_visitor( boolean_visitor(), cvar ) ) { std::cout << "true" << std::endl; } return( 0 );}