Boost logo

Boost :

From: John Femiani (JOHN.FEMIANI_at_[hidden])
Date: 2007-05-13 17:33:48

Hi all,


I wrote a little macro that uses BOOST_TYPEOF to determine the type of
one of its arguments, but it fails when I pass (*this) as an argument in
vc8. I forced emulation because, according to the docs, vc8 does not
seem to have the bug that let other vc compilers actually support native
typeof. I don't know the internals of the TYPEOF library well enough
to diagnose the problem, but the error is easy to produce.




#include <boost/typeof/typeof.hpp>



template<class Inner> struct A;





    { \

      BOOST_TYPEOF_TPL(X) &ref = X; \

      BOOST_TYPEOF_TPL(X)::inner_t inner = X.inner(); \




template<class Inner>

struct A{

    typedef Inner inner_t;


    inner_t inner() {

        return Inner();



    void do_something() {

        A<Inner>& star_this = *this;


        USES_TYPEOF_IN_A_MACRO(*this); //ERROR!






void main(){

  A<int> a;




If there is any way to accomplish the type of access I am attempting
from inside a macro I would really appreciate it (in my use case macros
seem to be absolutely necessary for other reasons). As you can see from
the example it is possible to avoid the problem by creating a reference
to *this and passing that, but I do not like this in principle because
too many caveats make the macro difficult to use.




Boost list run by bdawes at, gregod at, cpdaniel at, john at