Boost C++ Libraries: Ticket #9511: Non-static data member https://svn.boost.org/trac10/ticket/9511 <p> Consider the following example: </p> <pre class="wiki"> void foo(int value) {} struct alpha { int value; typedef BOOST_TYPEOF(foo(value)) return_type; }; </pre><p> 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 <a class="ext-link" href="https://llvm.org/viewvc/llvm-project?view=revision&amp;revision=154073"><span class="icon">​</span>added</a> in clang 3.1.) </p> <p> Is this a bug in Boost.Typeof or is it expected behavior? Is there a workaround for it? </p> <p> The error message is: </p> <pre class="wiki">/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. </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9511 Trac 1.4.3 Steven Watanabe Fri, 04 Apr 2014 01:50:11 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/9511#comment:1 https://svn.boost.org/trac10/ticket/9511#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> This behavior is expected. There's absolutely nothing that Boost.Typeof can do about it anyway. Workaround: foo(boost::declval&lt;alpha&amp;&gt;().value). </p> Ticket