<div dir="ltr">Good. <div><br></div><div>-- Gaby</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 24, 2014 at 9:01 AM, Larry Evans <span dir="ltr"><<a href="mailto:cppljevans@suddenlink.net" target="_blank">cppljevans@suddenlink.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 11/19/2014 10:32 AM, Larry Evans wrote:<br>
> On 11/14/2014 01:01 PM, David Blaikie wrote:> On Fri, Nov 14, 2014 at<br>
> 4:23 AM, Larry Evans <<a href="mailto:cppljevans@suddenlink.net">cppljevans@suddenlink.net</a>><br>
>> wrote:<br>
>><br>
>>> On 11/14/2014 12:48 AM, David Blaikie wrote:<br>
>>>> My guess is that the proposal was written assuming a certain<br>
>>> implementation<br>
>>>> of constexpr that never panned out.<br>
>>>><br>
>>>> It looks like both GCC and Clang expect constexpr member variables to be<br>
>>>> explicitly marked static:<br>
>>>><br>
>>>> const.cpp:5:19: error: non-static data member 'f' declared 'constexpr'<br>
>>>>    constexpr foo f{};<br>
>>>>                    ^<br>
>>>><br>
>>>> (is GCC 4.9's diagnostic - for a simple non-template constexpr member<br>
>>> variable)<br>
>>>><br>
>>> That's sad because, as n3651 says on pp. 2-3:<br>
>>><br>
>>>   The main problems with “static data member” are:<br>
>>><br>
>>>   • they require “duplicate” declarations: once inside the class<br>
>>>     template, once outside the class template to provide the “real”<br>
>>>     definition in case the constants is odr-used.<br>
>>><br>
>>>   • programmers are both miffed and confused by the necessity of<br>
>>>     providing twice the same declaration. By contrast, “ordinary”<br>
>>>     constant declarations do not need duplicate declarations.<br>
>>><br>
>><br>
>> I don't think this is referring to the need to write "static" in a static<br>
>> member variable template declaration.<br>
>><br>
>> This is referring to the workaround (In the absence of static<br>
> variables) of<br>
>> using a class template with a nested static data member - pointing out<br>
> that<br>
>> when you write it that way (see the example near this workaround<br>
>> description) you have to write the class, the variable declaration,<br>
> and the<br>
>> variable definition. Whereas with a plain non-member variable template you<br>
>> don't need separate declaration/definition - the variable template (like a<br>
>> function template) is the declaration+definition all in one.<br>
>><br>
><br>
> So, if the keyword, static, *is* used, a separate definition *outside* of<br>
> the class (IOW, in, I think the terminology is, "in namespace scope")<br>
> is needed. In contrast, if keyword static *is not* used, the<br>
> separate definition is not required ( even though the<br>
> variable is still a static member) ?<br>
><br>
>><br>
>>> Also, the clang status page:<br>
>>><br>
>>>   <a href="http://clang.llvm.org/cxx_status.html" target="_blank">http://clang.llvm.org/cxx_status.html</a><br>
>>><br>
>>> reference n3651 below the section title:<br>
>>><br>
>>>   C++14 implementation status<br>
>>><br>
>>> Hence, I thought that's what clang implemented.<br>
>>><br>
>><br>
>> Ah, here's the wording that's important:<br>
>><br>
>> "A variable template at class scope is a static data member template." in<br>
>> 14 paragraph 1.<br>
>><br>
>> (sorry, I'd been looking in the static member parts of the spec, not the<br>
>> variable template parts, which have this special case)<br>
>><br>
>> It looks like this just hasn't been implemented - Larisse (CC'd) did the<br>
>> initial variable template implementation. Perhaps she can tell us if that<br>
>> was a more recent change, whether it's planned to be fixed, or a bug<br>
> in the<br>
>> spec etc.<br>
>><br>
> The reponse to my comment here:<br>
><br>
>   <a href="http://en.cppreference.com/w/Talk:cpp/language/variable_template" target="_blank">http://en.cppreference.com/w/Talk:cpp/language/variable_template</a><br>
><br>
> says:<br>
><br>
>   the examples in the standard have an error, mentioned<br>
>   _here_<br>
><br>
> where _here_ links to:<br>
><br>
><br>
> <a href="http://stackoverflow.com/questions/21474111/variable-template-at-class-scope/21482264?noredirect=1#comment32627331_21482264" target="_blank">http://stackoverflow.com/questions/21474111/variable-template-at-class-scope/21482264?noredirect=1#comment32627331_21482264</a><br>
><br>
> which is, essentially, the question posed in my OP to this<br>
> thread.  In addition, the comments to that SO post contain:<br>
><br>
>   _The committee is aware that the wording for variable<br>
>   templates needs some help in various places_<br>
><br>
> which links to:<br>
><br>
><br>
> <a href="https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/ZTw3W3vjWWs" target="_blank">https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/ZTw3W3vjWWs</a><br>
><br>
> which I'm still trying to digest :(, but it seems to<br>
> indicate the variable template meaning is ambiguous; hence,<br>
> one can't say clang has a bug in its implementation<br>
> of variable templates.<br>
><br>
</div></div>My last response to the talk:<br>
<br>
<a href="http://en.cppreference.com/w/Talk:cpp/language/variable_template" target="_blank">http://en.cppreference.com/w/Talk:cpp/language/variable_template</a><br>
<br>
contains:<br>
<br>
  the definition outside the class definition is ...<br>
  *only* optional if a reference is not made to the template variable.<br>
<br>
and a reference to the standard's 9.4.2p3 is made to justify that<br>
conclusion.<br>
<br>
Hence, AFAICT, clang is correct in requiring the outside class defintion<br>
when the template variable is referenced.<br>
<br>
-regards,<br>
Larry<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-users mailing list<br>
<a href="mailto:cfe-users@cs.uiuc.edu">cfe-users@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users</a><br>
</div></div></blockquote></div><br></div>