<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Feb 1, 2011, at 12:42 PM, Larisse Voufo wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br><br><div class="gmail_quote">On Tue, Feb 1, 2011 at 3:01 PM, Douglas Gregor <span dir="ltr"><<a href="mailto:dgregor@apple.com">dgregor@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div style="word-wrap: break-word;"><br><div><div class="im"><div>On Feb 1, 2011, at 11:45 AM, Larisse Voufo wrote:</div><br><blockquote type="cite">Let me see if I can rephrase this problem... <br>At this point, instantiation is no longer an issue. The issue is managing new DeclContext's.<br>
<br>Take the following definition of a concept:<br><br>concept A<typename T> {<br>
    void f(int) { }<br>}<br><br>This definition is parsed into a ConceptDecl  object <b>ContextA</b> where ConceptDecl is a DeclContext as well as a TemplateDecl.<br>When the concept is used on a generic function such as:<br>

<br>template<typename T><br>requires A<T><br>void func(T a) {<br>    f(a);<br>}<br><br>at the call f(a),  the lookup process finds the definition of f() in the DeclContext <b>ContextA</b>.  <br>Hence, the definition of func() is accepted. <br>

Let's refer to the found definition as <b>Fn</b>.<br><br>Now, when func() is used in the main, the lookup and instantiation-related processes are still finding and using that same definition of f(): Fn.<br></blockquote>
<div><br></div></div><div>That's wrong. You need to map from the concept's function f() to the corresponding function f() in the concept map.</div><div><br></div><div><span style="white-space: pre-wrap;">        </span>- Doug</div>
</div></div></blockquote><div><br>Perhaps I should've phrased that this is the sample case I'm examining at the moment, not the defacto way that concepts should work. The idea above should generalize to any DeclContext, whether they are  ConceptDecls or not. <br>
For instance, forget concepts, call  "concept A<typename T>" My_DeclContext and replace everything as follows:<br><br> My_DeclContext A {<br>
    void f(int) { }<br>}<br>//This definition is parsed into a SomeDecl  object <b>ContextA</b> where SomeDecl is a DeclContext.<br><br>template<...><br><b>lookup_in (A</b>)<br>
void func(T a) {<br>    f(a);<br>}<br><br>Again, the observations from the previous example should naturally translate to this case, and they are the result of an intensive debugging session (overnight)...<br><br><b>If Fn is found and used throughout the compilation, how come it gets lost at link time? </b><br>
My interest is that: if we can get this to work, then I'll know for sure that I understand the way that lookup and instantiation work in clang, with respect to added declaration contexts. <br></div></div></blockquote><div><br></div><div>Fn is in a concept, so it can't be instantiated without instantiating the concept itself first to produce an instantiated Fn declaration. Then you can go ahead and instantiate the body of the instantiated Fn declaration. Step through how a member function of a class template gets instantiated:</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">      </span>template<typename T></div><div><span class="Apple-tab-span" style="white-space:pre">   </span>struct A {</div><div><span class="Apple-tab-span" style="white-space:pre">           </span>void f(int);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>};</div><div><br></div><div>It doesn't make any sense to instantiate A<T>::f(int) without knowing what T is, but that's what you're trying to do with concepts.</div><div><br></div><blockquote type="cite"><div class="gmail_quote"><div>I'm concerned that we are perhaps getting confused from thinking about this problem from completely different perspective. Marcin was also quite ahead of me on this. :) <br>
Please, just note that I am not particularly thinking of concepts at the moment... I want to very basically understand why the case above would cause the error I am getting, when the only major change I made was in deviating the lookup process for f() so that it is looked up in <b>ContextA </b>-- using LookupQualifiedName(...), rather than in the global scope<b>...<br>
</b></div></div></blockquote></div><div><br></div><div>The change you made means that the function declaration "f" that's being referenced from the instantiation of "func" is still dependent on a template, even though this is non-template code (after instantiation). </div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">       </span>- Doug</div></body></html>