Boost logo

Boost :

From: Felipe Magno de Almeida (felipe.m.almeida_at_[hidden])
Date: 2007-10-16 21:37:32

On 10/16/07, Felipe Magno de Almeida <felipe.m.almeida_at_[hidden]> wrote:
> On 10/16/07, David Abrahams <dave_at_[hidden]> wrote:

I probably wasn't clear enough. I'll try better now.


> > > wnd_lock<text_box> text = create<text_box>( _parent = w, _pos =
> > > std::make_pair(0, 0)
> > > , text_box::_multi_line = true );
> > >
> > > Is it achievable?
> >
> > Sorry, it isn't clear from the above what you mean by "extended
> > keywords?" Is it just the use of text_box:: qualification on
> > _multi_line?
> No, I would like that my function would accept an unbound number of
> keyword types.
> _multi_line for example could be implemented by a third-party, and I
> would like it to work with create<> function anyway.

What I want is a way for users to define keywords which would work
with my function.
I have implemented something more or less like that, but it is more
like another, yet very simple, named parameter concept. But it relies
on passing a specific object type (that contains a boost::any).
I would like that keywords and overload resolution could be
implemented seperately and used inside that function. The function,
being a template, could then adapt to what it received as arguments
and parameters.
It was like was defining that certain keywords would be obligatory,
but all others (known or not known by the function) are optional.
These keywords types could then implement a concept which would allow
the named parameter function to use those parameters and arguments.
Hope it is clearer now.
So, is it possible with Boost.Parameter library?

PS: What I have substituting this is having types that return an
object of type 'expression'. Then through PP magic I have all numbers
of parameters receiving expression objects and named parameters. But
this way I can't template the whole function and leave duck-typing to
after the create instantiation.

So I have something like this:

#define GUI_arguments(z, n, data) A ## n const& arg ## n
#define GUI_create_extension_args(z, n, data) extension const&
BOOST_PP_CAT(ext, n)
#define GUI_extension_push_backs(z, n, data)
extensions.push_back(BOOST_PP_CAT(ext, n));

template <typename impl,
GUI_arguments, ~)

  , BOOST_PP_ENUM(BOOST_PP_ITERATION_1, GUI_create_extension_args, ~)

  , typename create_parameter::match<BOOST_PP_ENUM_PARAMS(BOOST_PP_ADD(BOOST_PP_ITERATION(),1),
A)>::type const& args = create_parameter())
  std::vector<extension> extensions;

BOOST_PP_REPEAT(BOOST_PP_ITERATION_1, GUI_extension_push_backs, ~)

  return create_impl<impl>(args(BOOST_PP_ENUM_PARAMS(BOOST_PP_ADD(BOOST_PP_ITERATION(),1),
arg)), extensions);

Where it iterates two times to have two counters. But I can't mix
defined keywords and extension keywords this way.

> > --
> > Dave Abrahams
> > Boost Consulting
> >

Thanks in advance,

Felipe Magno de Almeida

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