POV-Ray : Newsgroups : povray.off-topic : A question about Java generics (not a flame) : Re: A question about Java generics (not a flame) Server Time
7 Sep 2024 19:16:16 EDT (-0400)
  Re: A question about Java generics (not a flame)  
From: Warp
Date: 16 May 2008 09:16:07
Message: <482d8917@news.povray.org>
Fredrik Eriksson <fe79}--at--{yahoo}--dot--{com> wrote:
> >   I have to admit I don't know if the C++ standard requires the  
> > environment of the instantation of the template when compiling the
> > template function or not.

> When parsing the template definition, only non-dependent names are looked  
> up. Dependent names are looked up at the instantiation point; at that  
> point both contexts are needed.

  Actually that's not what the C++ standard says. This is the relevant
part of the standard:

    A specialization for a function template, a member
    function template, or of a member function or static
    data member of a class template may have multiple points
    of instantiations within a translation unit. A
    specialization for a class template has at most one
    point of instantiation within a translation unit. A
    specialization for any template may have points of
    instantiation in multiple translation units. If two
    different points of instantiation give a template
    specialization different meanings according to the one
    definition rule (3.2), the program is ill-formed, no
    diagnostic required.

  In short: If the context causes a template instantiation to produce
different results, the program is ill-formed. In other words, the
result is undefined behavior, and the compiler can do whatever it wants.

  I understand this to also mean that the compiler is allowed to compile
an export template just once even if it's instantiated at several places,
using the context of one of those places.

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.