[cfe-commits] r151117 - in /cfe/trunk: include/clang/AST/ExprCXX.h include/clang/Sema/Sema.h lib/Parse/ParseDeclCXX.cpp lib/Sema/Sema.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaExprCXX.cpp lib/Sema/SemaOverload.cpp lib/Sema/TreeTransform.h test/CXX/d

Richard Smith richard at metafoo.co.uk
Tue Feb 21 21:00:08 PST 2012


On Tue, Feb 21, 2012 at 8:38 PM, Michel Morin <mimomorin at gmail.com> wrote:

> > Log:
> > Implement C++11 [expr.call]p11: If the operand to a decltype-specifier
> is a
> > function call (or a comma expression with a function call on its
> right-hand
> > side), possibly parenthesized, then the return type is not required to be
> > complete and a temporary is not bound. Other subexpressions inside a
> decltype
> > expression do not get this treatment.
>
> Is there any way to detect this C++11 decltype feature?
> `__has_feature(cxx_decltype)` does not work,
> since this macro also detects pre-N3276 decltype.
> (Boost.Config needs to detect N3276 decltype.)
>

There's no __has_feature check for it, but it's pretty easy to detect with
SFINAE (check for SFINAE access control first if you want to use this
particular approach):

template<typename T, typename U>
struct enable_if_type { typedef U type; };

template<typename T> false_type has_decltype_no_temp(...);
template<typename T> typename enable_if_type<decltype(T()),
true_type>::type has_decltype_no_temp(int);

class S { ~S(); };
using has_feature_decltype_no_temp = decltype(has_decltype_no_temp<S>(0));

- Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120221/e46ef8ef/attachment.html>


More information about the cfe-commits mailing list