Boost logo

Boost :

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


Some updated information so you guys aren't left in the dark -- in true
boost form, what started as a simple 1-line macro has evolved into a
thousand line file, though it is well worth it as I've expanded the
capabilities considerably. The macro now supports a very powerful
concept-like "requires", explicit return types including "lazy return types"
(similar to lazy_enable_if), "requires_expression" support which allows you
to specify arbitrary expression requirements, and the ability to separate
declarations from implementation in cases where the return type is specified
explicitly.

In the end, the macro not only handles automatic return type deduction but
it should also be able to act as a more powerful replacement for enable_if
with respect to function templates. With some further effort, additional
macros could be made to work with type templates and constructors as well,
in a manner a little more similar to enable_if.

To see how the macro is used go here:
http://codepaste.net/4u34ma

<http://codepaste.net/4u34ma>As of right now variadic macros are required,
however, I could easily make them optional if I always require users to put
more parenthesis in particular places (I.E. surrounding the code in a
"requires" regardless of whether or not there is a comma there), though I'm
not certain that I wish to go this route as, as far as I'm aware, all
compilers that support trailing return type also support variadic macros.
So, implementing it without variadic macros may just be forcing programmers
to use lisp-level amounts of parentheses for no reason.

I was hoping to have everything documented and up by now, but I'm still
fleshing things out. At this time I'm working on some tricks to make misuse
reported in an easy-to-read manner through some fancy preprocessor tricks
and static_assert/mpl assert message. After that I believe it should be
done.

-- 
-Matt Calabrese

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk