non-dependent name in template function

Discussion in 'C Programming' started by George2, Mar 10, 2008.

  1. George2

    George2

    Joined:
    Feb 12, 2008
    Messages:
    108
    Hello everyone,


    I am confused about what Bjarne means below, and I quoted the section name, his words and his sample.

    My question is, what did he mean "A call that by coincidence has an argument that matches an actual template parameter type is not dependent"?

    I think the compile error is because, g (1) function call is not dependent on template parameter, and it should be resolved in the definition phase (not instantiation phase) of template function f. But in definition phase of f, what g is (the symbol g) can not be resolved. So comes the compile error.

    Is my analysis correct? What did Bjarne mean?

    (section C.13.8.1 Dependent Names)

    --------------------
    A call that by coincidence has an argument that matches an actual template parameter type is not dependent. For example,
    --------------------

    Code:
    template <class T> T f (T a)
    {
    	return g (1); // error: no g() in scope and g(1) doesn't depent on T
    }
    
    int g (int);
    
    int z = f (2);
    

    thanks in advance,
    George
    George2, Mar 10, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Allan Schwartz
    Replies:
    1
    Views:
    383
    Victor Bazarov
    Aug 9, 2004
  2. pervinder
    Replies:
    4
    Views:
    2,971
    Malte Starostik
    Mar 29, 2005
  3. er
    Replies:
    1
    Views:
    324
  4. puzzlecracker
    Replies:
    1
    Views:
    501
    James Kanze
    Aug 7, 2008
  5. mlimber
    Replies:
    6
    Views:
    550
    Alf P. Steinbach /Usenet
    May 21, 2011
Loading...

Share This Page