Boost Variant: как получить текущий удерживаемый тип?

Как я понял, все типы of boost.variant разбираются на реальные типы (то есть, как если бы boost option a; a = "bla-bla" после компиляции превратился бы в строку a; a = "bla-bla" ) И поэтому мне интересно: как узнать, какой тип был помещен в вариант повышения?

Что я пробовал:

#include 
#include 
#include 
#include 

int main()
{
    typedef boost::function func0;
    typedef boost::function func1;
    typedef boost::variant variant_func;
    func1 fn = std::plus();
    variant_func v(fn);
    std::cout << boost::get(v)(1.0, 1.0) << std::endl; // this works
    //std::cout << boost::get(v)(1.0, 1.0) << std::endl; // this does not compile with many errors
    // std::cout << (v)(1.0, 1.0) << std::endl; // this fails with Error    1   error C2064: term does not evaluate to a function taking 2 arguments

    std::cin.get();
    return 0;
}

41
задан myWallJSON 1 December 2011 в 15:52
поделиться