Boost logo

Boost :

Subject: Re: [boost] [contract] C++11-like auto-functions
From: lcaminiti (lorcaminiti_at_[hidden])
Date: 2012-07-02 09:19:15

Dave Abrahams wrote
> on Wed Jun 27 2012, Lorenzo Caminiti <> wrote:
>> Hello all,
>> I'm thinking to expand Boost.Contract to support C++11-like
>> auto-functions for C++03.
>> I got a ticket for it:
>> But I might implement it only after the Boost review... (Are C++11
>> auto-function really useful?)
> auto functions arelly are useful, but mostly they're useful with a macro
> that calculates noexcept, return type, etc.:

I see but that only applies to C++11 and not to auto-functions emulated in
C++03 (because there's no noexcept in C++03). Also, these type of macros
only apply to 1-liner functions (of course, as you show using operator, you
can concatenate a bunch of expressions on a single line).

Contract++ could support something like that:

// auto swap(B& x, B& y) RETURNS(swap(x.a,y.a), swap(x.b,y.b), ...);

struct B { A a, b; }

// Defines swap to return `return ...` and automatically figures out
noexcept (on C++11).
    auto (swap) ( (B&) x, (B&) y )
        return(swap(x.a, y.a), swap(x.b, y.b))

I'll think more about this when/if I implement auto-functions support for


View this message in context:
Sent from the Boost - Dev mailing list archive at

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