Opened 11 years ago

#6590 new Feature Requests

BOOST_AUTO fails on C++11 lambdas

Reported by: Anders Kaseorg <andersk@…> Owned by: Peder Holt
Milestone: To Be Determined Component: typeof
Version: Boost 1.48.0 Severity: Problem
Keywords: Cc:

Description

BOOST_AUTO fails on C++11 lambdas as follows (tested with g++ 4.6.2-14ubuntu2):

#include <boost/typeof/typeof.hpp>
BOOST_AUTO(f, [](){});
$ g++ -c -std=c++0x test.cc
test.cc:2:1: error: lambda-expression in unevaluated context
test.cc:2:1: error: conversion from ‘<lambda()>’ to non-scalar type ‘<lambda()>’ requested

Although it’s apparently not possible to use typeof or decltype on a lambda expression, this could be fixed by defining BOOST_AUTO with C++11 auto on compilers that support it:

#define BOOST_AUTO(Var, Expr) auto Var = Expr
BOOST_AUTO(f, [](){});

Change History (0)

Note: See TracTickets for help on using tickets.