Boost logo

Boost Users :

Subject: [Boost-users] boost variant compile time visitation: verification
From: Hicham Mouline (hicham_at_[hidden])
Date: 2009-04-21 09:45:55


Hello,

#include <iostream>
#include <boost/variant/variant.hpp>

typedef boost::variant<int, double, char> VT;

struct print_type : public boost::static_visitor<const char*> {
  const char* operator()( int )
  {
    return "int";
  }
  const char* operator()( double )
  {
    return "double";
  }
  const char* operator()( char )
  {
    return "char";
  }
};

int main()
{
  VT v('c');
  std::cout<< v.apply_visitor( print_type() ) <<std::endl;;
}

If I understood the doc correctly, the visitation is supposed to be
compile-time,
that is, v.apply_visitor( print_type() ) is already "char" before the
program start...
Is this right?

If so, is there a way to see this in the binary executable file? Maybe
viewing symbols?
I have access to vs2005 and g++3/4 /linux platforms.

It would be so fantastic if compilers output _also_ the C++ source resulting
from the template machinery!

Best regards,


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net