Opened 9 years ago
Closed 9 years ago
#9511 closed Bugs (invalid)
Non-static data member
Reported by: | Owned by: | Peder Holt | |
---|---|---|---|
Milestone: | To Be Determined | Component: | typeof |
Version: | Boost 1.54.0 | Severity: | Problem |
Keywords: | Cc: |
Description
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.)
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.
Note:
See TracTickets
for help on using tickets.
This behavior is expected. There's absolutely nothing that Boost.Typeof can do about it anyway. Workaround: foo(boost::declval<alpha&>().value).