|
Boost : |
Subject: Re: [boost] [variant] awkward recursion
From: Marc Glisse (marc.glisse_at_[hidden])
Date: 2012-11-01 11:31:46
On Thu, 1 Nov 2012, Dave Abrahams wrote:
> on Wed Oct 31 2012, Antony Polukhin <antoshkka-AT-gmail.com> wrote:
>
>> May be it would be better to write a metafunction:
>>
>> template <class T> size_forward {
>> enum ENUM{value = sizeof(T)};
>> };
>>
>> User is free to specialize it, so Boost.Variant can use it to get
>> sizes of types (instead of directly calling to sizeof(T))
>>
>> Specialization for your case will be:
>>
>> template <> struct size_forward<vector<Y>> {
>> enum ENUM{value = sizeof(vector<X>)};
>> };
>>
>> I think that such metafunction could be widely used (for example in
>> Boost.Optional)
>
> As far as I can tell, putting sizeof() inside a layer of template
> instantiation doesn't solve anything. But maybe I'm missing something.
I think he is replacing sizeof(vector<incomplete>) with
sizeof(vector<int>) (as suggested a few messages back), not just hiding
sizeof in templates.
-- Marc Glisse
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk