Boost logo

Boost :

From: Vesa Karvonen (vesa_karvonen_at_[hidden])
Date: 2002-03-19 06:09:47

>I'm trying to use the BPL for the following and I'm kind of stuck.

I have trouble understanding the intention. If you just want a new syntax
for specifying function types, then I would recommend to not do it. If you
want a macro for specifying functions types that take N arguments of a
single type, then there might be some sense. What is it that you are trying
to macroize?

Are you positive about the syntax of function typedefs that you seem to be
trying to achieve? The following is a representative of a function
declaration (of 1 parameter):

  ret_type fun_name(param);

To get a typedef from any declaration, you just put `typedef´ in front of
the declaration:

  typedef ret_type fun_type(param);

Anyway, you obviously need to pass the param to the macro. Try the

  #include <boost/preprocessor.hpp>

  #define MAKE_FUNCTION_TYPE_NAME(f_name)\

  #define MAKE_TYPEDEF_N(ret_type,f_name,n_params,param)\
    typedef ret_type f_name(MAKE_FUNCTION_TYPE_NAME(f_name))\

  #define TYPEDEF_0(ret_type,f_name)\
  #define TYPEDEF_1(ret_type,f_name,param0)\

The above (probably) isn't what you were after, however. You probably want
to be able to pass an arbitrary number of parameters:


And get:

  typedef void bar(bar_type)(foo_type,int,long)

The above can be done, but I do not understand the motivation. You might
want to consider using lists.

Get your FREE download of MSN Explorer at

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