
8 Sep
2008
8 Sep
'08
3:39 p.m.
AMDG Ovanes Markarian wrote:
so you mean there are no VTable fakes inside as it is suggested by Andrei and in fact an additional numeric type identifier is stored? Which type from the type list is stored?
At the lowest level, boost::variant<std::string, int> (e.g.) looks something like: class variant { boost::aligned_storage< max(sizeof(std::string), sizeof(int)), lcm(alignment_of<std::string>::value, alignment_of<int>::value)> buffer_; int which_; }; apply_visitor is implemented something to the effect of switch(which_) { case 0: return(f(*static_cast<std::string*>(buffer_.address()))); case 1: return(f(*static_cast<int*>(buffer_.address()))); } In Christ, Steven Watanabe