Search

B.3 — Introduction to C++17

What is C++17?

In September of 2017, the ISO (International Organization for Standardization) approved a new version of C++, called C++17. C++17 contains a fair amount of new content

New improvements in C++17

For your interest, here’s a list of the major improvements that C++17 adds. Note that this list is not comprehensive, but rather intended to highlight some of the key improvements of interest.

  • __has_include preprocessor identifier to check if optional header files are available (no tutorial yet)
  • if statements that resolve at compile time (no tutorial yet)
  • Initializers in if statements and switch statements (no tutorial yet)
  • inline variables (no tutorial yet)
  • Fold expressions (no tutorial yet)
  • Nested namespaces can now be defined as namespace X::Y (4.3b -- Namespaces)
  • Removal of std::auto_ptr and some other deprecated types
  • static_assert no longer requires a diagnostic text message parameter (7.12a -- Assert and static_assert)
  • std::any (no tutorial yet)
  • std::byte (no tutorial yet)
  • std::filesystem (no tutorial yet)
  • std::optional (no tutorial yet)
  • std::shared_ptr can now manage C-style arrays (but std::make_shared can’t create them yet) (15.6 -- std::shared_ptr)
  • Structured binding declarations (7.4a -- Returning values by value, reference, and address, but could use a full lesson)
  • Template deduction for constructors (no tutorial yet)
  • Trigraphs have been removed (no tutorial yet)
  • typename can now be used (instead of class) in a template template parameter (no tutorial yet)
  • UTF-8 (u8) character literals (no tutorial yet)
Appendix C -- The end?
Index
B.2 -- Introduction to C++14

6 comments to B.3 — Introduction to C++17

  • Soumya

    Hi Alex,

    I am a great fan of your website. But recently I saw in reddit that they discourage your site for learning C++ [https://www.reddit.com/r/learnprogramming/wiki/index#wiki_discouraged_resources].

    Actually I am worried and need your response to this. It would cleanse doubts in me and many others.

    Thanks.

    • Hi Soumya!

      This has been discussed on said subreddit several times, I couldn't find a statement of a wiki maintainer.

      Summing it up:
      Some people don't like that Alex uses "wrong" names to explain certain topics. Though, throwing technical words and descriptions at a beginner is discouraging. As long as there's a transfer to the proper names once the basics are set, I don't see a problem.
      Some people don't like the order of the chapters/lessons, others do like the current order.
      There were and still are inconsistencies across all lessons, because the lessons weren't all written on the same day obviously. Alex fixes these inconsistencies once they are pointed out. One of the complaints was about @std::endl and '\n' being mixed. This has been addressed by Alex and mostly, if not entirely, been fixed.
      You'll have to go through a lot of lessons before you get to the topics that separate C and C++. Again, this can be considered good or bad.

      My opinion (I haven't read the lessons (apart from 2 or 3), I just reply to comments and give suggestions to learners):
      Learncpp is dated. Alex appears to be busy irl, so I can't blame him for not yet having lessons about C++14, 17 and 20. But there is too few content about C++11, and the content that is covered falls short compared to the pre C++11 content. eg. 9 lessons about C-style arrays and only 3 about @std::vector and @std::array,  @std::string not being properly discussed until chapter 17!
      A lot of quizzes involve writing algorithms, but Alex rarely mentions the @std functions that could be used instead (eg. @std::sort, @std::accumulate, @std::end, etc.). The @std library is too important to be left out.
      The first couple of lessons teach bad practice, some of which stretches throughout the entire tutorials (eg. std::endl and not using uniform initialization). All lessons should use the recommended features. The discouraged features should be discussed briefly, stating the difference to their alternatives and why they shouldn't be used.
      Adding rules but not following them in the tutorials causes readers the forget about the rules and don't follow them either.

      Despite these problem, I think of learncpp as the best place to learn C++.
      learncpp is actively maintained, questions get answered and errors get fixed. There are quizzes every couple of lessons which help understanding the lessons. C++ is a difficult language and Alex does a great job explaining it.

      Resources
      - https://www.reddit.com/r/learnprogramming/comments/4wbeg5/is_learncppcom_still_considered_bad/
      - https://www.reddit.com/r/learnprogramming/comments/6z8en4/why_is_learncppcom_a_discouraged_resource/
      - https://www.reddit.com/r/learnprogramming/comments/3ncs7q/c_learncppcom_has_been_updated_is_it_a_reliable/

  • P-z

    2nd line:

      ISO (International Organization for Standardization)

    Shouldn't Organization and Standardization be flipped? Or IOS instead of ISO?

    • "ISO is not an acronym. The organization adopted ISO as its abbreviated name in reference to the Greek word isos (ίσος, meaning "equal"),[4] as its name in the three official languages would have different acronyms. "
      https://en.wikipedia.org/wiki/International_Organization_for_Standardization#Name_and_abbreviations

  • nascardriver

    "Nested namespaces can now be defined as namespace X:Y"
    is missing a colon
    "Nested namespaces can now be defined as namespace X::Y"

Leave a Comment

Put all code inside code tags: [code]your code here[/code]