instantiation point discussion

This is a discussion on instantiation point discussion within the C++ Programming forums, part of the General Programming Boards category; Hello everyone, We have a lot of discussion in the two days, seems points from people are not quite the ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    instantiation point discussion

    Hello everyone,


    We have a lot of discussion in the two days, seems points from people are not quite the same (at least to some degree). Let me quote the original statement from Bjarne and code again here.

    My question is,

    1. if you agree g(int) -- declaration only -- will not instantise function f to f<int>, which conflicts with Bjarne's point, could you provide some code to prove please?

    2. if you agree with Bjarne's points, g(int) -- declaration only -- will instantise function f to f<int>, could you also provide some code to prove please?

    My point is (1), since I think VC instantise a template only when we use it other than deduce any information from template definition phase -- but I can not prove it. If you could prove (1), it is great!

    Code:
    // section C.13.8.3 Point of Instantiatant Binding
    
    template <class T> void f (T a) { g(a); }
    
    void g(int);
    
    void h()
    {
    	extern g (double);
    	f (2);
    }
    --------------------
    the point of instantiation for f<int>() is just before h(), so the g() called in f() is the global g (int) rather than the local g (double).
    --------------------

    BTW: from above statement from Bjarne, I think he means declaration of g(int) before h() will instiatise f to f <int>.


    thanks in advance,
    George

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    seems points from people are not quite the same
    Er ... the situation is this: everyone here agrees, except you. You still claim that we contradict Stroustrup, although that's just your misinterpretation of what he wrote.

    This thread is entirely unnecessary. You already have two others concerned with the point of instantiation problem.

    So stop claiming that Stroustrup supports your misconception and re-read the material.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to monitor process creation?
    By markiz in forum Windows Programming
    Replies: 31
    Last Post: 03-17-2008, 02:39 PM
  2. template function instantiation
    By George2 in forum C++ Programming
    Replies: 21
    Last Post: 03-09-2008, 06:35 AM
  3. Drawing Program
    By Max_Payne in forum C++ Programming
    Replies: 21
    Last Post: 12-21-2007, 04:34 PM
  4. floating point binary program, need help
    By ph34r me in forum C Programming
    Replies: 4
    Last Post: 11-10-2004, 06:10 AM
  5. overloading operator help
    By syrel in forum C++ Programming
    Replies: 8
    Last Post: 09-30-2004, 10:49 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21