[cfe-dev] in class member initializations not working? (clang 3.0)

Richard Smith richard at metafoo.co.uk
Wed Mar 7 19:37:48 PST 2012


You must use = or {}. The parentheses form would be ambiguous, and the C++
committee chose to avoid adding another place to the C++ grammar where
disambiguation was required.

On Wed, Mar 7, 2012 at 5:25 PM, David Blaikie <dblaikie at gmail.com> wrote:

> I believe you have to use = for in-place member initialization.
>
> On Wed, Mar 7, 2012 at 5:23 PM, Ryan Ericson <ryan.ericson at gmail.com>
> wrote:
> > Clang C++11 status page says that "Non static data member
> initializations"
> > is available in clang 3.0.
> >
> > I'm on Xcode 4.3, clang++ --version gives this:
> > Apple clang version 3.1 (tags/Apple/clang-318.0.45) (based on LLVM
> 3.1svn)
> >
> > This example fails to compile:
> > #include <string>
> > using namespace std;
> >
> > struct foo
> > {
> > string s("aa");
> > };
> >
> > With this error:
> > test3.cpp:6:11: error: expected parameter declarator
> >         string s("aa");
> >                  ^
> > test3.cpp:6:11: error: expected ')'
> > test3.cpp:6:10: note: to match this '('
> >         string s("aa");
> >
> > Am I misunderstanding something? Thanks in advance!
> >
> >
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> >
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120307/69b44376/attachment.html>


More information about the cfe-dev mailing list