
Following my prev message, I wrote the following test on a win platform, compiled with VS2005 /O2 in release mode #include <iostream> #include <boost/variant/variant.hpp> #include <windows.h> 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() { const VT v('c'); LARGE_INTEGER usec0, usec1; const char* volatile res; QueryPerformanceCounter( &usec0 ); for(size_t s=0; s<2000000; ++s) res = v.apply_visitor( print_type() ); QueryPerformanceCounter( &usec1 ); std::cout<< (usec1.QuadPart - usec0.QuadPart) <<std::endl; QueryPerformanceCounter( &usec0 ); for(size_t s=0; s<2000000; ++s) res = "char"; QueryPerformanceCounter( &usec1 ); std::cout<< (usec1.QuadPart - usec0.QuadPart) <<std::endl; } There is no statistically significant difference between the 2 cases. Can I deduce that at least on this platform, for this code, the visitation is done at compile-time? Rds,