Topic: N2713 vs. decltype


Author: restor <akrzemi1@interia.pl>
Date: Tue, 14 Apr 2009 18:16:20 CST
Raw View
Hi,
I learned in the latest "State of C++ Evolution" that N2713, which
proposed the syntax like:

     class Grammar {
         auto rule = expr1 + expr2;
     };

is dead. The rationale is that in a more complicated example like:

     template< class T >
     struct MyType : T {
         auto data = func();
         static const size_t erm = sizeof(data);
      };

makes determining the layout of the class  too complicated on the one
hand, and is likely to violate the One Definition Rule ("depending on
the order of header inclusion") on the other.

N2713 Also mentions that the same effect is already achievable with
the use of decltype:

     template< class T >
     struct MyType : T {
         decltype(func()) data = func();
         static const size_t erm = sizeof(data);
      };

Is allowing the above code a defect? Is the decltype operator going to
be banned from declaring non-static data members?

Regards,
&rzej

--
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]