Boost logo

Boost :

Subject: [boost] [typeof] Non-static data member
From: Bjorn Reese (breese_at_[hidden])
Date: 2013-12-12 07:04:05


Consider the following example:

   void foo(int value) {}
   struct alpha {
     int value;
     typedef BOOST_TYPEOF(foo(value)) return_type;
   };

This example compiles just fine with g++, but with clang++ it only
works if compiled with -std=c++11, otherwise it gives the error
message below. I believe that clang is correct (this diagnostics was
added in clang 3.1 [1].)

   https://llvm.org/viewvc/llvm-project?view=revision&revision=154073

Is this a bug in Boost.Typeof or is it expected behavior? Is there a
workaround for it?

The error message is:

/home/breese/src/treediff/treediff/main.cpp:17:30: error: invalid use of
non-static data member 'value'
     typedef BOOST_TYPEOF(foo(value)) return_type;
                              ^~~~~
/usr/local/include/boost/typeof/native.hpp:41:76: note: expanded from
macro 'BOOST_TYPEOF'
#define BOOST_TYPEOF(expr)
BOOST_TYPEOF_KEYWORD(boost::type_of::ensure_obj(expr))
 
     ^
1 error generated.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk