On Fri, Nov 14, 2014 at 4:23 AM, Larry Evans <cppljev...@suddenlink.net> wrote:
> On 11/14/2014 12:48 AM, David Blaikie wrote: > > My guess is that the proposal was written assuming a certain > implementation > > of constexpr that never panned out. > > > > It looks like both GCC and Clang expect constexpr member variables to be > > explicitly marked static: > > > > const.cpp:5:19: error: non-static data member 'f' declared 'constexpr' > > constexpr foo f{}; > > ^ > > > > (is GCC 4.9's diagnostic - for a simple non-template constexpr member > variable) > > > That's sad because, as n3651 says on pp. 2-3: > > The main problems with “static data member” are: > > • they require “duplicate” declarations: once inside the class > template, once outside the class template to provide the “real” > definition in case the constants is odr-used. > then don't put it in a class. > > • programmers are both miffed and confused by the necessity of > providing twice the same declaration. By contrast, “ordinary” > constant declarations do not need duplicate declarations. > > Also, the clang status page: > > http://clang.llvm.org/cxx_status.html > > reference n3651 below the section title: > > C++14 implementation status > > Hence, I thought that's what clang implemented. > > In addition, the latest standard *draft*: > > https://isocpp.org/files/papers/N3797.pdf > > contains the n3651 matrix_constants example on p. 313. > > Is there some more current standards document which requires the > static qualifier on variable templates within a class? > > TIA. > > -regards, > Larry > > > On Thu, Nov 13, 2014 at 8:38 PM, Larry Evans <cppljev...@suddenlink.net> > > wrote: > > > >> The following code: > >> > >> //{======================================= > >> #include <type_traits> > >> struct variable_template > >> { > >> template <int Value> > >> std::integral_constant<int,Value> constexpr > >> value{} > >> ; > >> }; > >> #include <iostream> > >> #include <iomanip> > >> int main() > >> { > >> std::cout<< > >> variable_template:: > >> value<1>()<<std::endl; > >> return 0; > >> } > >> //}======================================= > [snip] > > > _______________________________________________ > cfe-users mailing list > cfe-users@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users >
_______________________________________________ cfe-users mailing list cfe-users@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users