Boost logo

Boost :

Subject: Re: [boost] [variant] awkward recursion
From: Dave Abrahams (dave_at_[hidden])
Date: 2012-11-01 14:14:49


on Thu Nov 01 2012, Marc Glisse <marc.glisse-AT-inria.fr> wrote:

> 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.

Yeah... problem is, that might turn out to be wrong.

-- 
Dave Abrahams
BoostPro Computing                  Software Development        Training
http://www.boostpro.com             Clang/LLVM/EDG Compilers  C++  Boost

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