Is C++14 adding new keywords to C++?

C++C++11KeywordC++14

C++ Problem Overview


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?

C++ Solutions


Solution 1 - C++

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.)

Solution 2 - C++

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.

Solution 3 - C++

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNikos AthanasiouView Question on Stackoverflow
Solution 1 - C++T.C.View Answer on Stackoverflow
Solution 2 - C++R. Martinho FernandesView Answer on Stackoverflow
Solution 3 - C++Jack AidleyView Answer on Stackoverflow