Date: Sun, 6 Jun 2021 10:02:53 -0700
C++ grammar isn't LL, it's LR (to a first approximation). IOW, you can't
simply go left-to-right chomping off one (or N, for some _fixed_ N) and
figure out where you are. You need more context than that.
On Sun, Jun 6, 2021, 09:57 Eric Suen via Std-Discussion <
std-discussion_at_[hidden]> wrote:
> The following code, how do parser know that V is template and B is not?
>
> struct A {
> int a = V<1>();
> bool b = B < 0;
>
> void print() {
> std::cout << a;
> }
>
> template<int v>
> static int V() {
> return v;
> }
>
> static int B;
> };
>
> int A::B = 1;
>
> int main() {
> A a;
> a.print();
> }
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>
simply go left-to-right chomping off one (or N, for some _fixed_ N) and
figure out where you are. You need more context than that.
On Sun, Jun 6, 2021, 09:57 Eric Suen via Std-Discussion <
std-discussion_at_[hidden]> wrote:
> The following code, how do parser know that V is template and B is not?
>
> struct A {
> int a = V<1>();
> bool b = B < 0;
>
> void print() {
> std::cout << a;
> }
>
> template<int v>
> static int V() {
> return v;
> }
>
> static int B;
> };
>
> int A::B = 1;
>
> int main() {
> A a;
> a.print();
> }
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>
Received on 2021-06-06 12:03:07