#include <iostream>
#include <string>

#include <boost/variant.hpp>

void foo( boost::variant<int,long,std::string> arg )
{
    using namespace std;

    cout << "foo: ";
    switch( arg.which() ) {
    case 0:
        cout << "<int> " << boost::get<int>(arg) << endl;
        break;
    case 1:
        cout << "<long> " << boost::get<long>(arg) << endl;
        break;
    case 2:
        cout << "<string> " << boost::get<std::string>(arg) << endl;
        break;
    }
}

int main() {

    foo( 1 );
    foo( 2L );
    foo( std::string("hello world") );
    //foo( 3u ); // compile error
}
