Boost logo

Boost :

Subject: Re: [boost] Call for interest - BOOST_AUTO_FUNCTION
From: Matt Calabrese (rivorus_at_[hidden])
Date: 2010-10-20 16:51:51

On Tue, Oct 19, 2010 at 3:34 AM, Matt Calabrese <rivorus_at_[hidden]> wrote:

> All of these details can be worked out after I submit it for review, and at
> that point, pending it even gets accepted, if there is a strong opinion in
> one direction I will make changes, but as of right now I'd rather just get
> back to focusing on functionality.

Alright, I have an interesting way to handle checking arbitrary expression
requirements for the automatically deduced result type, but I'm not sure
it's standard.:It's actually kind of nasty, but I think it would work and it
also has the side-effect of allowing users to pass a series of statements,
including declarations, to "try" and "continue try", instead of a
preprocessor sequence of expressions (though compilers can't handle it yet).

For a macro invocation such as this:

template< class T >
, ( continue try some_required_function( _result_() ); some_other_function(
_result_() ); )
, ( return arg + 1; )

It would generate code where something such as the following would appear at
some point in the return type, for purposes of SFINAE:

decltype( [&]( decltype( [&]{ return arg; }() ) (*_result_)()
){ some_required_function( _result_() )); some_other_function( _result_()
);; } )

That's a mouthful, I know, but essentially what's happening is I'm creating
a lambda that has a function pointer parameter called "_result_" with a
return type that matches that of the "auto function", and in the body of
that lamda function it simply repeats the arguments passed to "continue
try". The reason why _result_ is a function pointer that is invoked as
opposed to simply a parameter whose type is a reference to the result type
is because doing that would force the value to be an lvalue when used in
expressions. By making _result_ a function pointer to be called, we can be
certain that its use in tested expressions has exactly the properties as
that of using the result type of the "auto function". If the user wishes to
test the result as if it were an lvalue, he'd either create a declaration,
or I could simply add a second parameter to the lambda function called
"_lvalue_result_" whose type is a reference to the result type of the "auto

It's pretty gross, but I think it might be standard. It won't be implemented
for a while though, as I have no way to test it.

-Matt Calabrese

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