Boost logo

Boost :

Subject: Re: [boost] [review][assign] Formal review of Assign v2 ongoing
From: er (er.ci.2020_at_[hidden])
Date: 2011-06-22 16:17:51


On 6/22/11 11:47 AM, lcaminiti wrote:
>
> lcaminiti wrote:
>>
>> One question: How do users extend the library to make it work with
>> user-defined containers different from the ones supported "out of the
>> box"?
>> http://svn.boost.org/svn/boost/sandbox/assign_v2/libs/assign/v2/doc/html/boost_assign_v2/apx/cont.html
>>
>
> Can anyone comment also on the question above? (Maybe it's trivial but still
> I'd like to know...)
>

If you want to use a container with a modifier that is already known to
the library, such as insert(), you can already do:

csv_put<insert_, I>( my_cont, a1,...aI, ..., z1, ...,zI); //(*)

although remember I have already made the point that this interface

insert<I>( my_cont )( a1,...aI, ..., z1, ...,zI)

is probably quite easy to implement as well, if requested.

If your container is of the same flavor as push_back but with a special
name, such as my_push_back(), you need to expand these macros:

#include <boost/assign/v2/option/modifier/std.hpp>
BOOST_ASSIGN_V2_OPTION_STD_MODIFIER_TAG(my_push_back)
BOOST_ASSIGN_V2_OPTION_STD_MODIFIER(my_push_back)

There are modifiers that are not standard (STD). For example, iterate
depends on a state, n, which is the starting index (By the way, this
index is restricted to zero in v1, I think). You might be able to guess
how to proceed by following this example

https://svn.boost.org/svn/boost/sandbox/assign_v2/boost/assign/v2/option/modifier/iterate.hpp

If not, let me know, and I'll try to elaborate. Finally, if you want,
say, insert() to be your default i.e. (*) is same as

csv_put<I>( my_cont, a1,...aI, ..., z1, ...,zI);

there are two cases. If your container falls into the category
'associative', for which insert is used by default, you need to put at
the top of your headers, a header that expands this macro:

#include <boost/assign/v2/support/traits/aux_/value_container.hpp>
BOOST_ASSIGN_V2_TRAITS_CONTAINER_CATEGORY(SeqPar, IsCategory,
Identifier, SeqArg)

as shown here:

https://svn.boost.org/svn/boost/sandbox/assign_v2/boost/assign/v2/support/traits/aux_/value_container.hpp

If you container does not fall into category 'associative', you would
have to file in a feature request to override this file

https://svn.boost.org/svn/boost/sandbox/assign_v2/boost/assign/v2/interpreter/modifier.hpp

with a new switch statement. Unfortunately, this file is not open for
extension. Someone with a good grasp of macros might be able to suggest
a remedy.

> Thanks a lot!

My pleasure, thanks for your interest.

> --Lorenzo
>
>
> --
> View this message in context: http://boost.2283326.n4.nabble.com/review-assign-Formal-review-of-Assign-v2-ongoing-tp3603885p3617395.html
> Sent from the Boost - Dev mailing list archive at Nabble.com.
> _______________________________________________
> Unsubscribe& other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


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