Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2007-01-01 16:15:57


Tobias Schwinger wrote:
> Christian Holmquist wrote:
>>
>> I would be very interested in using your extension.
>>
>
> Hey, that sounds motivating! Me too ;-). I'll get back to it - but I probably won't get anything done before the beginning of next week.
>

Here it is:

     http://tinyurl.com/ydoq9b (zip archive in the Boost file vault)

The components depend on Boost.FunctionTypes:

     http://tinyurl.com/qaf5f (zip archive in the Boost file vault)

The archive contains six components to transform and call functionals
including unit tests. I'll attach the README file with a brief reference
manual to this post as an appetizer.

The features proposed earlier in this discussion have been implemented
except parametrization of the sequence, because Fusion currently does
not provide some kind of "tag-dispatched construction mechanism" (a
metafunction that, given a sequence (or sequence tag) and some view,
computes a sequence type with a constructor that accepts the types in
the view as its arguments) which would be needed to do it right. Given
the choice between making a very intrusive proposal or messing up my own
code by making it inextensible, I decided that the feature wouldn't be
worth it (just using fusion::vector for feeding fused functions, for now).

fusion::unpack_args has been renamed to fusion::invoke, got some
polishing and was moved to the functional folder (with the new
components in place, that's clearly where it belongs). I also added a
function wrapper that binds the first argument to fusion::invoke called
fusion::fused.

Thanks to João Abecasis at this point for writing fusion::unpack_args.

Regards - and happy new year,
Tobias


  Boost.Fusion functionals subsystem proposal.

  (C) Copyright João Abecasi and Tobias Schwinger

  Use modification and distribution are subject to the Boost Software License,
  Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt).

<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>

Requirements
============

The components within this archive depend on FunctionTypes, a Boost library that
has not been added to the CVS yet.
The archive function_types.zip is located in the Template Metaprogramming folder
of the Boost file vault.

    http://boost-consulting.com/vault ......... Boost file vault
    http://tinyurl.com/qaf5f .................. FunctionTypes, download link

Files
=====

    boost/fusion/functional/detail/access.hpp
    boost/fusion/functional/detail/gen_nullary_result_of_spec.hpp
    boost/fusion/functional/detail/has_type.hpp
    boost/fusion/functional/detail/nullary_call_base.hpp
    boost/fusion/functional/detail/pow2_explode.hpp
    boost/fusion/functional/detail/pt_def.hpp
    boost/fusion/functional/detail/pt_undef.hpp
    boost/fusion/functional/detail/that_ptr.hpp
    boost/fusion/functional/fused.hpp
    boost/fusion/functional/invoke.hpp
    boost/fusion/functional/limits.hpp
    boost/fusion/functional/unfused_generic.hpp
    boost/fusion/functional/unfused_lvalue_args.hpp
    boost/fusion/functional/unfused_rvalue_args.hpp
    boost/fusion/functional/unfused_typed.hpp
    libs/fusion/test/functional/fused.cpp
    libs/fusion/test/functional/invoke.cpp
    libs/fusion/test/functional/unfused_generic.cpp
    libs/fusion/test/functional/unfused_lvalue_args.cpp
    libs/fusion/test/functional/unfused_rvalue_args.cpp
    libs/fusion/test/functional/unfused_typed.cpp
    libs/fusion/test/Jamfile
    libs/fusion/test/Jamfile.patch
    README_FUSION_FUNCTIONAL.TXT

Quick Reference
===============

Concepts

Regular Function defines the superset of builtin functionals (such as function
pointers) and function objects that work with boost::result_of.

Components

    template< class Function > class unfused_generic;
    template< class Function > class unfused_lvalue_args;
    template< class Function > class unfused_rvalue_args;

Transform Polymorphic Function Objects that take a single Sequence into Regular
Functions that accept a variable number of generic arguments.

Restrictions can be applied by removing the type member from the nested result
metafunction (in this case SFINAE applies for non-nullary calls - the nullary
call is taken care of by the library, be aware that the nullary call operator
can't be a template and thus results in earlier instantiation, however).

The rvalue and lvalue variants only accept const and non-const references
respectively.

    template< class Function, class Sequence > class unfused_typed;

Transform Polymorphic Function Objects that take a single Sequence into Regular
Functions that accept a variable number of strict typed arguments. The second
template parameter specifies the types in form of a Fusion sequence.

Restrictions can be applied by removing the type member from the nested result
metafunction (in this case SFINAE applies for non-nullary calls - the nullary
call is taken care of by the library, be aware that the nullary call operator
can't be a template and thus results in earlier instantiation, however).

    template< typename Function > class fused;

Transforms a Regular Function into a Polymorphic Function Object that takes a
Sequence with the arguments for the transformed function.

The Function template parameter may be const or a reference. Const qualification
is preserved and propagated appropriately.

    namespace result_of
    {
        template< typename Function, class Sequence > struct invoke;
    }

    template< typename Function, class Sequence >
    inline typename result_of::invoke<Function, Sequence>::type
    invoke(Function, Sequence &);

    template< typename Function, class Sequence >
    inline typename result_of::invoke<Function, Sequence const>::type
    invoke(Function, Sequence const &);

Calls a Regular Function with the arguments from a Sequence.

The first template parameter can be specialized explicitly to avoid copying
and to control the const qualification of the function.


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