Boost logo

Boost Users :

Subject: Re: [Boost-users] Needs advices on design ( mpl or processor )
From: Allan Nielsen (a_at_[hidden])
Date: 2012-01-09 04:27:56


Hi

Sorry, I have been away from my computer doing the weekend. I'm
looking at your suggested code, and the questions you have raised now.
I will answer as soon as possible.

Best regards
Allan W. Nielsen

On Sun, Jan 8, 2012 at 7:32 PM, Larry Evans <cppljevans_at_[hidden]> wrote:
> On 01/07/12 17:28, Larry Evans wrote:
>> On 01/07/12 02:42, Allan Nielsen wrote:
> [snip]
>>> void example1()
>>> {
>>>     // As you see, the expresions for calculating the offset get quite long,
>>>     // and are not easy to maintain.
>>
>> Here's where I don't understand why the calculation are done outside
>> the temple and then passed as args to the template.
>> Why not have a template do the calculations and accumulate the results,
>> somewhat like mpl::fold or the code I posted earlier?
>>
>>>     C< CompressedEnum<tagA, 1>,
>>>
>>>        CompressedEnum<tagB, CompressedEnum<tagA, 1>::offset *
>>>                             CompressedEnum<tagA, 1>::size >,
>>>
>>>        CompressedEnum<tagC,
>>>
>>>             CompressedEnum<tagB, CompressedEnum<tagA, 1>::offset *
>>>                                  CompressedEnum<tagA, 1>::size >::offset
>>>             *
>>>             CompressedEnum<tagB, CompressedEnum<tagA, 1>::offset *
>>>                                  CompressedEnum<tagA, 1>::size >::size
>>>        >
>>>     > c1;
>>>
>>>
>>> }
>>>
> [snip]
> The attached code produces output:
>
> :eos_t::offset=9
> :get_ol(T1)=2
> :get_ol(T2)=0
> :get_ol(T3)=0
> :get<T3>=0
> putting:
> :get<T1>=0
> :get<T2>=1
> :get<T3>=2
>
> The output before the putting: lines is caused by the obviously
> erroneous initialization of the buffer (no Enum e's stored in
> the buffer, only unsigned ints).  The output after the putting: lines
> shows the effect of the put<Tag,Enum>(Enum e).
>
> However, be warned! I'm not sure all the casting within the get_ol
> and put_ol is portable.
>
> Is this about what you want?
>
> I've looked briefly at Vicente's bit_mask library and it looks
> more complicated; however, that extra complication is probably
> because it provides extra capabilities.
>
> HTH.
>
> -Larry
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net