Is `auto int i` valid C++0x?

后端 未结 1 1068
野性不改
野性不改 2021-01-14 12:46

In answering this question the question arose as to whether the traditional C meaning of the keyword auto (automatic storage) is still valid in

相关标签:
1条回答
  • 2021-01-14 13:16

    No, it is not. In fact, §7.1.6.​4/3 gives the following example:

    auto x = 5; // OK: x has type int
    const auto *v = &x, u = 6; // OK: v has type const int*, u has type const int
    static auto y = 0.0; // OK: y has type double
    auto int r; // error: auto is not a storage-class-specifier
    

    As you can see, it results in an error. §7.1.6.​5 pretty much seals the deal with:

    A program that uses auto in a context not explicitly allowed in this section is ill-formed.

    0 讨论(0)
提交回复
热议问题