Class size versus cover template class

Consider the code below:

class Foo
{
    ...
};

template <class T>
class Bar
{
    T t;
};

Is it guaranteed to sizeof(Foo) == sizeof(Bar<Foo>)always evaluate truein any standard C ++ compiler?

Are there situations in which this condition will never be true?

+4
source share
1 answer

I do not believe that the standard makes this guarantee - the implementation is free to add an add-on at the end Bar.

, Bar, Foo. , , Foo (, ); Bar .

+5

Source: https://habr.com/ru/post/1540756/


All Articles