Boost Users :
Subject: Re: [Boost-users] How does BOOST_TYPEOF works?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-10-20 23:30:42
Peng Yu wrote:
> I tried to read the source code to figure out how BOOST_TYPEOF works.
> But I still don't understand how it works. Can somebody tell me how it
It works in 3 different ways depending on your compiler.
1) If your compiler has a typeof operator, Boost.Typeof uses that.
2) If your compiler has a specific bug that allows certain class
templates to be specialized on the fly, Boost.Typeof uses this
capability to associate each type with a unique integer and
get something to the effect of
where get_size is defined as
char (&get_size(const T&))[get_associated_int<T>::value];
3) If all else fails, Boost.Typeof associates a unique integer with each
type/class template. (This is what BOOST_TYPEOF_REGISTER_TYPE and
friends are for). Then, every type can be represented as a sequence
This sequence of integers is retrieved using sizeof.
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