103

The C++ Standards Committee tends to shy away from adding new keywords to the language, yet with C++11 that was not the case. Some examples:

constexpr
decltype
thread_local
auto // New usage
noexcept
nullptr
static_assert
alignof
alignas

Are there any new keywords introduced with C++14?

0

3 Answers 3

134

Table 4 (Keywords) in N3936 (C++14):

alignas           continue          friend            register          true
alignof           decltype          goto              reinterpret_cast  try
asm               default           if                return            typedef
auto              delete            inline            short             typeid
bool              do                int               signed            typename
break             double            long              sizeof            union
case              dynamic_cast      mutable           static            unsigned
catch             else              namespace         static_assert     using
char              enum              new               static_cast       virtual
char16_t          explicit          noexcept          struct            void
char32_t          export            nullptr           switch            volatile
class             extern            operator          template          wchar_t
const             false             private           this              while
constexpr         float             protected         thread_local
const_cast        for               public            throw

Table 4 in N3337 (C++11):

alignas           continue          friend            register          true
alignof           decltype          goto              reinterpret_cast  try
asm               default           if                return            typedef
auto              delete            inline            short             typeid
bool              do                int               signed            typename
break             double            long              sizeof            union
case              dynamic_cast      mutable           static            unsigned
catch             else              namespace         static_assert     using
char              enum              new               static_cast       virtual
char16_t          explicit          noexcept          struct            void
char32_t          export            nullptr           switch            volatile
class             extern            operator          template          wchar_t
const             false             private           this              while
constexpr         float             protected         thread_local
const_cast        for               public            throw

...which is a long-winded way of saying "no".

(override and final are "identifiers with special meaning" and are listed in Table 3; and etc. are "alternative representations...for certain operators and punctuators" and are listed in Table 5. Neither table changed between C++11 and C++14.)

6
  • 2
    I'd say that that is because they are put in the global namespace of every translation unit. (Yeah, you can ask why that is, and then well...) Aug 19, 2014 at 10:11
  • 2
    Is the register keyword still useful or used in new C++11 code?
    – Walter
    Aug 19, 2014 at 13:57
  • 2
    @Walter It's deprecated and widely ignored by compilers anyway.
    – T.C.
    Aug 19, 2014 at 13:59
  • 1
    The alternative tokens for logical operators are not mentioned in those tables? Are they not C++ keywords? Aug 19, 2014 at 19:20
  • 1
    @NikosAthanasiou, There's a table for those right under this one IIRC.
    – chris
    Aug 19, 2014 at 19:28
85

I'm posting this answer for the sake of giving tools for finding answers to similar questions.

The standard draft is currently kept in a public GitHub repository. That means you can ask this question to GitHub itself!

The keywords table is on the file source/lex.tex. If you do a blame on it, we can find that the last change to the keywords table took place back in August 2011 (it's actually the first commit: that table hasn't changed since the repo went live around the time C++11 was being finalised).

Alternatively we can ask GitHub to compare the two drafts that were sent for ballot for both versions of the standard: N3337 and N3936. A diff between those two shows that the changes to lex.tex did not change anything in the keywords table.

1
  • 2
    Thanks for this! Looks like there's still been no changes as of today.
    – sbi
    Mar 29, 2016 at 12:44
34

No new keywords will be added with C++14. This is unsurprising as C++14 is intended as a small upgrade to C++11 mainly involved in cleaning up bugs and making small, low impact, improvements. The next major change is likely to be C++'17' where I would expect new keywords once more.

The C++ Standards Committee tends to shy away from adding new keywords to the language, yet with C++11 that was not the case.

I think it's worth considering why the committee shies away from adding new keywords (and co-incidentally why you are wrong to include auto on your list). The main problem with new keywords is that in C++ you can't use a keyword as an identifier which means that adding a new keyword breaks existing code. Repurposing auto, then, doesn't break their rule because no existing code could use auto as an identifier anyway.

So in order to accept a new keyword there needs to be a justification that outweighs the cost of a potential clash with existing code and no sensible way to implement the same thing without a new keyword. In the case of C++11, the committee accepted a few proposals that required new keywords since they felt that that the benefit outweighed the cost not because they don't hate to add new keywords.

It's also why, if you look down the list you gave, each one is a compound keyword since that reduces the chance that they'll clash with existing identifiers.

3
  • 1
    "C++'17' where I would expect new keywords once more.": Will C++ eventually stop growing?
    – Giorgio
    Aug 20, 2014 at 15:03
  • 2
    @Giorgio Will software & hardware eventually stop evolving ? The big dilemma here is whether you can take a bold decision and throw away "old" syntax, break old code and proceed just with the evolved part of the language. Python kinda tries to do that Dec 13, 2014 at 8:32
  • 2
    @NorahAttkins: Clearly software must evolve, but growing a language indefinitely is not the only solution: when a language is mature for a certain niche, you can always break compatibility and start a new language to satisfy the needs of new niches. Python is one example. Other examples are C++ --> Java, Java --> Scala, Common Lisp --> Clojure, C++ --> D. Some languages grow indefinitely because their community is convinced that their favourite language is the only true language and they want it to be suited for all possible application areas. Of course, this expectation is not realistic.
    – Giorgio
    Dec 13, 2014 at 11:46

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.