
..My question is this: why can't boost::variant be clever about reference data types..
An example will be better than a lengthy explanation, please have a look at the test-cases in the boost distribution: libs/variant/test/: specially variant_reference_test.cpp
IMHO, it will answer all your queries.
Hmm... that doesn't seem to answer my question. boost::variant currently can not handle the following code: struct foo {}; int main(int argc, const char** argv) { foo f; foo* pf = &f; boost::variant<foo*,foo&> v; v = f; printf("%d\n", &boost::get<foo&>(v) == &f); v = pf; printf("%d\n", boost::get<foo*>(v) == pf); pf = NULL; printf("%d\n", boost::get<foo*>(v) != pf) return 0; } My question is essentially this: why couldn't it? Regards, Chris