Re: specialized templates not working as expected

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/19/20 10:15 PM, Jonathan Wakely wrote:
I understand that this is a template instantiation problem.
But I'm wondering why there is such a difference
in standard interpretation for such an old C++ feature.

Either MSVC has a bug, or it chooses to use the end of the file as the
point of instantiation for all templates. The latter is allowed by the
standard.

I also understand that there are other possibilities
to achieve a similar effect, but I don't like to discuss
these possibilities here.

So then what's the question?

The question was only
if this could be due to different standard interpretations.

The code says "can this block be simplified or even removed?" and the
answer's yes, but you said you don't want to discuss that.
This comment is a leftover from a discussion with my colleagues.
We wondered, if it would be possible to simplify this block
for given N foos to an O(1) sized block.
As shown, this was possible with MSVC.

I got suggestions to completely rewrite this minimal reproducer,
which comes from a customer project.
I don't want to discuss this here again.

If you reorder the specializations so that A<int>::A() comes last then
it compiles with GCC (and Clang and EDG). The problem is that
A<int>::A() triggers the implicit instantiation of the other member
functions, before the specializations have been seen. By reordering
them the specializations have been defined before the instantiation
happens.
Reordering might not be possible :-( (see above)

Kind Regards
Andre






[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux