<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Nov 15, 2014 at 9:13 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/15/2014 09:51 AM, Gabriel Dos Reis wrote:<br>
> On Sat, Nov 15, 2014 at 6:33 AM, Larry Evans <<a href="mailto:cppljevans@suddenlink.net">cppljevans@suddenlink.net</a>><br>
> wrote:<br>
><br>
>> On 11/15/2014 06:59 AM, Gabriel Dos Reis wrote:<br>
>>> On Fri, Nov 14, 2014 at 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<br>
>> 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>
>>><br>
>>> then don't put it in a class.<br>
>>><br>
>><br>
>> But then I don't understand why the problem was mentioned in n3651 on<br>
>> pp. 2-3.  I thought one of the reasons for the proposal was to free<br>
>> programmers from the need for "duplicate" declarations; however, the<br>
>> solution:<br>
>><br>
>>   don't put it in a class<br>
>><br>
>> seems to indicate that the problem can be avoided simply by not<br>
>> creating the problem.  IOW, the "duplicate" declaration in the<br>
>> archetypical example on p. 2, the numeric_limits example, can be<br>
>> avoided by not putting it in a template class (or struct in this<br>
>> case).<br>
>><br>
>> In that case, I don't understand the rationale for proposal.<br>
>><br>
>> I must be missing something :(<br>
>><br>
>> -regards,<br>
>> Larry<br>
>><br>
><br>
> If you hate (as I do) having to put a variable in a class template just so<br>
> that you can abstract over its type but then you are forced to provide a<br>
> "duplicate" declaration (the real definition) outside the class, then<br>
> variable templates remove that pain: they do what they were designed for.<br>
<br>
</div></div>That's what I was hoping.<br>
<br>
Maybe the problem is I'm not making my point clear enough.<br>
If I understand your proposal, then the following code should<br>
compile without error when:<br>
  !defined(USE_STATIC) && !defined(DUPLICATE_DECLARATION)<br>
yet, with clang 3.5, it only compiles with both these<br>
macros are define.<br>
<br>
Is clang wrong?<br></blockquote><div><br></div><div>You still have variable template as class member in your original example, so you have to  obey the rules of class members...</div><div><br></div><div>Note that your original example was (also) missing the keyword "static" -- the C++ object model does not permit non-static data member templates.</div><div><br></div><div>-- Gaby</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
><br>
> -- Gaby<br>
<div class="HOEnZb"><div class="h5">><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>
><br>
<br>
</div></div><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>
<br></blockquote></div><br></div></div>