<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Nov 14, 2014 at 4:23 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:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On 11/14/2014 12:48 AM, David Blaikie wrote:<br>
> My guess is that the proposal was written assuming a certain 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 variable)<br>
><br>
</span>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></blockquote><div><br></div><div>I don't think this is referring to the need to write "static" in a static member variable template declaration.<br><br>This is referring to the workaround (In the absence of static variables) of using a class template with a nested static data member - pointing out that when you write it that way (see the example near this workaround description) you have to write the class, the variable declaration, and the variable definition. Whereas with a plain non-member variable template you don't need separate declaration/definition - the variable template (like a function template) is the declaration+definition all in one.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">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></blockquote><div><br></div><div>Ah, here's the wording that's important:<br><br>"A variable template at class scope is a static data member template." in 14 paragraph 1.<br><br>(sorry, I'd been looking in the static member parts of the spec, not the variable template parts, which have this special case)<br><br>It looks like this just hasn't been implemented - Larisse (CC'd) did the initial variable template implementation. Perhaps she can tell us if that was a more recent change, whether it's planned to be fixed, or a bug in the spec etc.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">In addition, the latest standard *draft*:<br>
<br>
  <a href="https://isocpp.org/files/papers/N3797.pdf" target="_blank">https://isocpp.org/files/papers/N3797.pdf</a><br>
<br>
contains the n3651 matrix_constants example on p. 313.<br>
<br>
Is there some more current standards document which requires the<br>
static qualifier on variable templates within a class?</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
TIA.<br>
<br>
-regards,<br>
Larry<br>
<span class=""><br>
> On Thu, Nov 13, 2014 at 8:38 PM, Larry Evans <<a href="mailto:cppljevans@suddenlink.net">cppljevans@suddenlink.net</a>><br>
> wrote:<br>
><br>
>> The following code:<br>
>><br>
>> //{=======================================<br>
>> #include <type_traits><br>
>> struct variable_template<br>
>> {<br>
>>     template <int Value><br>
>>     std::integral_constant<int,Value> constexpr<br>
>>   value{}<br>
>>     ;<br>
>> };<br>
>> #include <iostream><br>
>> #include <iomanip><br>
>> int main()<br>
>> {<br>
>>     std::cout<<<br>
>>       variable_template::<br>
>>       value<1>()<<std::endl;<br>
>>     return 0;<br>
>> }<br>
>> //}=======================================<br>
</span>[snip]<br>
<div class=""><div class="h5"><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></div>