On 11/15/2014 04:12 PM, Gabriel Dos Reis wrote:> On Sat, Nov 15, 2014 at 9:13 AM, Larry Evans <cppljev...@suddenlink.net> > wrote: > >> On 11/15/2014 09:51 AM, Gabriel Dos Reis wrote: >>> On Sat, Nov 15, 2014 at 6:33 AM, Larry Evans <cppljev...@suddenlink.net> >>> wrote: >>> >>>> On 11/15/2014 06:59 AM, Gabriel Dos Reis wrote: >>>>> On Fri, Nov 14, 2014 at 4:23 AM, Larry Evans < >> cppljev...@suddenlink.net> >>>>> wrote: >>>>> [snip] >>>
>>> If you hate (as I do) having to put a variable in a class template >>> just so that you can abstract over its type but then you are >>> forced to provide a "duplicate" declaration (the real definition) >>> outside the class, then variable templates remove that pain: they >>> do what they were designed for. >> That's what I was hoping. >> >> Maybe the problem is I'm not making my point clear enough. >> If I understand your proposal, then the following code should >> compile without error when: >> !defined(USE_STATIC) && !defined(DUPLICATE_DECLARATION) >> yet, with clang 3.5, it only compiles with both these >> macros are define. >> >> Is clang wrong? >> > > You still have variable template as class member in your original example, > so you have to obey the rules of class members... > Note that your original example was (also) missing the keyword "static" -- > the C++ object model does not permit non-static data member > templates. But the matrix_constants example on p. 4 of n3651 also is missing the keyword "static". The paragraph above that example says: A variable template at class scope is a static data member template. So I'm guessing that the compiler should interpret sigma1 as a class *static* member instead of instance member, *despite* there being no "static" keyword *in the example* (IOW, the sigma1 belongs to the class, not the instances of that class. IOW if: matrix_constants mc1, mc2; there would be only one instance of matrix_constants::sigma1 shared by mc1 and mc2. IOW, there would be no mc1.sigma1 or mc2.sigma1, there would only be matrix_constants::sigma1.) Is that right? Now clang3.5 *requires* the static keyword despite it being absent in the n3651 example. However, *with* static, clang3.5 also requires the "undesired" duplicate declaration to avoid a link-time error about "missing" sigma1 definition. Hence, clang3.5 is wrong in its implementation of n3651, AFAICT. Right? -- Larry _______________________________________________ cfe-users mailing list cfe-users@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users