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].)

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
#define BOOST_TYPEOF(expr)
1 error generated.

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