std.boxer and arrays
Aarti_pl
aarti at interia.pl
Wed Oct 17 00:36:46 PDT 2007
Brad Roberts pisze:
> Aarti_pl wrote:
>> Bill Baxter pisze:
>>> Marcin Kuszczak wrote:
>>>> Walter Bright wrote:
>>>>
>>>>> Carlos Santander wrote:
>>>>>> Maybe I missed something, but does the inclusion of std.variant mean
>>>>>> that std.boxer will be deprecated or removed at some point?
>>>>>
>>>>> Yes. If you're using boxer, take a serious look at variant, and see if
>>>>> that works for you.
>>>>
>>>> There is missing functionality in variant though. I mean converting
>>>> variadic
>>>> function parameters into array of Boxes. It's nice, so it should be
>>>> retained IMHO.
>>>
>>> I just used std.boxer for the first time recently.
>>> The thing that I found missing was methods for working with and
>>> converting boxed arrays (*not* arrays of boxes). You can only
>>> unconvert to the exact type of the original, and there's no
>>> overloaded opIndex or getElem/setElem functions. No way to ask what
>>> the type of an element is either. I wrote some templates that did
>>> the trick for what I wanted, but I had to copy a few private things
>>> out of std.boxer to do it. I'd file an enhancement request and maybe
>>> even a patch if I believed anyone would do anything about it.
>>>
>>> --bb
>>>
>>>
>>
>> You are lucky then :-)
>> It seems that std.variant from D 2.0 has such a functionality...
>>
>> ----
>>
>> With boxing of variadic parameters I meant something like this:
>>
>> # void func(...) {
>> # Box[] barr = boxArray(_arguments, _argptr);
>> # }
>>
>> It can be usefull e.g. for repassing arguments to other function.
>>
>> BR
>> Marcin Kuszczak
>
> Take a closer look. Std/variant.d contains:
>
> Variant[] variantArray(T...)(T args)
> {
> Variant[] result;
> foreach (arg; args)
> {
> result ~= Variant(arg);
> }
> return result;
> }
>
> It's a template rather than using the variadic options, but the end
> result is the same.
But how to use it with non-template variadic functions?
Could you please provide example?
----
And I if you could also address my second question (Variant inside Variant):
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.announce&article_id=10305
Thanks in advance!
BR
Marcin Kuszczak
More information about the Digitalmars-d
mailing list