Boost logo

Boost :

Subject: Re: [boost] RFC Expression Validity Asserts
From: Matt Calabrese (rivorus_at_[hidden])
Date: 2015-01-22 22:16:26

On Thu, Jan 22, 2015 at 6:49 PM, TONGARI J <tongari95_at_[hidden]> wrote:

> You're right, I misunderstood the situation.
> Your code doesn't work for clang, it seems to be more strict than g++:
> "error: a lambda expression may not appear inside of a constant
> expression"
> I suspect it's also a bug, since a hand-written functor does compile.

Hmm, this might be the problem, but I'm still not sure if this is a
compiler bug or not. According to the standard, the type of the object
yielded by a lambda expression has an implicitly declared default
constructor/copy constructor/destructor as they are for any other type, and
since the type is stateless, that would mean that those operations are
constexpr. I don't mind that operator() isn't constexpr because I never
actually use it as such.

I suppose that if someone were to be pedantic, they could argue that even
though all of the constructors are constexpr, the object still might not
necessarily be a constant expression. Still, I'm not certain that the
omission of such a detail would imply that the object isn't a constant
expression. I think the standard may have just unintentionally left this
unspecified, in which case it would be valid for a compiler to accept this
code or for a compiler to deny the code.

-Matt Calabrese

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