Topic: The wording for lambdas


Author: Greg Herlihy <greghe@pacbell.net>
Date: Mon, 15 Oct 2007 18:39:44 CST
Raw View
On Oct 6, 11:47 am, restor <akrze...@interia.pl> wrote:
> I have one concern about lambda wording (N2413). Will an introduction
> of a new token <> not invalidate any code that fully specializes a
> template, or instantiates a template that has default values for all
> its parameters?
>
> My understanding is that the code below would have two syntax errors:
> -----------------------------------------------------------
> template< typename T = int > struct Str{};
>
> template<> struct Str<int> {};  // Error: Invalid Lambda definition
> Str<> str;                      // The same

No, the proposed syntax for lambda definitions never has a "<>" appear
after an identifier or a keyword. Whereas the syntax for C++ templates
always has a "<>" appear after either an identifier or the "template"
keyword. Therefore a C++ compiler should be able to tell whether a
"<>" is part of lambda definition or part of a template specialization
based on what came before it.

Greg


> --------------------------------------------------------
> Should the standard not add a note in 14.3 that the token <> may be
> split into two in some contexts, the same way that N1757 does?

No, there

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





Author: restor <akrzemi1@interia.pl>
Date: Sat, 6 Oct 2007 12:47:19 CST
Raw View
I have one concern about lambda wording (N2413). Will an introduction
of a new token <> not invalidate any code that fully specializes a
template, or instantiates a template that has default values for all
its parameters?

My understanding is that the code below would have two syntax errors:
-----------------------------------------------------------
template< typename T = int > struct Str{};

template<> struct Str<int> {};  // Error: Invalid Lambda definition
Str<> str;                      // The same
--------------------------------------------------------
Should the standard not add a note in 14.3 that the token <> may be
split into two in some contexts, the same way that N1757 does?

&rzej

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