Boost logo

Boost :

From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2002-05-12 16:20:44


(message split in two because it was too big - this is part 1)

> > What exactly do we need from an arity_traits/function_traits class? To
> be more
> > clear, what should be in it, and is it a necessity that it compile on
> > non-compliant compilers (i.e. partial specialization)?
>
> before this goes too much further, please see:
>
> boost/python/detail/arg_tuple_size.hpp
> boost/python/preprocessed/arg_tuple_size.hpp
>
> Enjoy,
> Dave

Dave, I just rewrote this file using the preprocessor library that I mentioned
earlier. Here is an exact copy of the file:
------------------------------
#if !defined(IS_ITERATING)

#ifndef ARG_TUPLE_SIZE_HPP_CHAOS_PP_
#define ARG_TUPLE_SIZE_HPP_CHAOS_PP_

#include <boost/config.hpp>
#include <boost/python/detail/char_array.hpp>

#include "chaos.h"

namespace boost { namespace python { namespace detail {

#ifndef BOOST_PYTHON_MAX_ARITY
#define BOOST_PYTHON_MAX_ARITY 50
#endif

template<class F> struct arg_tuple_size;

??=include ENABLE(iterate.hxx)

    #define BOUND 0
    #include SET_LBOUND()

    #define BOUND BOOST_PYTHON_MAX_ARITY
    #include SET_UBOUND()

    #define FILENAME_1 "arg_tuple_size.hpp"
    #include ITERATE()

??=include DISABLE(iterate.hxx)

#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)

template<class F> struct arg_tuple_size {
    BOOST_STATIC_CONSTANT(std::size_t, value =
sizeof(arg_tuple_size_helper(F(0)).elements - 1);
};

#endif

}}} // boost::python::detail

#endif

#elif DEPTH() == 1

    #line LINE(__LINE__, arg_tuple_size.hpp)

    #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
        template<class R INSERT_PUNC(FILE_ARG(), COMMA) LIST_CLASS(FILE_ARG(),
A)>
        struct arg_tuple_size<R (LIST_IDS(FILE_ARG(), A))>
        {
            BOOST_STATIC_CONSTANT(std::size_t, value = FILE_ARG());
        };
    #else
        template<class R INSERT_PUNC(FILE_ARG(), COMMA) LIST_CLASS(FILE_ARG(),
A)>
        char_array<FILE_ARG()> arg_tuple_size_helper(R (*)(LIST_IDS(FILE_ARG(),
A)));
    #endif

    #define BOUND 0
    #include SET_LBOUND()

    #if !defined(__MWERKS__) || __MWERKS__ > 0x2407
        #define BOUND 3
    #else
        #define BOUND 1
    #endif
    #include SET_UBOUND()

    #define FILENAME_2 "arg_tuple_size.hpp"

    #define AUX EXPAND(4, (NIL, LAMBDA(const), LAMBDA(volatile), LAMBDA(const
volatile)))
    #include ITERATE()

#elif DEPTH() == 2

    #line LINE(__LINE__, arg_tuple_size.hpp)

    #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
        template<class R, class O INSERT_PUNC(RELATIVE_ARG(1), COMMA)
LIST_CLASS(RELATIVE_ARG(1), A)>
        struct arg_tuple_size<R (O::*)(LIST_IDS(RELATIVE_ARG(1), A))
APPLY(GET(FILE_ARG(), AUX))>
        {
            BOOST_STATIC_CONSTANT(std::size_t, value = INCR(RELATIVE_ARG(1)));
        };
    #else
        template<class R, class O INSERT_PUNC(RELATIVE_ARG(1), COMMA)
LIST_CLASS(RELATIVE_ARG(1), A)>
        char_array<INCR(RELATIVE_ARG(1))>
        arg_tuple_size_helper(R (O::*)(LIST_IDS(RELATIVE_ARG(1), A))
APPLY(GET(FILE_ARG(), AUX));
    #endif

#endif
-------------------------

...continued in part 2.


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